Add hotkey for download

This commit is contained in:
PhatPhuckDave
2024-07-21 18:56:11 +02:00
parent 7cf0cf5033
commit 38449a7676

26
hotkey.js Normal file
View File

@@ -0,0 +1,26 @@
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));
});
}