Disable Page Visibility API

Disable Page Visibility API Script

Verze ze dne 14. 08. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name Disable Page Visibility API
// @version 1.0
// @description Disable Page Visibility API Script
// @match *://*/*
// @license MIT
// @grant none
// @run-at document-start
// @namespace https://greasyfork.org/users/956726
// ==/UserScript==

(function() {
    'use strict';

    Object.defineProperties(document,{ 'hidden': {value: false} });
    Object.defineProperties(document,{ 'mshidden': {value: false} });
    Object.defineProperties(document,{ 'mozHidden': {value: false} });
    Object.defineProperties(document,{ 'webkitHidden': {value: false} });
    Object.defineProperties(document,{ 'visibilityState': {value: 'visible'} });
    Object.defineProperties(document,{ 'mozvisibilityState': {value: 'visible'} });
    Object.defineProperties(document,{ 'webkitvisibilityState': {value: 'visible'} });

    const evt = e => {
        e.preventDefault();
        e.stopPropagation();
        e.stopImmediatePropagation();
    };
    document.addEventListener('visibilitychange', evt, true);
    document.addEventListener('msvisibilitychange', evt, true);
    document.addEventListener('mozvisibilitychange', evt, true);
    document.addEventListener('webkitvisibilitychange', evt, true);
    document.addEventListener('hasFocus', evt, true);
    window.addEventListener('blur', evt, true);
    window.addEventListener('focus', evt, true);

    console.log('Disable Page Visibility API Enabled.');
})();