Disable Page Visibility API

Disable Page Visibility API Script

La data de 14-08-2025. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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.');
})();