Compare commits

..

4 Commits

Author SHA1 Message Date
ca3c3423b1 Discover go install 2024-10-03 10:53:35 +02:00
0ce14bdc53 Update hotkey 2024-08-17 15:12:01 +02:00
PhatPhuckDave
676748f614 Make text green when download started
Finally, feedback
2024-07-22 15:45:53 +02:00
PhatPhuckDave
b92a325b99 Update hotkey to work with any youtube page (hopefully) 2024-07-21 23:29:24 +02:00
3 changed files with 23 additions and 9 deletions

View File

@@ -1,3 +1,3 @@
module main
module dl
go 1.22.4

View File

@@ -1 +0,0 @@
main.exe,"C:\Program Files\Git\usr\bin\dl.exe",t

View File

@@ -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));
});
}