mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
Add plugin to disable autoplay
This commit is contained in:
25
plugins/disable-autoplay/front.js
Normal file
25
plugins/disable-autoplay/front.js
Normal file
@ -0,0 +1,25 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user