Compare commits
4 Commits
7e12d9e939
...
master
Author | SHA1 | Date | |
---|---|---|---|
ca3c3423b1 | |||
0ce14bdc53 | |||
![]() |
676748f614 | ||
![]() |
b92a325b99 |
29
hotkey.js
29
hotkey.js
@@ -1,16 +1,27 @@
|
||||
nodes = document.querySelectorAll(":hover");
|
||||
i = 1;
|
||||
console.log(nodes);
|
||||
videoNode = nodes[nodes.length - i];
|
||||
titleNode = nodes[nodes.length - i];
|
||||
|
||||
while (videoNode && videoNode.tagName != "YTD-RICH-ITEM-RENDERER") {
|
||||
videoNode = videoNode.parentElement;
|
||||
console.log(videoNode);
|
||||
selector = "a#video-title-link";
|
||||
invidious = false;
|
||||
if (window.location.href.includes("invidious.site")) {
|
||||
selector = "a";
|
||||
invidious = true;
|
||||
}
|
||||
if (!(videoNode && videoNode.tagName == "YTD-RICH-ITEM-RENDERER")) {
|
||||
|
||||
while (titleNode && !titleNode.matches(selector)) {
|
||||
titleNode = titleNode.parentElement;
|
||||
console.log(titleNode);
|
||||
}
|
||||
if (!(titleNode && titleNode.matches(selector))) {
|
||||
console.error("No video element found.");
|
||||
} else {
|
||||
link = videoNode.querySelector("a#video-title-link").href;
|
||||
link = titleNode.href;
|
||||
if (link.startsWith("/")) {
|
||||
link = window.location.origin + link;
|
||||
}
|
||||
console.log(link);
|
||||
fetch("http://localhost:5000/download", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -20,7 +31,11 @@ if (!(videoNode && videoNode.tagName == "YTD-RICH-ITEM-RENDERER")) {
|
||||
link: link,
|
||||
}),
|
||||
}).then((res) => {
|
||||
console.log(res);
|
||||
textNode = titleNode.querySelector("yt-formatted-string");
|
||||
if (invidious) {
|
||||
textNode = titleNode.querySelector("p");
|
||||
}
|
||||
textNode.style.setProperty("color", "green", "important");
|
||||
res.json().then((data) => console.log(data));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user