gist raw perm HEAD
by
noromanba
2012-04-27 [2012/04/27 03:35:58]
Gistに名前付きハッシュ無しの最新リンクを表示する。Gistのuser.jsインストール時に便利。Greasemonkey版 https://userscripts.org/scripts/show/130781
// ==UserScript==
// @name gist raw HEAD
// @title gist raw HEAD
// @namespace http://www.hatena.ne.jp/noromanba/
// @description Add permanently HEAD link on Gist. Use both Bookmarklet and Greasemonkey. ex.) user.js Install & Update URL / (at)require load xxx.js
// @include https://*gist.github.com/*
// @version 2012.4.13.4.38
// @homepage http://www.hatena.ne.jp/noromanba/
// @license MIT License; http://nrm.mit-license.org/2012
// @copyright (c) 2012+, noromanba (http://www.hatena.ne.jp/noromanba/)
// @author noromanba
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Button_Icon_Orange.svg/32px-Button_Icon_Orange.svg.png
// @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Button_Icon_Orange.svg/64px-Button_Icon_Orange.svg.png
// ==/UserScript==
/*
* @private NIY
*/
// ex.) https://gist.github.com/1862384/
// HTTP 302 => HTTP 200
// https://gist.github.com/raw/1862384/be767303bba9da3ae8bace3542e663f3542e3450/veedama-HatenaStar-AutoSupplement.user.js
// https://raw.github.com/gist/1862384/be767303bba9da3ae8bace3542e663f3542e3450/veedama-HatenaStar-AutoSupplement.user.js
// use this -> https://raw.github.com/gist/1862384/veedama-HatenaStar-AutoSupplement.user.js
(function() {
var raw = document.querySelector('#gist-embed + a');
var head = raw.cloneNode(true); //console.dir('* ' + head);
// @TODO use splice(), slice(), apply() or call()
var perm = head.pathname.split('/')[2] + '/';
perm += head.pathname.split('/').pop();
head.href = 'https://raw.github.com/gist/' + perm; //console.info('* ' + head.href);
head.textContent = head.textContent.replace(/raw/i, 'HEAD');
raw.parentNode.insertBefore(head);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。