Skip to content

Instantly share code, notes, and snippets.

@apexskier
Last active March 9, 2018 19:21
Show Gist options
  • Save apexskier/4bc7e9ccc5da6d2850b433c3c4b996f6 to your computer and use it in GitHub Desktop.
Save apexskier/4bc7e9ccc5da6d2850b433c3c4b996f6 to your computer and use it in GitHub Desktop.
github view at last commit

This is a simple bookmarklet that redirects the current file you're viewing on github to it's last commit. This is nice for generating permanent links, rather than linking to master which may change.

javascript:"use strict";var _slicedToArray=function(){return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,r){var e=[],n=!0,o=!1,a=void 0;try{for(var i,c=t[Symbol.iterator]();!(n=(i=c.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,a=t}finally{try{!n&&c.return&&c.return()}finally{if(o)throw a}}return e}(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();!function(){var t=document.querySelector(".commit-tease-sha").textContent.trim(),r=document.location.pathname.match(/^(\/[\w-_]+\/[\w-_]+\/blob\/)(\w+)(\/.*)/),e=_slicedToArray(r,4),n=(e[0],e[1]),o=(e[2],e[3]);document.location.pathname=""+n+t+o}();
(function lastCommit() {
const sha = document.querySelector('.commit-tease-sha').textContent.trim();
const [_, pre, oldRef, post] = document.location.pathname.match(/^(\/[\w-_]+\/[\w-_]+\/blob\/)(\w+)(\/.*)/);
document.location.pathname = `${pre}${sha}${post}`;
})()
"use strict";var _slicedToArray=function(){return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,r){var e=[],n=!0,o=!1,a=void 0;try{for(var i,c=t[Symbol.iterator]();!(n=(i=c.next()).done)&&(e.push(i.value),!r||e.length!==r);n=!0);}catch(t){o=!0,a=t}finally{try{!n&&c.return&&c.return()}finally{if(o)throw a}}return e}(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();!function(){var t=document.querySelector(".commit-tease-sha").textContent.trim(),r=document.location.pathname.match(/^(\/[\w-_]+\/[\w-_]+\/blob\/)(\w+)(\/.*)/),e=_slicedToArray(r,4),n=(e[0],e[1]),o=(e[2],e[3]);document.location.pathname=""+n+t+o}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment