-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdetail-content.js
38 lines (35 loc) · 1011 Bytes
/
detail-content.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
const waitForDomElement = (check, containerSelector, callback) => {
if (check()) {
callback()
} else {
const observer = new MutationObserver((mutationsList, observer) => {
if (!check()) return
observer.disconnect()
callback()
})
observer.observe(document.querySelector(containerSelector), {
childList: true,
subtree: true
})
return observer
}
}
const onLoad = () => {
waitForDomElement(() => document.querySelector('.embedded-player-container.show'), 'body', () => {
document.body.classList.add('playing')
})
//// Todo: sync videos
// waitForDomElement(() => document.querySelector('video'), 'body', () => {
// const video = document.querySelector('video')
// console.log('video', video)
// // if(!video) return
// // video.currentTime = 30
// })
}
window.addEventListener('DOMContentLoaded', () => {
if(document.readyState === 'complete') {
onLoad()
} else {
window.addEventListener('load', onLoad)
}
})