42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
nodes = document.querySelectorAll(":hover");
|
|
i = 1;
|
|
console.log(nodes);
|
|
titleNode = nodes[nodes.length - i];
|
|
|
|
selector = "a#video-title-link";
|
|
invidious = false;
|
|
if (window.location.href.includes("invidious.site")) {
|
|
selector = "a";
|
|
invidious = true;
|
|
}
|
|
|
|
while (titleNode && !titleNode.matches(selector)) {
|
|
titleNode = titleNode.parentElement;
|
|
console.log(titleNode);
|
|
}
|
|
if (!(titleNode && titleNode.matches(selector))) {
|
|
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));
|
|
});
|
|
}
|