Skip to content

Instantly share code, notes, and snippets.

@jukben
Last active February 12, 2026 12:40
Show Gist options
  • Select an option

  • Save jukben/b62b389e7dcd0b10c4a64ef0bdafd5b4 to your computer and use it in GitHub Desktop.

Select an option

Save jukben/b62b389e7dcd0b10c4a64ef0bdafd5b4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name EasyLlama Anti Focus Detection
// @namespace https://github.com/jukben
// @version 1.1
// @description Prevents websites from detecting tab/window focus loss
// @author jukben
// @match *://*.mygo1.com/*
// @match *://app.easyllama.com/*
// @run-at document-start
// @grant none
// @updateURL https://gist.github.com/jukben/b62b389e7dcd0b10c4a64ef0bdafd5b4/raw/focused-easyllama.user.js
// @downloadURL https://gist.github.com/jukben/b62b389e7dcd0b10c4a64ef0bdafd5b4/raw/focused-easyllama.user.js
// @homepageURL https://gist.github.com/jukben/b62b389e7dcd0b10c4a64ef0bdafd5b4
// ==/UserScript==
(function() {
'use strict';
const log = (msg) => console.log(`%c[Anti-Focus] ${msg}`, 'color: #00cc88; font-weight: bold');
log('Script loaded ✓');
Object.defineProperty(document, 'hidden', { get: () => false });
Object.defineProperty(document, 'visibilityState', { get: () => 'visible' });
Document.prototype.hasFocus = () => true;
log('Patched document.hidden, visibilityState, hasFocus()');
document.addEventListener('visibilitychange', e => { e.stopImmediatePropagation(); log('Blocked visibilitychange event'); }, true);
window.addEventListener('blur', e => { e.stopImmediatePropagation(); log('Blocked window blur'); }, true);
window.addEventListener('focus', e => { e.stopImmediatePropagation(); log('Blocked window focus'); }, true);
document.addEventListener('blur', e => { e.stopImmediatePropagation(); log('Blocked document blur'); }, true);
document.addEventListener('focus', e => { e.stopImmediatePropagation(); log('Blocked document focus'); }, true);
log('All event listeners installed ✓');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment