Skip to content

Instantly share code, notes, and snippets.

@zischwartz
Last active August 10, 2019 22:41
Show Gist options
  • Save zischwartz/daa9dd15ea0604321ca777c01fa4e3dd to your computer and use it in GitHub Desktop.
Save zischwartz/daa9dd15ea0604321ca777c01fa4e3dd to your computer and use it in GitHub Desktop.
Shortcut to Toggle Between Github Repo and That Repo's Github Pages

Add it as a custom search engine in Chrome by entering chrome://settings/searchEngines in the search bar and clicking "add".

For the url just write javascript: and then paste the contents of toggle_gh.js after the colon, and hit save.

Alternatively, if you'd like a button, you can just paste the javascript: ... as a "new page" in bookmarks.

let user = location.host == "github.com" ? location.pathname.split('/')[1] : location.host.split('.')[0];
let repo = location.host == "github.com" ? location.pathname.split('/')[2] : location.pathname.split('/')[1];
window.location = location.host == "github.com" ? `https://${user}.github.io/${repo}/` : `https://github.com/${user}/${repo}`;
@zischwartz
Copy link
Author

Like this:
screen shot 2019-03-05 at 9 18 27 am

I ended up changing the keyword to simply tog

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