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");
|
nodes = document.querySelectorAll(":hover");
|
||||||
i = 1;
|
i = 1;
|
||||||
console.log(nodes);
|
console.log(nodes);
|
||||||
videoNode = nodes[nodes.length - i];
|
titleNode = nodes[nodes.length - i];
|
||||||
|
|
||||||
while (videoNode && videoNode.tagName != "YTD-RICH-ITEM-RENDERER") {
|
selector = "a#video-title-link";
|
||||||
videoNode = videoNode.parentElement;
|
invidious = false;
|
||||||
console.log(videoNode);
|
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.");
|
console.error("No video element found.");
|
||||||
} else {
|
} 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", {
|
fetch("http://localhost:5000/download", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
@@ -20,7 +31,11 @@ if (!(videoNode && videoNode.tagName == "YTD-RICH-ITEM-RENDERER")) {
|
|||||||
link: link,
|
link: link,
|
||||||
}),
|
}),
|
||||||
}).then((res) => {
|
}).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));
|
res.json().then((data) => console.log(data));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user