Created
September 10, 2014 23:39
-
-
Save cwparsons/e8559889acaaa9cb7225 to your computer and use it in GitHub Desktop.
Raw Git Bookmarklet
This file contains 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 characters
(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