Last active
November 21, 2023 21:40
-
-
Save bhughes339/24262ad737d35778db69bf9f778e595e to your computer and use it in GitHub Desktop.
Automatically pause Twitch VODs when window not visible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitch VOD Autopause | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Automatically pause Twitch VODs when window not visible | |
// @author bhughes339 | |
// @match https://*.twitch.tv/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv | |
// ==/UserScript== | |
var intervalMs = 100; | |
(function() { | |
'use strict'; | |
setInterval(function() { | |
var vid = document.getElementsByTagName("video")[0]; | |
// Pause videos when not in focus | |
if (document.hidden && document.URL.includes("/videos/")) { | |
vid.pause(); | |
}; | |
// Pause autoplay bullshit | |
if (document.URL.match(/videos($|\?)/) || !document.URL.includes("/videos")) { | |
vid.pause(); | |
vid.muted = false; | |
}; | |
}, intervalMs); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment