Last active
May 28, 2026 00:09
-
-
Save SocksTheWolf/822155d955661416df1dde5a48cb3e73 to your computer and use it in GitHub Desktop.
Userscript for allowing for lurking as a Twitch user. Press the Raw button to trigger install.
This file contains hidden or 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 TwitchAllowLurks | |
| // @namespace https://socksthewolf.com/ | |
| // @version 0.2.4 | |
| // @description Disable HTML5 Page Visibility API to prevent Twitch ads from stopping lurks | |
| // @author kookxiang (code) & socksthewolf (config) | |
| // @match https://twitch.tv/* | |
| // @match https://m.twitch.tv/* | |
| // @match https://www.twitch.tv/* | |
| // @exclude https://www.twitch.tv/popout/*/guest-star | |
| // @exclude https://www.twitch.tv/settings/* | |
| // @grant none | |
| // @run-at document-start | |
| // @downloadURL https://gist.githubusercontent.com/SocksTheWolf/822155d955661416df1dde5a48cb3e73/raw/twitchallowlurks.user.js | |
| // ==/UserScript== | |
| // stop visibility monitoring events | |
| document.addEventListener('visibilitychange', function (e) { e.stopImmediatePropagation(); }, true); | |
| // disable unfocus events | |
| window.addEventListener('blur', function (e) { e.stopImmediatePropagation(); }, true); | |
| // override document.visibilityState to always return the page is visible | |
| Object.defineProperty(document, 'visibilityState', { get: function () { return "visible"; } }); | |
| // override document.hidden to always return that the page is rendering | |
| Object.defineProperty(document, 'hidden', { get: function () { return false; } }); |
Author
Huge thanks for this, I hope this will help! Much prefer a solution like this over a browser-wide extension.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated script with a few excludes locations (disables this code from running the on guest star page and your settings pages), and inlined comments into script so it's clear what the script does.