mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
26 lines
564 B
JavaScript
26 lines
564 B
JavaScript
let videoElement = null;
|
|
|
|
const observer = new MutationObserver((mutations, observer) => {
|
|
if (!videoElement) {
|
|
videoElement = document.querySelector("video");
|
|
}
|
|
|
|
if (videoElement) {
|
|
videoElement.ontimeupdate = () => {
|
|
if (videoElement.currentTime === 0 && videoElement.duration !== NaN) {
|
|
// auto-confirm-when-paused plugin can interfere here if not disabled!
|
|
videoElement.pause();
|
|
}
|
|
};
|
|
}
|
|
});
|
|
|
|
function observeVideoElement() {
|
|
observer.observe(document, {
|
|
childList: true,
|
|
subtree: true,
|
|
});
|
|
}
|
|
|
|
module.exports = observeVideoElement;
|