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!]).
Why isn't this more popular??