Skip to content

Instantly share code, notes, and snippets.

@bancek
Last active February 18, 2026 21:24
Show Gist options
  • Select an option

  • Save bancek/871e45db249fab7b03fd72afc42ee0db to your computer and use it in GitHub Desktop.

Select an option

Save bancek/871e45db249fab7b03fd72afc42ee0db to your computer and use it in GitHub Desktop.
Gitea commits navigation and commit summary userscript (for Tampermonkey)
fetch(document.location.pathname.split("/commits/")[0] + "/commits/list")
.then((res) => res.json())
.then((res) => {
const commits = res.commits;
commits.reverse();
const currentCommitId = document.location.pathname.split("/commits/")[1];
const currentCommitIdx = commits.findIndex((x) => x.id == currentCommitId);
function addCommitButton(commitId, text, label) {
const button = document.createElement("a");
button.className = "ui tiny basic button";
button.href =
document.location.pathname.split("/commits/")[0] +
"/commits/" +
commitId +
document.location.search +
document.location.hash;
button.title = label;
button.ariaLabel = label;
button.innerText = text;
document.querySelector(".diff-detail-actions").appendChild(button);
}
// add prev button
if (currentCommitIdx > 0) {
addCommitButton(
commits[currentCommitIdx - 1].id,
"< Prev",
"Previous commit",
);
}
// add next button
if (currentCommitIdx < commits.length - 1) {
addCommitButton(
commits[currentCommitIdx + 1].id,
"Next >",
"Next commit",
);
}
// add current commit summary
const currentCommit = commits[currentCommitIdx];
const currentCommitSummaryEl = document.createElement("div");
currentCommitSummaryEl.className = "ui info message";
const currentCommitSummaryElChild = document.createElement("div");
currentCommitSummaryElChild.innerText = `Current commit: ${currentCommit.summary}`;
currentCommitSummaryEl.appendChild(currentCommitSummaryElChild);
document.querySelector("#diff-container").before(currentCommitSummaryEl);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment