This is a bookmarklet that transforms a link to a file from going to a branch to the specific current HEAD commit. This allows to keep links consistent, even when files change. This is specifically useful when linking to specific lines (which loose their meaning over time when line numbers change).
This is the transformation:
https://github.com/mapbox/mapbox.js/blob/mb-pages/package.json#L25
To install, create a new bookmark and copy the code below in their:
javascript:(function(){
var a = $('.commit-title a');
if (a && a.length > 0) {
s = a[0].href.split('/');
w = window.location.pathname.split('/');
w[4] = s[s.length-1];
window.location.pathname = w.join('/');
} else {
alert('Not a Github file site or bookmarklet is broken');
}
})();