Skip to content

Instantly share code, notes, and snippets.

@zischwartz zischwartz/README.md
Last active Aug 10, 2019

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

commented Mar 5, 2019

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
You can’t perform that action at this time.