Skip to content

Instantly share code, notes, and snippets.

@yulanggong
Last active September 19, 2016 01:59
Show Gist options
  • Save yulanggong/886cba8ac057f012f78c7e8ee41470ce to your computer and use it in GitHub Desktop.
Save yulanggong/886cba8ac057f012f78c7e8ee41470ce to your computer and use it in GitHub Desktop.
πŸ”ƒ Switch between github.io and github.com
//Bookmarklet:
//javascript:!function(){var o=location.host.slice(-9);"github.io"==o?location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/,function(o,t,i){location.href="https://github.com/"+t+"/"+i}):"ithub.com"==o&&location.href.replace(/github\.com\/([^\/]+)\/([^\/]+)/,function(o,t,i){location.href="https://"+t.toLowerCase()+".github.io/"+i})}();
(function(){
var host = location.host.slice(-9);
if(host == 'github.io'){
location.href.replace(/\/\/([^\.]+)\.github\.io\/([^\/]+)/, function(a, name, project){
location.href = 'https://github.com/' + name + '/' + project;
})
} else if (host == 'ithub.com') {
location.href.replace(/github\.com\/([^\/]+)\/([^\/]+)/, function(a, name, project){
location.href = 'https://'+ name.toLowerCase() +'.github.io/' + project;
})
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment