Universal Fullscreen (Alt+X)

Fullscreen toggle with console debugging

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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();
                }
            }
        }
    });
})();