Kami's Corner

Here's a userscript for footnotes

I'll be honest, having the page scroll to a footnote whenever you click on one is really annoying. It makes it basically impossible to read footnotes while reading a blogpost due to it making it very easy to lose track of where you were. I made a small (and pretty scuffed) userscript that instead opens the footnote as an alert and doesn't scroll the page. I know, making a custom footnote widget thing that pops up would be a lot nicer, but this works well enough, so i don't really care. Maybe at some point.

Anyways, here's the code. Run it with the userscript extension of your choice.1

const footnotes = document.querySelectorAll(".footnote-ref")
footnotes.forEach(note => {
    note.addEventListener("click",footnoteClick, false)
});

function footnoteClick(event) {
    const noteLink = event.target;
    const note = document.querySelector(noteLink.href.substring(noteLink.href.lastIndexOf('/') + 1));
    const noteText = note.innerText;
    alert(noteText);

    event.preventDefault();
}
  1. And here's a footnote so you can test it.

#meta #userscript