Universal Fullscreen (Alt+X)

Fullscreen toggle with console debugging

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

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

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         Universal Fullscreen (Alt+X)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Fullscreen toggle with console debugging
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    
    console.log("✅ Fullscreen script loaded on this page.");

    document.addEventListener('keydown', function(e) {
        // Check if Alt + X is pressed
        if (e.altKey && e.key.toLowerCase() === 'x') {
            console.log("⌨️ Alt+X pressed!");
            e.preventDefault(); 

            if (!document.fullscreenElement) {
                console.log("Attempting to enter fullscreen...");
                if (document.documentElement.requestFullscreen) {
                    document.documentElement.requestFullscreen().then(() => {
                        console.log("🟢 Fullscreen entered successfully.");
                    }).catch(err => {
                        console.error(`🔴 Fullscreen blocked by browser: ${err.message}`);
                    });
                } else {
                    console.error("🔴 requestFullscreen API not supported on this page.");
                }
            } else {
                console.log("Attempting to exit fullscreen...");
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                }
            }
        }
    });
})();