Last active
September 2, 2023 13:03
Revisions
-
noromanba revised this gist
Dec 20, 2014 . 3 changed files with 83 additions and 113 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # gist raw perm HEAD ## Install - https://gist.github.com/noromanba/2370972/raw/gist-raw-perm-HEAD.user.js ## About Visit Gist and see 'raw' link, It's including **SHA-1 long hash name** like this. @@ -14,11 +14,11 @@ This user.js provide 'HEAD' links. It's takes **shrinked permanent raw link** a ### HEAD _**True Permalink**_: This is **absolutery permanent link** but it's _always filetype: txt_. <pre>https://gist.github.com/raw/2370972/</pre> ### HEAD(named) _**Almost Permalink**_: This is almost permanent link. It's _strict filetype_ by extension. **This link broken when filename changed**. <pre>https://gist.github.com/raw/2370972/gist-raw-perm-HEAD.user.js</pre> This link most useful for install user.js from Gist. ## Known Problems @@ -29,29 +29,42 @@ _**HEAD**_ can accessible 1st file only. That is Gist API constraints. ### Binary 1st file e.g. [https://gist.github.com/890279/](https://gist.github.com/890279/) prob SOLVED, sort alphabetic? and text file order are top <s> access to raw https://gist.github.com/raw/890279/ expected https://raw.github.com/gist/890279/simple320_320.png but actual API return [2nd text file data]("https://raw.github.com/gist/890279/gistfile1.txt"). </s> ### Gist API Multifiles Gist has problem. Gist API is not provide true permalink(called _**HEAD**_) for 2nd or more files. #### [Gist API v3](http://developer.github.com/v3/gists/) Include content and history. it's too long too much than v1(closed). - [https://api.github.com/gists/2370972](https://api.github.com/gists/2370972) ## See also ### Gist HTTP e.g. [https://gist.github.com/2370972](https://gist.github.com/2370972) OBSOLETE <s> - GET 'raw' => HTTP 302 `https://gist.github.com/raw/2370972/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js` - => HTTP 200 OK `https://raw.github.com/gist/2370972/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js` </s> ### Bookmarklet base code is small Bookmarklet, you can see based rev below - http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ/rev/gYC-ydWE_JP9Jg latest permalink - http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,109 +1,85 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace http://www.hatena.ne.jp/noromanba/ // @description add permanently HEAD link on Gist for UserScript // @include https://gist.github.com/* // @exclude https://gist.github.com/*/*/revisions // @grant none // @version 2014.12.20.0 // @homepage https://gist.github.com/2370972 // @downloadURL https://gist.github.com/noromanba/2370972/raw/gist-raw-perm-HEAD.user.js // @license MIT License http://nrm.mit-license.org/2012 // @author noromanba http://noromanba.flavors.me // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/32px-Color_icon_orange_v2.svg.png // @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/64px-Color_icon_orange_v2.svg.png // ==/UserScript== // Icon (PD by Mizunoryu, Badseed, Jacobolus) // https://commons.wikimedia.org/wiki/File:Color_icon_orange_v2.svg // Devel // https://gist.github.com/2370972 (function () { // WIP // - [x] works well onload/DOMContentLoaded // - [ ] pjax:success/end handling // - can not use executeBrowserContext() (aka contentEval et al.) // - due to CSP, too much strict // - so can not touch page-context jQuery var appendButton = function code() { var links; if (!/^https:\/\/gist\.github\.com\/[\w-]+\/\w+/.test(location.href) || !(links = document.body.querySelectorAll('.files .raw-url:not(.head-url)'))) { return; } Array.prototype.forEach.call(links, function (hashlink) { // <a aria-label="View Raw" href="/noromanba/2370972/raw/431c256a6a929a15867112d93bc82238a2723a47/README.md" data-skip-pjax="" class="minibutton raw-url js-view-raw">Raw</a> var perm = document.createElement('a'); perm.textContent = 'HEAD'; perm.ariaLabel = 'View HEAD'; perm.dataset.skipPjax = ''; perm.classList.add('minibutton', 'head-url'); var pathnames = hashlink.href.split('/'); var filename = pathnames.pop(); var base = pathnames.slice(0, -1).join('/'); perm.title = filename; //perm.textContent = filename; perm.href = base + '/' + filename; hashlink.parentNode.appendChild(perm); }); }; appendButton(); // FIXME faild due to CSP, work w/ executeBrowserContext() /*/ // TODO independent of jQuery; replace to MutationObserver // c.f. https://github.com/defunkt/jquery-pjax#events jQuery('#js-pjax-container').on('pjax:end', function () { appendButton(); }); //*/ // FIXME 100% cpu usage /*/ // c.f. MutationObserver // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver // http://caniuse.com/#feat=mutationobserver new MutationObserver(function (records) { //records.forEach(function (record) { appendButton(); //}); }).observe(document.body, { childList: true, subtree: true }); //*/ //////////////////////////////////////////////////////////////////////////// // DBG pjax handling // - https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // - https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js /*/ window.addEventListener('load', function (evt) { console.info(evt.type, evt); @@ -213,4 +189,4 @@ console.log(evt.type, evt); }); //*/ })(); // /anonwrap This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +0,0 @@ -
noromanba renamed this gist
Dec 24, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
noromanba renamed this gist
Dec 24, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
noromanba revised this gist
Dec 24, 2012 . 1 changed file with 216 additions and 147 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,147 +1,216 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.24.0 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js // @updateURL https://userscripts.org/scripts/source/130781.meta.js // @license MIT License http://nrm.mit-license.org/2012 // @copyright (c) 2012 noromanba https://www.hatena.ne.jp/noromanba/ // @author noromanba // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/32px-Color_icon_orange_v2.svg.png // @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/64px-Color_icon_orange_v2.svg.png // ==/UserScript== // Icon (Public Domain by Mizunoryu, Badseed, Jacobolus) // https://commons.wikimedia.org/wiki/File:Color_icon_orange_v2.svg // Devel // https://gist.github.com/2370972 (function () { var executeBrowserContext = (function () { var parent = document.head || document.documentElement || document.body; var container = document.createElement('script'); container.type = 'text/javascript'; container.charset = 'utf-8'; parent.appendChild(container); return function (funcOrString) { container.appendChild(document.createTextNode('(' + funcOrString.toString() + ')();\n')); }; })(); var appendButton = function code() { if (!(/^https:\/\/gist\.github\.com\/[\w-]+/.test(location.href)) || document.querySelector('.gist-perm-button')) { return; } // TODO refactor to Gist{} var gistfile = function (rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/([\w-]+)\/[\w-]+\/(.*)/), baseurl = 'https://raw.github.com/gist/', id = meta[1], basename = meta[2]; return { raw: raw, id: id, name: basename, data: { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, permalink: baseurl + id + '/' }; }; var gist = []; // more smart, into a gist{} Array.prototype.forEach.call(document.querySelectorAll('.actions .raw-url'), function (raw) { var namedHead = raw.cloneNode(true); var file = gistfile(raw); gist.push(file); // TODO remove redundant attr namedHead.href = file.permalink + file.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = file.name; namedHead.className += ' ' + 'gist-perm-button'; // Firefox must be needs 2nd args c.f. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // https://raw.github.com/gist/ID/ => return 1st non-binary file. Gist API v3 protocol gist.some(function (file) { // TODO xhr to Gist API and get filetype, parse json or see response header if (/(?:png|bmp|jpe?g|gif)$/i.test(file.data.type)) return; var head = file.raw.cloneNode(true); head.href = file.permalink; head.textContent = 'HEAD'; head.title = file.id + '.txt'; file.raw.parentNode.insertBefore(head, file.raw.nextSibling); return true; }); // TODO independent of jQuery; replace to addEventListener/MutationObserver // c.f. https://github.com/defunkt/jquery-pjax#events jQuery('#js-pjax-container').on('load', function (evt) { code(); }); jQuery('#js-pjax-container').on('pjax:end', function (evt) { code(); }); }; // /appendButton executeBrowserContext(appendButton); // DBG pjax handling // <at>require https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // <at>require https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js /*/ window.addEventListener('load', function (evt) { console.info(evt.type, evt); }, false); window.addEventListener('popstate', function (evt) { console.info(evt.type, evt); }, false); // c.f. https://github.com/defunkt/jquery-pjax#events window.addEventListener('pjax:start', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:end', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:beforeSend', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:send', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:complete', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:success', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:error', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:timeout', function (evt) { console.log(evt.type, evt); }, false); window.addEventListener('pjax:send', function (evt) { console.log(evt.type, evt); }, false); // $.pjax.submit only use of Gist c.f. https://github.com/defunkt/jquery-pjax#pjaxsubmit window.addEventListener('submit', function (evt) { console.log(evt.type, evt); }, false); ////////// jQuery .on ////////// // c.f. https://github.com/defunkt/jquery-pjax#events $(document).on('pjax:start', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:end', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:beforeSend', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:send', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:complete', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:success', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:error', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:timeout', function (evt) { console.log(evt.type, evt); }); $(document).on('pjax:send', function (evt) { console.log(evt.type, evt); }); $(document).on('submit', function (evt) { console.log(evt.type, evt); }); // #js-pjax-container $('#js-pjax-container').on('submit', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:start', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:end', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:beforeSend', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:send', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:complete', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:success', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:error', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:timeout', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('pjax:send', function (evt) { console.log(evt.type, evt); }); $('#js-pjax-container').on('submit', function (evt) { console.log(evt.type, evt); }); //*/ })(); // /anonwrap -
noromanba revised this gist
Dec 23, 2012 . 1 changed file with 146 additions and 85 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,86 +1,147 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.23.3 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js // @updateURL https://userscripts.org/scripts/source/130781.meta.js // @license MIT License http://nrm.mit-license.org/2012 // @copyright (c) 2012 noromanba https://www.hatena.ne.jp/noromanba/ // @author noromanba // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/32px-Color_icon_orange_v2.svg.png // @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/64px-Color_icon_orange_v2.svg.png // ==/UserScript== // <at>require https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // <at>require https://raw.github.com/defunkt/jquery-pjax/master/jquery.pjax.js // Icon (Public Domain by Mizunoryu, Badseed, Jacobolus) // https://commons.wikimedia.org/wiki/File:Color_icon_orange_v2.svg // Devel // https://gist.github.com/2370972 // TODO smart pjax handling (function() { var appendButton = function () { if (!(/^https:\/\/gist\.github\.com\/[\w-]+/.test(location.href))) return; // TODO refactor to Gist{} var gistfile = function (rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/([\w-]+)\/[\w-]+\/(.*)/), baseurl = 'https://raw.github.com/gist/', id = meta[1], basename = meta[2]; return { raw: raw, id: id, name: basename, data: { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, permalink: baseurl + id + '/' }; }; var gist = []; // more smart, into a gist{} Array.prototype.forEach.call(document.querySelectorAll('.actions .raw-url'), function (raw) { var namedHead = raw.cloneNode(true); var file = gistfile(raw); gist.push(file); // TODO remove redundant attr namedHead.href = file.permalink + file.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = file.name; // Firefox must be needs 2nd args c.f. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // https://raw.github.com/gist/ID/ => return 1st non-binary file. Gist API v3 protocol gist.some(function (file) { // TODO xhr to Gist API and get filetype, parse json or response header if (/(?:png|bmp|jpe?g|gif)$/i.test(file.data.type)) return; var head = file.raw.cloneNode(true); head.href = file.permalink; head.textContent = 'HEAD'; head.title = file.id + '.txt'; file.raw.parentNode.insertBefore(head, file.raw.nextSibling); return true; }); }; appendButton(); ////////// pjax handling ////////// /*/ window.addEventListener('load', function (evt) { console.info(evt.type, evt); appendButton(); }, false); // c.f. https://github.com/defunkt/jquery-pjax#events window.addEventListener('pjax:end', function (evt) { console.info(evt.type, evt); appendButton(); }, false); window.addEventListener('pjax:success', function (evt) { console.info(evt.type, evt); appendButton(); }, false); window.addEventListener('popstate', function(evt) { console.info(evt.type, evt); appendButton(); },false ); ////////// jQuery .on ////////// // c.f. https://github.com/defunkt/jquery-pjax#events $(document).on('pjax:start', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:end', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:beforeSend', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:send', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:complete', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:success', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:error', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:timeout', function(evt) { console.log(evt.type, evt); }); $(document).on('pjax:send', function(evt) { console.log(evt.type, evt); }); // $.pjax.submit only use of Gist c.f. https://github.com/defunkt/jquery-pjax#pjaxsubmit $(document).on('submit', function(evt) { console.log(evt.type, evt); }); //*/ /*/ // or .site-content Array.prototype.forEach.call(document.querySelectorAll('a[class="js-current-repository"], .gist-item .creator a'), function (trigger) { trigger.addEventListener('click', function () { appendButton(); }, false); }); //*/ })(); -
noromanba revised this gist
Dec 23, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.23.3 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -53,9 +53,9 @@ gist.push(file); // TODO remove redundant attr namedHead.href = file.permalink + file.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = file.name; // Firefox must be needs 2nd args c.f. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); -
noromanba revised this gist
Dec 23, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.23.2 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -24,7 +24,7 @@ // TODO smart pjax handling (function() { var appendButton = function () { if (!(/^https:\/\/gist\.github\.com\/[\w-]+/.test(location.href))) return; // TODO refactor to Gist{} var gistfile = function (rawNode) { -
noromanba revised this gist
Dec 23, 2012 . 1 changed file with 57 additions and 43 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.23.1 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -21,52 +21,66 @@ // Devel // https://gist.github.com/2370972 // TODO smart pjax handling (function() { var appendButton = function () { if (!(/https:\/\/gist\.github\.com\/[\w-]+/.test(location.href))) return; // TODO refactor to Gist{} var gistfile = function (rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/([\w-]+)\/[\w-]+\/(.*)/), baseurl = 'https://raw.github.com/gist/', id = meta[1], basename = meta[2]; return { raw: raw, id: id, name: basename, data: { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, permalink: baseurl + id + '/' }; }; var gist = []; // more smart, into a gist{} Array.prototype.forEach.call(document.querySelectorAll('.actions .raw-url'), function (raw) { var namedHead = raw.cloneNode(true); var file = gistfile(raw); gist.push(file); // TODO remove redundant attr namedHead.href = gist.permalink + gist.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = gist.name; // Firefox must be needs 2nd args c.f. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // https://raw.github.com/gist/ID/ => return 1st non-binary file. Gist API v3 protocol gist.some(function (file) { // TODO xhr to Gist API and get filetype, parse json or response header if (/(?:png|bmp|jpe?g|gif)$/i.test(file.data.type)) return; var head = file.raw.cloneNode(true); head.href = file.permalink; head.textContent = 'HEAD'; head.title = file.id + '.txt'; file.raw.parentNode.insertBefore(head, file.raw.nextSibling); return true; }); }; appendButton(); // or .site-content /*/ Array.prototype.forEach.call(document.querySelectorAll('a[class="js-current-repository"], .gist-item .creator a'), function (trigger) { trigger.addEventListener('click', function () { appendButton(); }, false); }); //*/ })(); -
noromanba renamed this gist
Dec 23, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
noromanba revised this gist
Dec 22, 2012 . 1 changed file with 23 additions and 20 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,33 +3,37 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.12.23.0 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js // @updateURL https://userscripts.org/scripts/source/130781.meta.js // @license MIT License http://nrm.mit-license.org/2012 // @copyright (c) 2012 noromanba https://www.hatena.ne.jp/noromanba/ // @author noromanba // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/32px-Color_icon_orange_v2.svg.png // @icon64 https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Color_icon_orange_v2.svg/64px-Color_icon_orange_v2.svg.png // ==/UserScript== // Icon (Public Domain by Mizunoryu, Badseed, Jacobolus) // https://commons.wikimedia.org/wiki/File:Color_icon_orange_v2.svg // Devel // https://gist.github.com/2370972 // TODO // - refactor and XHR in old rev // - remove redundant attr // - handle pjax (function() { // FIXME refactor var gist = function(rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/(\w+)\/\w+\/(.*)/), baseurl = 'https://raw.github.com/gist/', id = meta[1], basename = meta[2]; return { raw: raw, id: id, @@ -41,29 +45,28 @@ permalink: baseurl + id + '/' }; }; var files = []; // more smart, into gist{} Array.prototype.forEach.call(document.querySelectorAll('.actions .raw-url'), function(raw) { var namedHead = raw.cloneNode(true); var g = gist(raw); files.push(g); namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = g.name; // Fx must be needs 2nd args https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // FIXME refactor // 1st file only (Gist API constraints) (function(g) { if (!g) return; var head = g.raw.cloneNode(true); head.href = g.permalink; head.textContent = 'HEAD'; head.title = g.id + '.txt'; g.raw.parentNode.insertBefore(head, g.raw.nextSibling); })(files[0]); })(); -
noromanba revised this gist
Jul 23, 2012 . 3 changed files with 26 additions and 29 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ When you install user.js _**strongly recommends**_ on [**userscripts.org**](http ## About Visit Gist and see 'raw' link, It's including **SHA-1 long hash name** like this. `https://gist.github.com/raw/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js`  @@ -21,42 +21,37 @@ _**Almost Permalink**_: This is almost permanent link. It's _strict filetype_ by <pre>https://raw.github.com/gist/2370972/gist-raw-perm-HEAD.user.js</pre> This link most useful for install user.js from Gist. ## Known Problems ### Multifiles Gist _**HEAD**_ can accessible 1st file only. That is Gist API constraints. ### Binary 1st file e.g. [https://gist.github.com/890279/](https://gist.github.com/890279/) Access to raw: https://raw.github.com/gist/890279/. Expected https://raw.github.com/gist/890279/simple320_320.png, but actual API return [2nd text file data]("https://raw.github.com/gist/890279/gistfile1.txt"). ### Gist API Multifiles Gist has problem. Gist API is not provide true permalink(called _**HEAD**_) for 2nd or more files. #### [Gist API v3](http://developer.github.com/v3/gists/) Include content and history. it's too long too much than v1(closed). + [https://api.github.com/gists/2370972](https://api.github.com/gists/2370972) ## See also ### Gist HTTP e.g. [https://gist.github.com/2370972](https://gist.github.com/2370972) + GET 'raw' => HTTP 302 `https://gist.github.com/raw/2370972/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js` + => HTTP 200 OK `https://raw.github.com/gist/2370972/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js` ### Bookmarklet Base code is small Bookmarklet, you can see [based rev.](http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ/rev/gYC-ydWE_JP9Jg "http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ/rev/gYC-ydWE_JP9Jg"). Latest rev. permalink is [gist raw perm HEAD - Hatena::Let](http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,29 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist for UserScript // @include https://gist.github.com/* // @version 2012.7.24.539 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js // @updateURL https://userscripts.org/scripts/source/130781.meta.js // @license MIT License http://nrm.mit-license.org/2012 // @copyright (c) 2012 noromanba (https://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== // Devel // https://gist.github.com/2370972 // TODO refactor and XHR in old rev. (function() { var raws = document.querySelectorAll('.actions > a'); if (!raws) return; // FIXME refactor var gist = function(rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/(\d+)\/\w+\/(.*)/), @@ -53,6 +55,7 @@ raw.parentNode.insertBefore(namedHead, null); }); // FIXME refactor // 1st file only (Gist API constraints) (function(g) { if (g) { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ <h3>About</h3> <strong>Add permanently HEAD link on Gist</strong> <p>This user.js add 'HEAD' link. It's takes <strong>shrinked permanent raw link</strong> like this:</p> <pre> https://raw.github.com/gist/2370972/gist-raw-perm-HEAD.user.js </pre> @@ -13,7 +12,7 @@ <h3>About</h3> <h3>Detail</h3> <p>Show technical details on <a href="https://gist.github.com/2370972" target="_blank">Gist: 2370972</a>.</p> <h3>:-)</h3> <p>Enjoy Gist and Coding!</p> Regards,<br /> -
noromanba revised this gist
May 2, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist. Use for install user.js, (at)require xxx.js etc. // @include https://gist.github.com/* // @version 2012.5.1.0.31 // @homepage https://userscripts.org/scripts/show/130781 @@ -53,7 +53,7 @@ raw.parentNode.insertBefore(namedHead, null); }); // 1st file only (Gist API constraints) (function(g) { if (g) { var head = g.raw.cloneNode(true); -
noromanba revised this gist
May 2, 2012 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # gist raw perm HEAD [userscripts.org #130781](https://userscripts.org/scripts/show/130781 "https://userscripts.org/scripts/show/130781") ## Install When you install user.js _**strongly recommends**_ on [**userscripts.org**](https://userscripts.org/scripts/show/130781 "https://userscripts.org/scripts/show/130781"). **NOT HERE**. ## About Visit Gist and see 'raw' link, It's including **SHA-1 long hash name** like this. @@ -24,9 +24,12 @@ This link most useful for install user.js from Gist. ## Known Ploblems ### Multifiles Gist _**HEAD**_ can accessible 1st file only. That is Gist API constraints. ### Binary 1st file cf. [https://gist.github.com/890279/](https://gist.github.com/890279/) See raw data in https://raw.github.com/gist/890279/. Expected https://raw.github.com/gist/890279/simple320_320.png but actual API return 2nd file data. It's same as https://raw.github.com/gist/890279/gistfile1.txt. ### Gist API Multifiles Gist has ploblem. Gist API not provide true permlink(bee called _**HEAD**_) for 2nd or more files. -
noromanba revised this gist
Apr 30, 2012 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,10 @@ # gist raw perm HEAD [userscripts.org #130781](https://userscripts.org/scripts/show/130781 "https://userscripts.org/scripts/show/130781") ## Install When you install user.js _**strongly recommended**_ on [**userscripts.org**](https://userscripts.org/scripts/show/130781 "https://userscripts.org/scripts/show/130781"). **Not here**. ## About Visit Gist and see 'raw' link, It's including **SHA-1 long hash name** like this. <pre>https://gist.github.com/raw/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js</pre> @@ -44,7 +44,7 @@ Include content and history. It's too long too much. ## Jot ### Gist raw HTTP This behavior on [HERE](https://gist.github.com/2370972). + GET 'raw' return HTTP 302 @@ -55,4 +55,5 @@ cf. https://gist.github.com/2370972 <pre>https://raw.github.com/gist/2370972/2370972/47150711fedb7375d19d761ab122485b8105678d/gist-raw-perm-HEAD.user.js</pre> ### Based on Base code is small Bookmarklet, you can see based rev. [HERE](http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ/rev/gYC-ydWE_JP9Jg "http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ/rev/gYC-ydWE_JP9Jg") on [Hatena::Let](http://let.hatelabo.jp/). Lateset rev. Permalink is [gist raw perm HEAD - Hatena::Let](http://let.hatelabo.jp/noromanba/let/gYC-ydWE_JP1JQ). -
noromanba revised this gist
Apr 30, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.5.1.0.31 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js -
noromanba revised this gist
Apr 30, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,11 +40,11 @@ }; }; var files = []; // more smart, into gist{} Array.prototype.forEach.call(raws, function(raw) { var namedHead = raw.cloneNode(true); var g = gist(raw); files.push(g); namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; @@ -62,5 +62,5 @@ head.title = g.id + '.txt'; g.raw.parentNode.insertBefore(head, g.raw.nextSibling); } })(files[0]); })(); -
noromanba revised this gist
Apr 30, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD links on Gist. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.30.2.58 // @homepage https://userscripts.org/scripts/show/130781 -
noromanba revised this gist
Apr 29, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.30.2.58 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -19,7 +19,7 @@ // https://gist.github.com/2370972 (function() { var raws = document.querySelectorAll('.actions > a'); if (!raws) return; var gist = function(rawNode) { @@ -49,11 +49,11 @@ namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = g.name; // Fx must be needs 2nd args https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // 1st file only (Gist API constrains) (function(g) { if (g) { var head = g.raw.cloneNode(true); -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.23.5.56 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ // ==UserScript== // @name gist raw perm HEAD // @namespace https://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.23.5.41 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js // @updateURL https://userscripts.org/scripts/source/130781.meta.js // @license MIT License; http://nrm.mit-license.org/2012 // @copyright (c) 2012+, noromanba (https://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 @@ -23,11 +23,11 @@ if (!raws) return; var gist = function(rawNode) { var raw = rawNode, meta = raw.pathname.match(/\/raw\/(\d+)\/\w+\/(.*)/), baseurl = 'https://raw.github.com/gist/', id = meta[1], basename = meta[2]; return { raw: raw, id: id, @@ -40,7 +40,7 @@ }; }; var gists = []; // more smart, into gist{} Array.prototype.forEach.call(raws, function(raw) { var namedHead = raw.cloneNode(true); var g = gist(raw); -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace http://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.23.5.35 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -40,8 +40,8 @@ }; }; var gists = []; // into gist{}.. Array.prototype.forEach.call(raws, function(raw) { var namedHead = raw.cloneNode(true); var g = gist(raw); gists.push(g); @@ -53,7 +53,7 @@ raw.parentNode.insertBefore(namedHead, null); }); // 1st file only (Gist API constrain) (function(g) { if (g) { var head = g.raw.cloneNode(true); -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 23 additions and 19 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace http://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.23.4.33 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -22,41 +22,45 @@ var raws = document.querySelectorAll('#gist-embed + a'); if (!raws) return; var gist = function(rawNode) { var raw = rawNode; var meta = raw.pathname.match(/\/raw\/(\d+)\/\w+\/(.*)/); var baseurl = 'https://raw.github.com/gist/'; var id = meta[1]; var basename = meta[2]; return { raw: raw, id: id, name: basename, file: { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, permalink: baseurl + id + '/' }; }; var gists = []; Array.forEach(raws, function(raw) { var namedHead = raw.cloneNode(true); var g = gist(raw); gists.push(g); namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = g.name; // Fx must be needs 2nd args. cf. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(namedHead, null); }); // nonamed HEAD is 1st file only (Gist API constrain) (function(g) { if (g) { var head = g.raw.cloneNode(true); head.href = g.permalink; head.textContent = 'HEAD'; head.title = g.id + '.txt'; g.raw.parentNode.insertBefore(head, g.raw.nextSibling); } })(gists[0]); })(); -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,8 +29,10 @@ var basename = meta[2]; return { id: id, // include directory -> 'foo/bar.txt' cf. https://gist.github.com/662233 name: basename, // without directory -> 'bar.txt' file: { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, @@ -48,13 +50,13 @@ var head = raw.cloneNode(true); head.href = g.permalink; head.textContent = 'HEAD'; head.title = g.id + '.txt'; // Fx must be needs 2nd args. cf. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(head, null); } namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = g.name; raw.parentNode.insertBefore(namedHead, null); } })(); -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 10 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,27 +22,19 @@ var raws = document.querySelectorAll('#gist-embed + a'); if (!raws) return; var gist = function(refNode) { var meta = refNode.pathname.match(/\/raw\/(\d+)\/\w+\/(.*)/); var baseurl = 'https://raw.github.com/gist/'; var id = meta[1]; var basename = meta[2]; return { id: id, name: basename, // include directory -> 'foo/bar.txt' cf. https://gist.github.com/662233 file: { // without directory -> 'bar.txt' name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }, permalink: baseurl + id + '/' }; }; @@ -54,15 +46,15 @@ if (i === 0) { var head = raw.cloneNode(true); head.href = g.permalink; head.textContent = 'HEAD'; head.title = 'HEAD(' + g.id + '.txt)'; // Fx must be needs 2nd args. cf. https://developer.mozilla.org/en/DOM/element.insertBefore raw.parentNode.insertBefore(head, null); } namedHead.href = g.permalink + g.name; namedHead.textContent = 'HEAD(named)'; namedHead.title = 'HEAD(' + g.name + ')'; raw.parentNode.insertBefore(namedHead, null); } })(); -
noromanba renamed this gist
Apr 22, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ <h3>About</h3> <strong>Add permanently HEAD link on Gist</strong> <p>This user.js add 'HEAD' link. It's takes <strong>shrinked permanent raw link</strong>. Like This</p> <pre> https://raw.github.com/gist/2370972/gist-raw-perm-HEAD.user.js </pre> <p><div> <img src="http://cdn-ak.f.st-hatena.com/images/fotolife/n/noromanba/20120413/20120413072715.png" alt="gist-raw-perm-HEAD" width="600px" /> </div></p> <h3>Detail</h3> <p>Show technical details on <a href="https://gist.github.com/2370972" target="_blank">Gist: 2370972</a>.</p> <h3>:EOF</h3> <p>Enjoy Gist and Coding!</p> Regards,<br /> noromanba -
noromanba revised this gist
Apr 22, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,10 +31,10 @@ id: function() { return id; }, name: function() { // include directory -> 'foo/bar.txt' cf. https://gist.github.com/662233 return basename; }, file: function() { // without directory -> 'bar.txt' return { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' -
noromanba revised this gist
Apr 20, 2012 . 1 changed file with 27 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ // @namespace http://www.hatena.ne.jp/noromanba/ // @description Add permanently HEAD link on Gist for Greasemonkey. Use for install user.js or load xxx.js with (at)require etc. // @include https://gist.github.com/* // @version 2012.4.20.12.32 // @homepage https://userscripts.org/scripts/show/130781 // @downloadURL https://userscripts.org/scripts/source/130781.user.js // @installURL https://userscripts.org/scripts/source/130781.user.js @@ -21,35 +21,36 @@ (function() { var raws = document.querySelectorAll('#gist-embed + a'); if (!raws) return; var gist = function(rawnode) { // encapsulation var meta = rawnode.pathname.match(/\/raw\/(\d+)\/\w+\/(.*)/); var baseurl = 'https://raw.github.com/gist/'; var id = meta[1]; var basename = meta[2]; return { id: function() { return id; }, name: function() { // directory included -> 'foo/bar.txt' cf. https://gist.github.com/662233 return basename; }, file: function() { // without path -> 'bar.txt' return { name: basename.slice(basename.lastIndexOf('/') + 1), type: basename.split('.').length > 1 ? basename.split('.').pop() : 'N/D' }; }, permalink: function() { return baseurl + id + '/'; } }; }; for (var i = 0; i < raws.length; i++) { var raw = raws[i]; var namedHead = raw.cloneNode(true); var g = gist(raw); if (i === 0) { var head = raw.cloneNode(true); -
noromanba revised this gist
Apr 18, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <h3>About</h3> <strong>Add permanently HEAD link on Gist</strong> <p>This user.js add 'HEAD' link. It's takes <strong>shrinked permanent raw link</strong>. Like This</p> <pre> https://raw.github.com/gist/2370972/gist-raw-perm-HEAD.user.js -
noromanba revised this gist
Apr 18, 2012 . 1 changed file with 1 addition and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,15 +22,9 @@ _**Almost Permalink**_: This is almost permanent link. It's _strict filetype_ by This link most useful for install user.js from Gist. ## Known Ploblems ### Multifiles Gist _**HEAD**_ can accessible 1st file only. That is Gist API constraining. + ex. https://gist.github.com/2370972
NewerOlder