Add Raw bookmarklet download link

    @@ -4,7 +4,6 @@ * @include http://let.hatelabo.jp/* * @license MIT License * @require - * @private * @javascript_url */
  • /*
     * @title Add Raw bookmarklet download link
     * @description export supplemental
     * @include http://let.hatelabo.jp/*
     * @license MIT License
     * @require
     * @javascript_url
     */
    
    ((d)=>{  
      const CONTENT = d.querySelector('pre.code-raw')? d.querySelector('pre.code-raw').textContent :'';
      if(!CONTENT) return;
      // console.log(CONTENT);
      const FILENAME = d.title.replace(/ /g, '_').replace(/\.$/, '-');
      const FILE = new File([CONTENT], {type : 'text/plain'});
      const DL = d.createElement('a');
      DL.href = window.URL.createObjectURL(FILE);
      DL.id = 'downloadUNIT';
      DL.textContent = "Download";
      DL.download = FILENAME + '.txt';
      const BODY = d.querySelector('body');
      if(!d.getElementById("downloadUNIT")){
      BODY.insertBefore (DL, BODY.firstChild);
      DL.click();
      }
      void(0);
    })(document);
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2016/03/05 14:56:25 - 2016-03-05
  2. 2016/03/05 14:53:35 - 2016-03-05