Skip to content

Instantly share code, notes, and snippets.

@SocksTheWolf
Last active May 28, 2026 00:09
Show Gist options
  • Select an option

  • Save SocksTheWolf/822155d955661416df1dde5a48cb3e73 to your computer and use it in GitHub Desktop.

Select an option

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.
// ==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; } });
@SlyAceZeta

Copy link
Copy Markdown

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