This bookmarklet automatically converts the current GitHub Repo URL to the GitHub.io Page.
- Create a new Bookmark and name it "Repo to GH Page" or something.
- Paste this as the URL:
javascript:(()=>{const{href:a}=window.location;if(a.startsWith("https://github.com/")){const b=(a.split("/").pop()||"").split("#")[0];if(b){const c=(a.split("/")[3]||"").split(".")[0];c&&(window.location.href=`https://${c}.github.io/${b}`)}}})();
- Move it to your bookmarks bar (optional)
Source Code:
(() => {
"use strict";
const { href } = window.location;
if (!href.startsWith("https://github.com/")) return;
const repo = (href.split("/").pop() || "").split("#")[0];
if (!repo) return;
const username = (href.split("/")[3] || "").split(".")[0];
if (!username) return;
window.location.href = `https://${username}.github.io/${repo}`;
})();
This bookmarklet is the reverse version of the one above. It automatically converts the current GitHub.io Page to the Repository URL.
- Create a new Bookmark and name it "GH Page to Repo" or something.
- Paste this as the URL:
javascript:(()=>{const{href:a}=window.location;if(!a.includes("github.io"))return;const b=a.split("//")[1].split(".")[0];if(!b)return;let c=a.replace(`https://${b}.github.io/`,"");"/"===c.at(-1)&&(c=c.split("/")[0]);c&&(window.location.href=`https://github.com/${b}/${c}`)})();
- Move it to your bookmarks bar (optional)
Source Code:
(() => {
"use strict";
const { href } = window.location;
if (!href.includes("github.io")) return;
const username = href.split("//")[1].split(".")[0];
if (!username) return;
let repo = href.replace(`https://${username}.github.io/`, "");
if (repo.at(-1) === "/") repo = repo.split("/")[0];
if (!repo) return;
window.location.href = `https://github.com/${username}/${repo}`;
})();
(click GIF to enlarge)