nodes = document.querySelectorAll(":hover"); i = 1; console.log(nodes); selectors = ["a#video-title-link", "a#video-title"]; invidious = false; if (window.location.href.includes("invidious.site")) { selector = "a"; invidious = true; } titleNode = nodes[nodes.length - i]; outer: while (titleNode) { for (let selector of selectors) { if (titleNode.matches(selector)) { break outer; } } titleNode = titleNode.parentElement; console.log(titleNode); } if (!titleNode) { console.error("No video element found."); } else { link = titleNode.href; if (link.startsWith("/")) { link = window.location.origin + link; } console.log(link); fetch("https://nsq.site.quack-lab.dev/pub?topic=ytdqueue", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ link: link, }), }).then((res) => { textNode = titleNode.querySelector("yt-formatted-string"); if (invidious) { textNode = titleNode.querySelector("p"); } textNode.style.setProperty("color", "green", "important"); res.json().then((data) => console.log(data)); }); }