diff --git a/plugins/disable-autoplay/front.js b/plugins/disable-autoplay/front.js new file mode 100644 index 00000000..c40eb7fd --- /dev/null +++ b/plugins/disable-autoplay/front.js @@ -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;