Gi+ git clone

    @@ -1,15 +1,29 @@ /* - * @title Clip Gist clone URL - * @description Gistのページにgit cloneのためのコマンドラインを表示します + * @title G +git:// + * @description append git-protocal (git://) on Gist * @include https://gist.github.com/* - * @license MIT License - * @require + * @contributor xtetsuji http://let.hatelabo.jp/xtetsuji/let/hJmcxdPpvrF- (Fork of) + * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmcxq3wlKcE + * @license MIT License http://opensource.org/licenses/MIT + * @javascript_url */ -(function(){ - var div = document.getElementsByClassName("export-references")[0]; - var li = document.createElement("li"); - var gist_id = location.href.match(/gist\.github\.com\/.*?\/(\d+)/)[1]; - li.innerHTML = '<label for="x-git-clone-field"><strong>Git Clone</strong> this gist.</label><input type="text" readonly spellcheck="false" class="url-field js-url-field" name="x-git-clone-field" value="git clone git@github.com:'+gist_id+'.git">'; - div.appendChild(li); +(function () { + var id = (location.pathname.match(/\/.*\/(\w+)/) || [])[1], + container = document.querySelector('.export-references'); + if (!id || !container) return; + + var gpField = document.createElement("li"); + + // TODO omit innerHTML + gpField.innerHTML = [ + '<label for="x-git-clone-field">', + '<strong>Git Clone</strong> this gist', + '</label>', + '<input type="text" readonly spellcheck="false" class="url-field js-url-field"', + 'name="x-git-clone-field"', + 'value="git clone git@github.com:', id, '.git">' + ].join(''); + + container.appendChild(gpField); })();
  • /*
     * @title G +git://
     * @description append git-protocal (git://) on Gist
     * @include https://gist.github.com/*
     * @contributor xtetsuji  http://let.hatelabo.jp/xtetsuji/let/hJmcxdPpvrF- (Fork of)
     * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmcxq3wlKcE
     * @license MIT License http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    (function () {
      var id = (location.pathname.match(/\/.*\/(\w+)/) || [])[1],
        container = document.querySelector('.export-references');
      if (!id || !container) return;
    
      var gpField = document.createElement("li");
    
      // TODO omit innerHTML
      gpField.innerHTML = [
        '<label for="x-git-clone-field">',
        '<strong>Git Clone</strong> this gist',
        '</label>',
        '<input type="text" readonly spellcheck="false" class="url-field js-url-field"',
        'name="x-git-clone-field"',
        'value="git clone git@github.com:', id, '.git">'
      ].join('');
    
      container.appendChild(gpField);
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/11/08 00:29:45 - 2013-11-08
  2. 2013/11/07 23:42:27 - 2013-11-07
  3. 2013/11/07 23:01:20 - 2013-11-07