-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (33 loc) · 1.37 KB
/
index.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
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
resolve(document.querySelector(selector));
observer.disconnect();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
window.addEventListener("load", function (){
waitForElm("#shorts-player > div.html5-video-container > video").then((elm) => {
let videoPlayer = document.querySelector("#shorts-player > div.html5-video-container > video")
let nextButton = document.querySelector("#navigation-button-down > ytd-button-renderer > a")
videoPlayer.addEventListener("play", (event) => {
setTimeout(function(){
document.querySelector("#shorts-player > div.html5-video-container > video").loop = false;
}, 5000)
})
videoPlayer.addEventListener("ended", () => {
nextButton.click()
document.querySelector("#shorts-player > div.html5-video-container > video").loop = false
})
videoPlayer.loop = false
});
})