select to open window bookmarklet

  • /*
     * @title select to open window bookmarklet
     * @description exercises
     * @include http://*
     * @license MIT License
     */
    /* for moz */
    (function(){
      var sel = window.getSelection()||false;
      if(sel && sel!="") {
        var rg = sel.getRangeAt(0);
        window.open("data:text/plain;charset=utf8," + encodeURIComponent(rg), "_blank");
      } else if(!sel) {
        alert("\u6B8B\u5FF5");
      }
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/04/10 22:18:16 - 2013-04-10
  2. 2013/04/10 22:13:34 - 2013-04-10