Skip to content

Instantly share code, notes, and snippets.

@taylorzane
Created July 19, 2015 20:46
Show Gist options
  • Save taylorzane/ad2b2dd93618d92e067a to your computer and use it in GitHub Desktop.
Save taylorzane/ad2b2dd93618d92e067a to your computer and use it in GitHub Desktop.
Toggle Github Repo and Github Pages
function() {
var loc = document.location;
if (loc.host.split('.').slice(-2).join('.') === 'github.io') {
loc.href = 'http://github.com/' + loc.host.split('.')[0] + '/' + loc.pathname.split('/').filter(function(e){return e !== '';})[0];
} else if (loc.host.split('.').slice(-2).join('.') === 'github.com') {
loc.href = 'http://' + loc.pathname.split('/').filter(function(e){return e !== '';})[0] + '.github.io/' + loc.pathname.split('/').filter(function(e){return e !== '';})[1];
} else {
console.log('whatever.');
}
}
// Bookmartlet Version. Needs minification.
javascript:(function() {var loc = document.location; if (loc.host.split('.').slice(-2).join('.') === 'github.io') {loc.href = 'http://github.com/' + loc.host.split('.')[0] + '/' + loc.pathname.split('/').filter(function(e){return e !== '';})[0]; } else if (loc.host.split('.').slice(-2).join('.') === 'github.com') {loc.href = 'http://' + loc.pathname.split('/').filter(function(e){return e !== '';})[0] + '.github.io/' + loc.pathname.split('/').filter(function(e){return e !== '';})[1]; } else {console.log('whatever.'); } })();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment