-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
38 lines (33 loc) · 1.29 KB
/
content.js
File metadata and controls
38 lines (33 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var observer = new MutationObserver(function (mutations) {
var findAndClick = function (node, selector) {
var matchedNode = node.querySelector(selector);
if (matchedNode) {
matchedNode.click();
return true;
}
return false;
}
var findAndClickDifferentElements = function (node, identifierSelector, clickSelector) {
var autoPlayPresent = node.querySelector(identifierSelector);
if (autoPlayPresent) {
return findAndClick(node, clickSelector);
}
return false;
}
mutations.forEach(function (mutation) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
var node = mutation.addedNodes[i];
if (node && node instanceof Element) {
var matched = findAndClick(node, '[aria-label="Skip Intro"]');
if (!matched) {
matched = findAndClickDifferentElements(node, '.WatchNext-autoplay', '.PlayIcon-size-medium')
if (!matched) {
matched = findAndClick(node, '[aria-label ^= "Next episode in"]');
console.log(matched);
}
}
}
}
})
});
observer.observe(document, { childList: true, subtree: true });