Skip to content

Commit

Permalink
Add plugin to disable autoplay
Browse files Browse the repository at this point in the history
  • Loading branch information
th-ch committed Mar 4, 2021
1 parent 796a7aa commit eaa9571
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions plugins/disable-autoplay/front.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit eaa9571

Please sign in to comment.