NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name AutoPlay Video AutoStopper // @namespace com.vsubhash.js.autoplay-video-auto-stopper // @description Pauses auto-playing videos. Excludes YouTube (has its own autostopper script com.vsubhash.js.youtube-annoyances-remover); Supports Firefox-based browser up to Version 36. Newer versions should use a UserAgent (UA) spoofer add-on. YouTube loads a lighter version of the YouTube page for older browsers. This script will require the GreaseMonkey add-on to run the script inside a browser. // @exclude https://www.youtube.com/* // @version 2019.02 // @copyright 2019, V. Subhash (www.vsubhash.com) // @license MIT // @homepageURL https://gist.github.com/vsubhash // @author zomberi // @grant none // ==/UserScript== document.addEventListener("readystatechange", handle_DOMLoad, false); function handle_DOMLoad() { console.log("VideoAutoStopper: Readystatechange."); if ((document.readyState == "interactive") || (document.readyState == "complete")) { console.log("VideoAutoStopper: Document iteractive/complete."); window.setTimeout(pauseAllVideos, 1*1000); window.setTimeout(pauseAllVideos, 5*1000); window.setTimeout(pauseAllVideos, 20*1000); window.setTimeout(pauseAllVideos, 30*1000); } } function pauseAllVideos() { console.log("VideoAutoStopper: Parsing video tags..."); try { var arVideos = document.getElementsByTagName("video"); for (var i = 0; i < arVideos.length; i++) { arVideos[i].pause(); console.log("VideoAutoStopper: Paused a video - " + (i+1)); arVideos[i].muted = true; // custom controls may not update arVideos[i].removeAttribute("autoplay"); arVideos[i].removeAttribute("loop"); arVideos[i].setAttribute("preload", "none"); } } catch(e) { console.error("VideoAutoStopper: Error - " + e); } }