Files
youtube-downloader/hotkey.js
2024-07-21 18:56:11 +02:00

27 lines
710 B
JavaScript

nodes = document.querySelectorAll(":hover");
i = 1;
console.log(nodes);
videoNode = nodes[nodes.length - i];
while (videoNode && videoNode.tagName != "YTD-RICH-ITEM-RENDERER") {
videoNode = videoNode.parentElement;
console.log(videoNode);
}
if (!(videoNode && videoNode.tagName == "YTD-RICH-ITEM-RENDERER")) {
console.error("No video element found.");
} else {
link = videoNode.querySelector("a#video-title-link").href;
fetch("http://localhost:5000/download", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
link: link,
}),
}).then((res) => {
console.log(res);
res.json().then((data) => console.log(data));
});
}