Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bookmarklet to quickly switch between a repo and the gh-pages ( view.
// Instructions. Save as a bookmark. Click when on a repo or (gh-pages branch) site.
location = /io$/.test(h) ?
'' + h.split('.')[0] + p:
'http://'+ p.split('/')[1]+''+ '/' + p.split('/').slice(2).join('/')

This comment has been minimized.

Copy link

@mjhea0 mjhea0 commented Jun 18, 2014

That would be even cooler to check to see if the github pages even exists before navigating there, but there is the Access-Control-Allow-Origin issue. I figured since it was and, they would allow such requests

var xhr = new XMLHttpRequest();
undefined"GET", "", false);
XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access. VM1046:2
NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load ''.

This comment has been minimized.

Copy link
Owner Author

@a-laughlin a-laughlin commented Jun 19, 2014

Interesting thought. You could circumvent the cross-origin issue by assuming that index.html exists on if it exists on the 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

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