Skip to content

Instantly share code, notes, and snippets.

@duzun
Last active October 22, 2015 20:32
Show Gist options
  • Save duzun/55e2005d297bd560df4e to your computer and use it in GitHub Desktop.
Save duzun/55e2005d297bd560df4e to your computer and use it in GitHub Desktop.
Go to github.io of a github repo which has gh-pages branch.
<a class="btn btn-default btn-info bookmarklet" href="javascript:(function(d,b,c,a){b=d.location;a=b.pathname.split('/');c=b.hostname;return'github.com'==c&&2<a.length?(a=b.protocol+'//'+a[1]+'.'+c.replace(/\.com$/,'.io')+'/'+a[2],void d.open(a,'_blank')):alert('Go to a github repo and try again!'),!1})(this);">
Go to Github.IO
</a>
/**
* Go to github.io of a github repo which has gh-pages branch.
*
* @license MIT
* @version 1.0.0
* @author Dumitru Uzun (DUzun.Me)
* @homepage https://duzun.me/playground#gotoGithubIO
*/
(function (w, l, h, p) {
l = w.location;
p = l.pathname.split('/');
h = l.hostname;
return h == 'github.com' && p.length > 2
? ( p=l.protocol + '//' + p[1] + '.' + h.replace(/\.com$/, '.io') + '/' + p[2],
void w.open(p, '_blank')
// l.href=p
) : alert('Go to a github repo and try again!'), false
;
}(this));
javascript:(function(d,b,c,a){b=d.location;a=b.pathname.split('/');c=b.hostname;return'github.com'==c&&2<a.length?(a=b.protocol+'//'+a[1]+'.'+c.replace(/\.com$/,'.io')+'/'+a[2],void d.open(a,'_blank')):alert('Go to a github repo and try again!'),!1})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment