diff --git a/hotkey.js b/hotkey.js new file mode 100644 index 0000000..12ddbe4 --- /dev/null +++ b/hotkey.js @@ -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)); + }); +}