Aims to prevent autoplay on any streaming service!
// ==UserScript==
// @name Universal Autoplay Stopper
// @version 0.8
// @description Aims to prevent autoplay on any streaming service!
// @match https://*/*
// @namespace https://greasyfork.org/users/189717
// ==/UserScript==
(() => {
const setLastUserAction = () => {
localStorage.setItem('last user action', Date.now())
}
['click', 'keydown'].forEach((type) => {
document.addEventListener(type, setLastUserAction)
// Listen on this element for Netflix, because events don't bubble up to document.
const watchVideoElement = document.querySelector('.watch-video')
if(watchVideoElement){
watchVideoElement.addEventListener(type, setLastUserAction)
}
})
setInterval(() => {
document.querySelectorAll('video').forEach((v) => {
const timeSinceAction = Date.now() - (localStorage.getItem('last user action') ?? 0)
if(v.currentTime < 30 && timeSinceAction > 60000 && !v.paused){
v.pause()
}
})
}, 1000)
})()