Fetches repo URL from GitHub API; injects button via DOM manipulation.
function getRepoUrl() {
const pathComponents = window.location.pathname.split("/");
const user = pathComponents[1], repo = pathComponents[2];
return `https://useful-forks.github.io/?repo=${user}/${repo}`;
}
function setBtnUrl() {
const button = document.getElementById(UF_BTN_ID);
button.addEventListener("click", () => {
window.open(getRepoUrl(), "_blank");
});
}
function createUsefulBtn() {
const li = document.createElement("li");
const content = `
<div class="float-left">
<button id="${UF_BTN_ID}" class="btn-sm btn" aria-describedby="${UF_TIP_ID}">
<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-search">
<path d="M10.68 11.74a6 6 0 0 1-7.922-8.982 6 6 0 0 1 8.982
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key