-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
54 lines (50 loc) · 1.3 KB
/
main.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(async () => {
// if (true)
// return console.log('YOUTUBE CHANGED SOME STUFF SO WORKING ON FIX')
const initObserve = (selector, cb) => {
let startElem = document.querySelector(selector);
if (startElem) {
try {
cb(startElem);
} catch (e) {
console.log(e);
}
}
const observer = new MutationObserver((mutations) => {
let elem = document.querySelector(selector);
if (elem) {
try {
cb(elem);
} catch (e) {
console.log(e);
}
}
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
};
try {
initObserve(".ytp-ad-skip-button-container", (elem) => {
setTimeout(() => {
elem.click();
console.log("skipped");
}, 500);
});
initObserve(".ytp-ad-player-overlay-layout", (elem) => {
let btnElem = document.querySelector(".ytp-ad-skip-button-container");
if (!btnElem) {
let videoElem = document.getElementsByTagName("video");
if (videoElem) videoElem = videoElem[0];
setTimeout(() => {
videoElem?.fastSeek(videoElem.duration ?? 4444);
console.log("skipped");
}, 500);
}
});
console.log("SET");
} catch (e) {
console.log("Error ", e);
}
})();