functiongetActiveTocElement(e){return[...e].find(e=>e.getBoundingClientRect().y<0)}functionfindCorrespondingTocTitle(t){return[...document.querySelectorAll("#toc li a")].find(e=>e.href.substring(e.href.indexOf("#"))==="#"+t.id)}document.addEventListener("DOMContentLoaded",function(){document.getElementById("navbar").clientHeight,document.getElementById("toc");vare=document.querySelectorAll("#toc li a");document.getElementById("page-content");lett=[];[...e].forEach(e=>{t.push(e.href.substring(e.href.indexOf("#")))});e=document.querySelectorAll(t.join(","));console.log(e);letn=[...e].reverse();e=getActiveTocElement(n);console.log(e),findCorrespondingTocTitle(e).classList.add("bg-blue-800");leto=e;window.addEventListener("scroll",()=>{vare=getActiveTocElement(n);console.log("elem",e),console.log("previous",o),e!==o&&(o.classList.remove("bg-blue-800"),findCorrespondingTocTitle(e).classList.add("bg-blue-800"))})});