Universal Fullscreen (Alt+X)

Fullscreen toggle with console debugging

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 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         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();
                }
            }
        }
    });
})();