Update hotkey
This commit is contained in:
18
hotkey.js
18
hotkey.js
@@ -3,14 +3,25 @@ i = 1;
|
||||
console.log(nodes);
|
||||
titleNode = nodes[nodes.length - i];
|
||||
|
||||
while (titleNode && !titleNode.matches("a#video-title-link")) {
|
||||
selector = "a#video-title-link";
|
||||
invidious = false;
|
||||
if (window.location.href.includes("invidious.site")) {
|
||||
selector = "a";
|
||||
invidious = true;
|
||||
}
|
||||
|
||||
while (titleNode && !titleNode.matches(selector)) {
|
||||
titleNode = titleNode.parentElement;
|
||||
console.log(titleNode);
|
||||
}
|
||||
if (!(titleNode && titleNode.matches("a#video-title-link"))) {
|
||||
if (!(titleNode && titleNode.matches(selector))) {
|
||||
console.error("No video element found.");
|
||||
} else {
|
||||
link = titleNode.href;
|
||||
if (link.startsWith("/")) {
|
||||
link = window.location.origin + link;
|
||||
}
|
||||
console.log(link);
|
||||
fetch("http://localhost:5000/download", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -21,6 +32,9 @@ if (!(titleNode && titleNode.matches("a#video-title-link"))) {
|
||||
}),
|
||||
}).then((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