Fix bug with different XPaths across instances

This commit is contained in:
The Magician 2024-03-27 13:49:40 +00:00
parent cdceafb4ee
commit bb65745ef5
1 changed files with 16 additions and 10 deletions

View File

@ -6,15 +6,21 @@
// @include http* // @include http*
// ==/UserScript== // ==/UserScript==
let recommendedSidebarXpath = "/html/body/div/div/div[5]/div[3]"; let sidebarXpaths = ["/html/body/div/div/div[4]/div[3]", "/html/body/div/div/div[5]/div[3]"];
let recommendedSidebar = document.evaluate(
recommendedSidebarXpath, for (const index in sidebarXpaths) {
let xpath = sidebarXpaths[index];
let recommendedSidebar = document.evaluate(
xpath,
document, document,
null, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, XPathResult.FIRST_ORDERED_NODE_TYPE,
null, null,
).singleNodeValue; ).singleNodeValue;
if (recommendedSidebar != null) { if (recommendedSidebar != null) {
recommendedSidebar.setAttribute("hidden", true); recommendedSidebar.setAttribute("hidden", true);
break;
}
} }