Files
youtube-downloader/hotkey.js
PhatPhuckDave 676748f614 Make text green when download started
Finally, feedback
2024-07-22 15:45:53 +02:00

28 lines
766 B
JavaScript

nodes = document.querySelectorAll(":hover");
i = 1;
console.log(nodes);
titleNode = nodes[nodes.length - i];
while (titleNode && !titleNode.matches("a#video-title-link")) {
titleNode = titleNode.parentElement;
console.log(titleNode);
}
if (!(titleNode && titleNode.matches("a#video-title-link"))) {
console.error("No video element found.");
} else {
link = titleNode.href;
fetch("http://localhost:5000/download", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
link: link,
}),
}).then((res) => {
textNode = titleNode.querySelector("yt-formatted-string");
textNode.style.setProperty("color", "green", "important");
res.json().then((data) => console.log(data));
});
}