A simple bookmarklet which makes our painful life a bit easier.
javascript:(function(b,a,c,d,e){if(/\.\w+$/.test(a))b.location=c+a.replace("/blob/","/");else if(e=prompt("Insert a filename:","index.html"))b.location=c+a.replace("/tree/","/")+(~a.indexOf(d)?"/":d)+e})(window,location.pathname,"http://rawgit.com","/master/");
The usage is quite simple:
Go to any repo where you like to preview a file, and execute the booklet. If the current url is a file, it should open the file directly, otherwise it will prompt for a filename (per default it is index.html
).
I've tested it with the following url-usecases:
- https://github.com/user/repo/
- https://github.com/user/repo/tree/master/folder/
- https://github.com/user/repo/blob/master/file.ext
- https://raw.github.com/user/repo/master/file.ext
- https://raw.githubusercontent.com/user/repo/master/file.ext
New: optimized for http://backtick.io/
- Firefox CSP interfere currently with the operation of bookmarklets.
But, yay! There's already a bugreport: https://bugzilla.mozilla.org/show_bug.cgi?id=866522
So, to use this booklet on HTTPS-enabled sites you've to disablesecurity.csp.enable
viaabout:config
(...or look for a better solution [...and note it here!]).