Skip to content

Instantly share code, notes, and snippets.

@cwparsons
Created September 10, 2014 23:39
Show Gist options
  • Save cwparsons/e8559889acaaa9cb7225 to your computer and use it in GitHub Desktop.
Save cwparsons/e8559889acaaa9cb7225 to your computer and use it in GitHub Desktop.
Raw Git Bookmarklet
(function() {
var files = document.querySelectorAll('.file');
for (var i = 0; i < files.length; i++) {
var url = files[i].querySelector('.raw-url');
var href = url.href;
href = href.replace('https://gist.github.com/', '//rawgit.com/');
var path = url.pathname.split('/');
var filename = path[path.length - 1];
var link = document.createElement('a');
link.className = 'minibutton';
link.href = 'javascript:(function(d) { var body = d.getElementsByTagName(\'body\')[0], script = d.createElement(\'script\'); script.src = \'' + href + '\'; body.appendChild(script);}(window.document));';
link.innerText = filename;
url.parentElement.appendChild(link);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment