Greasy Fork

Greasy Fork is available in English.

IPE禅模式

为IPE添加F11全屏功能

目前为 2025-04-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         IPE禅模式
// @namespace    https://thdog.moe/
// @version      0.1
// @description  为IPE添加F11全屏功能
// @author       shirokurakana
// @match        *://thwiki.cc/*
// @icon         https://static.thbwiki.cc/favicon.ico
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    let isIPEFullScreen = false;
    // 监听键盘事件
    document.addEventListener('keydown', function(event) {
        // 检测按下的键是否是F11
        if (event.key === 'F11' || event.keyCode === 122) { // 双重兼容判断
            // 阻止浏览器默认全屏行为(可选)
            event.preventDefault();

            if (isIPEFullScreen) {
                unsetFullScreen();
            } else {
                setFullScreen();
            }
            isIPEFullScreen = !isIPEFullScreen;
        }
    });

    function setFullScreen() {
        document.querySelector('.monaco-container').style.height = '640px';
        document.querySelector('#ssi-modalWrapper').style.width = '100%';
        document.querySelector('#ssi-modalWrapper').style.maxWidth = 'unset';
        document.querySelector('#ssi-modalWrapper').style.margin = '0 auto';
    }

    function unsetFullScreen() {
        document.querySelector('.monaco-container').style.height = '386px';
        document.querySelector('#ssi-modalWrapper').style.width = '85%';
        document.querySelector('#ssi-modalWrapper').style.maxWidth = '900px';
        document.querySelector('#ssi-modalWrapper').style.margin = '30px auto 20px';
    }
})();