Update hotkey

This commit is contained in:
2024-08-17 15:12:01 +02:00
parent 676748f614
commit 0ce14bdc53

View File

@@ -3,14 +3,25 @@ i = 1;
console.log(nodes); console.log(nodes);
titleNode = nodes[nodes.length - i]; titleNode = nodes[nodes.length - i];
while (titleNode && !titleNode.matches("a#video-title-link")) { 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; titleNode = titleNode.parentElement;
console.log(titleNode); console.log(titleNode);
} }
if (!(titleNode && titleNode.matches("a#video-title-link"))) { if (!(titleNode && titleNode.matches(selector))) {
console.error("No video element found."); console.error("No video element found.");
} else { } else {
link = titleNode.href; link = titleNode.href;
if (link.startsWith("/")) {
link = window.location.origin + link;
}
console.log(link);
fetch("http://localhost:5000/download", { fetch("http://localhost:5000/download", {
method: "POST", method: "POST",
headers: { headers: {
@@ -21,6 +32,9 @@ if (!(titleNode && titleNode.matches("a#video-title-link"))) {
}), }),
}).then((res) => { }).then((res) => {
textNode = titleNode.querySelector("yt-formatted-string"); textNode = titleNode.querySelector("yt-formatted-string");
if (invidious) {
textNode = titleNode.querySelector("p");
}
textNode.style.setProperty("color", "green", "important"); textNode.style.setProperty("color", "green", "important");
res.json().then((data) => console.log(data)); res.json().then((data) => console.log(data));
}); });