Skip to content

Instantly share code, notes, and snippets.

@a-laughlin
Created June 18, 2014 01:23
Show Gist options
  • Save a-laughlin/1035d616c666271e1fe3 to your computer and use it in GitHub Desktop.
Save a-laughlin/1035d616c666271e1fe3 to your computer and use it in GitHub Desktop.
Bookmarklet to quickly switch between a repo and the gh-pages (github.io) view.
// Instructions. Save as a bookmark. Click when on a repo or github.io (gh-pages branch) site.
javascript:(function(h,p){
location = /io$/.test(h) ?
'https://github.com/' + h.split('.')[0] + p:
'http://'+ p.split('/')[1]+'.github.io'+ '/' + p.split('/').slice(2).join('/')
})(location.host,location.pathname);
@a-laughlin
Copy link
Author

Interesting thought. You could circumvent the cross-origin issue by assuming that index.html exists on github.io if it exists on the github.com domain in a gh-pages branch. Have your xhr check that the gh-pages branch exists, search it for index.html, and render the appropriate path prefixed with ____.github.io.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment