getHTMLsource

    @@ -1,14 +1,18 @@ /* - * @title bookmarklet - * @description my bookmarklet - * @include http://*javascript:"http%3A%2F%2Flet.hatelabo.jp%2Fsin5%2Ft%2Fc0dcf3aaf894370fa1d9a22eb8cfc4eb7246e70b.js%20%28arg%29".replace%28%2F%28%5CS%2B%29%5Cs%2B%28%5CS%2A%29%2F%2Cfunction%28s%2Curl%2Carg%29%7Bs%3Ddocument.createElement%28"script"%29%3Bs.charset%3D"utf-8"%3Bs.src%3Durl%2B"%3Fs%3D"%2BencodeURIComponent%28arg%29%3Bdocument.body.appendChild%28s%29%7D%29%3Bvoid%280%29%3B + * @title getHTMLsource + * @description get selected HTML source * @license MIT License - * @require * @private */ -con = document.getSelection().getRangeAt(0).cloneContents(); -div = document.createElement('div'); -document.body.appendChild(div); -div.appendChild(con); -alert(div.innerHTML); +var source = ""; +if(document.getSelection){ + con = document.getSelection().getRangeAt(0).cloneContents(); + div = document.createElement('div'); + document.body.appendChild(div); + div.appendChild(con); + source = div.innerHTML +} else if(document.selection){ + source = document.selection.createRange().htmlText; +} +alert(source);
  • /*
     * @title getHTMLsource
     * @description get selected HTML source
     * @license MIT License
     * @private
     */
    var source = "";
    if(document.getSelection){
      con = document.getSelection().getRangeAt(0).cloneContents();
      div = document.createElement('div');
      document.body.appendChild(div);
      div.appendChild(con);
      source = div.innerHTML
    } else if(document.selection){
      source = document.selection.createRange().htmlText;
    }
    alert(source);
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/06/25 22:49:28 - 2010-06-25
  2. 2010/06/25 22:48:56 - 2010-06-25
  3. 2010/06/25 22:45:32 - 2010-06-25
  4. 2010/06/25 22:40:04 - 2010-06-25
  5. 2010/06/25 03:34:42 - 2010-06-25
  6. 2010/06/25 03:15:36 - 2010-06-25
  7. 2010/06/25 03:14:22 - 2010-06-25
  8. 2010/06/25 03:14:06 - 2010-06-25
  9. 2010/06/25 01:03:37 - 2010-06-25
  10. 2010/06/25 01:02:09 - 2010-06-25
  11. 2010/06/25 00:55:48 - 2010-06-25
  12. 2010/06/25 00:54:13 - 2010-06-25
  13. 2010/06/25 00:53:16 - 2010-06-25
  14. 2010/06/25 00:44:26 - 2010-06-25
  15. 2010/06/25 00:43:45 - 2010-06-25
  16. 2010/06/25 00:36:29 - 2010-06-25
  17. 2010/06/25 00:28:42 - 2010-06-25
  18. 2010/06/25 00:26:12 - 2010-06-25
  19. 2010/06/24 23:07:46 - 2010-06-24