Update hotkey script to work with multiple selectors
Because, of course, videos are drawn differently on home page, search results, video recommendations and subscriptions THANKS GOOGL
This commit is contained in:
14
hotkey.js
14
hotkey.js
@@ -1,20 +1,26 @@
|
||||
nodes = document.querySelectorAll(":hover");
|
||||
i = 1;
|
||||
console.log(nodes);
|
||||
titleNode = nodes[nodes.length - i];
|
||||
|
||||
selector = "a#video-title-link";
|
||||
selectors = ["a#video-title-link", "a#video-title"];
|
||||
invidious = false;
|
||||
if (window.location.href.includes("invidious.site")) {
|
||||
selector = "a";
|
||||
invidious = true;
|
||||
}
|
||||
|
||||
while (titleNode && !titleNode.matches(selector)) {
|
||||
titleNode = nodes[nodes.length - i];
|
||||
outer:
|
||||
while (titleNode) {
|
||||
for (let selector of selectors) {
|
||||
if (titleNode.matches(selector)) {
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
titleNode = titleNode.parentElement;
|
||||
console.log(titleNode);
|
||||
}
|
||||
if (!(titleNode && titleNode.matches(selector))) {
|
||||
if (!titleNode) {
|
||||
console.error("No video element found.");
|
||||
} else {
|
||||
link = titleNode.href;
|
||||
|
Reference in New Issue
Block a user