Skip to content

Instantly share code, notes, and snippets.

@weiland
Created July 8, 2014 20:47
Show Gist options
  • Save weiland/7b04f898ff37259f52a8 to your computer and use it in GitHub Desktop.
Save weiland/7b04f898ff37259f52a8 to your computer and use it in GitHub Desktop.
Switch between a GitHub Repository and their gh-pages.
javascript:(function() { var s,r,c; var l = window.location; if(l.origin.indexOf('github.io') !== -1) { r = /(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/i; s = window.location.origin.match(r)[1]; window.location.href='https://github.com/' + s + l.pathname; } else if(l.origin.indexOf('github.com') !== -1) { s = window.location.pathname.split('/')[1]; c = window.location.pathname.split('/')[2]; window.location.href='http://' + s + '.github.io/' + c; }})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment