1// Because we may redirect a canonical, the URL cannot be used to discover the id 2window.addEventListener("load", function () { 3 let currentId = JSINFO["id"]; 4 let currentIdParts = currentId.split(":").filter(el => el.length !== 0); 5 document.querySelectorAll(".page-explorer-tree-cs").forEach(element => { 6 let baseId = element.dataset.wikiId; 7 let baseParts = baseId.split(":").filter(el => el.length !== 0); 8 let processedIdArray = []; 9 for (const [index, currentPart] of currentIdParts.entries()) { 10 processedIdArray.push(currentPart); 11 if (index < baseParts.length) { 12 if (currentPart === baseParts[index]) { 13 continue; 14 } 15 } 16 let processedId = processedIdArray.join(":") 17 if (index < currentIdParts.length - 1) { 18 let button = element.querySelector(`button[data-wiki-id='${processedId}']`); 19 if (button != null) { 20 button.click(); 21 } 22 } else { 23 let link = element.querySelector(`a[data-wiki-id='${processedId}']`); 24 if (link != null) { 25 link.classList.add("active"); 26 } 27 } 28 } 29 }); 30}); 31