Bypass Fullscreen e Focus

Inganna il controllo dello schermo intero e del focus

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         Bypass Fullscreen e Focus
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  Inganna il controllo dello schermo intero e del focus
// @match        *://*/*
// @run-at       document-start
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. BYPASS VISIBILITA' E FOCUS ---
    Object.defineProperty(document, 'visibilityState', { get: () => 'visible' });
    Object.defineProperty(document, 'hidden', { get: () => false });

    const blockFocusEvents = (e) => {
        e.stopImmediatePropagation();
        e.preventDefault();
    };

    window.addEventListener('visibilitychange', blockFocusEvents, true);
    document.addEventListener('visibilitychange', blockFocusEvents, true);
    window.addEventListener('blur', blockFocusEvents, true);
    document.addEventListener('blur', blockFocusEvents, true);


    // --- 2. BYPASS SCHERMO INTERO ---
    // Creiamo un finto elemento da restituire quando il sito chiede se siamo in Fullscreen
    const mockFullscreenElement = document.documentElement;

    const fullscreenProps = [
        'fullscreenElement',
        'webkitFullscreenElement',
        'mozFullScreenElement',
        'msFullscreenElement'
    ];

    // Sovrascriviamo le proprietà in modo che non restituiscano mai "null"
    fullscreenProps.forEach(prop => {
        Object.defineProperty(document, prop, {
            get: () => mockFullscreenElement,
            configurable: true
        });
    });

    // Blocchiamo gli eventi di cambio schermo intero
    const blockFullscreenEvents = (e) => {
        e.stopImmediatePropagation();
        // Nota: non usiamo preventDefault() qui perché l'azione di base (uscire) è forzata dal browser
    };

    const fullscreenEvents = [
        'fullscreenchange',
        'webkitfullscreenchange',
        'mozfullscreenchange',
        'MSFullscreenChange'
    ];

    fullscreenEvents.forEach(evt => {
        document.addEventListener(evt, blockFullscreenEvents, true);
        window.addEventListener(evt, blockFullscreenEvents, true);
    });

})();