Add hotkey for download
This commit is contained in:
26
hotkey.js
Normal file
26
hotkey.js
Normal 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));
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user