>>108593815
The elites don’t want you to know this, but you can just paste bookmarklets into your URL field in your browser. You don’t have to minimize them and turn spaces into %20. `javascript:` is also something you can just leave in a file — it’s a label, like for goto or whatever. I have 14 bookmarklets.
function getGitHubRepoRef(rawUrl) {
try {
const u = new URL(rawUrl);
if (u.hostname !== "github.com") return null;
for (const key of ["issue", "pull_request", "pullRequest"]) {
const value = u.searchParams.get(key);
if (!value) continue;
const [org, repo, num] = decodeURIComponent(value).split("|");
if (org && repo && /^\d+$/.test(num)) {
return { org, repo, num, full: `${org}/${repo}#${num}` };
}
}
const parts = u.pathname.split("/").filter(Boolean);
const reserved = new Set([
"orgs",
"users",
"settings",
"notifications",
"marketplace",
"sponsors",
"explore",
"login",
"signup",
]);
if (
parts.length >= 4 &&
!reserved.has(parts[0]) &&
["issues", "pull"].includes(parts[2]) &&
/^\d+$/.test(parts[3])
) {
const [org, repo, , num] = parts;
return { org, repo, num, full: `${org}/${repo}#${num}` };
}
} catch {}
return null;
}