an evil little hack i enjoy
<a class="item" href="https://git.xn--scling-oua.cat.family/">[Gitweb]</a>
<script type="module">
const gitwebLink = document.querySelector(
'a[href="https://git.xn--scling-oua.cat.family/"]',
);
const editNavbar = function editNavbar() {
const navbarLeft = document.querySelector("#navbar .navbar-left");
const spacer = document.querySelector("#navbar .navbar-left div");
for (const e of [gitwebLink, spacer]) {
e.remove();
navbarLeft.prepend(e);
}
};
const editGitwebLink = function editGitwebLink() {
const pathParts = location.pathname.split("/");
if (pathParts[1] !== 'aescling' || pathParts[2] in [undefined, ""]) {
return;
}
const repo = pathparts[2];
const uri = gitwebLink.getAttribute("href");
gitwebLink.setAttribute("href", `${uri}${repo}.git`);
};
const main = function main() {
editNavbar();
editGitwebLink();
};
main();
</script>
re: an evil little hack i enjoy
@vaporeon_ this is code from my forgejo instance. it does two things:
i would purrefur to just render it all server side but i’m not gonna hack on forgejo itself just fur small UI changes
re: an evil little hack i enjoy
@vaporeon_ also the results of disabling JS doesn’t ruin anything, you just don’t get the dynamically generated gitweb URI and the link gets put in an awkward place on the navbar
re: an evil little hack i enjoy
@vaporeon_ yeh
re: an evil little hack i enjoy
@aescling I'm stupid, what does this do?