Last active
July 28, 2021 21:19
-
-
Save dmryabov/9342068195602bd71c2e387af4524556 to your computer and use it in GitHub Desktop.
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 Constant Quality | |
// @description Prevents automatic stream quality degradation when tab is hidden. | |
// @match *://*.twitch.tv/* | |
// @namespace https://gist.github.com/dmryabov/ | |
// @version 1.4 | |
// @grant none | |
// @run-at document-start | |
// @downloadUrl https://gist.githubusercontent.com/dmryabov/9342068195602bd71c2e387af4524556/raw/twitch-constant-quality.js | |
// ==/UserScript== | |
const addEventListener = window.addEventListener; | |
const interceptedEventNames = { | |
'visibilitychange': true, | |
'msvisibilitychange': true, | |
'webkitvisibilitychange': true, | |
}; | |
document.addEventListener = function () { | |
const eventName = arguments[0]; | |
if (interceptedEventNames[eventName]) { | |
console.debug(`prevented adding of "${eventName}" listener`); | |
return; | |
} | |
addEventListener.apply(this, arguments); | |
}; | |
setInterval(function () { | |
let pointsButton = document.querySelector('div[data-test-selector="community-points-summary"] button[aria-label="Claim Bonus"]'); | |
if (pointsButton) { | |
pointsButton.click(); | |
console.debug('clicked twitch points button'); | |
} | |
}, 2500); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment