27 lines
710 B
JavaScript
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));
|
|
});
|
|
}
|