If the current page is a GitHub Pages page, open the corresponding repo. if the current page is a repo, open the GitHub Pages page.
For example, if the current page is https://osteele.github.io/p5.layers, clicking the bookmarklet navigates https://github.com/osteele/p5.layers, and vice versa.
Limitations:
- Does not respect custom domains (CNAME)
- Does not work for organization repos
-
Add a new bookmark. (For example, bookmark this page.)
-
Rename the bookmark. For example,
GHP↔︎GH
. -
Edit the bookmark address. Replace it with this:
javascript:window.location.href%3Dwindow.location.href.replace%28/https%3F%3A%5C/%5C/%28%5B%5E%5C/%5D%2B%29%5C.github%5C.io%5C/%28%5B%5E%5C/%5D%2A%29.%2A/%2C%27%3Agithub.com/%241/%242%27%29.replace%28/%5Ehttps%3A%5C/%5C/github%5C.com%5C/%28.%2B%3F%29%5C/%28%5B%5E%5C/%5D%2B%29.%2A/%2C%27%3A%241.github.io/%242%27%29.replace%28/%5E%3A/%2C%27https%3A%5C/%5C/%27%29