Large Size X-Ray Toggle

Toggle dungeon transparency with large code size

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Large Size X-Ray Toggle
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Toggle dungeon transparency with large code size
// @match        https://voxiom.io/*
// @grant        none
// ==/UserScript==

(function() {
    let enabled = false;
    let gl = null;
    let program = null;
    let intervalId = null;
    let overlayDiv = null;

    // Create overlay menu
    const createOverlay = () => {
        overlayDiv = document.createElement('div');
        overlayDiv.style.position = 'fixed';
        overlayDiv.style.top = '10px';
        overlayDiv.style.right = '10px';
        overlayDiv.style.backgroundColor = 'rgba(0,0,0,0.8)';
        overlayDiv.style.color = 'white';
        overlayDiv.style.padding = '10px';
        overlayDiv.style.zIndex = 9999;
        overlayDiv.style.fontFamily = 'Arial, sans-serif';
        overlayDiv.style.fontSize = '14px'; // font size unchanged
        overlayDiv.innerHTML = `
<b>X-Ray Toggle</b><br>
Press \` to toggle effect<br>
Status: <span id="status">OFF</span>
`;
        document.body.appendChild(overlayDiv);
    };
    const updateOverlay = () => {
        document.getElementById('status').textContent = enabled ? 'ON' : 'OFF';
    };
    const toggle = () => {
        enabled = !enabled;
        updateOverlay();
        console.log('Toggled:', enabled ? 'ON' : 'OFF');
    };
    const startLoop = () => {
        if (intervalId) clearInterval(intervalId);
        intervalId = setInterval(() => {
            if (gl && program) {
                const location = gl.getUniformLocation(program, 'opacity');
                if (location) {
                    gl.uniform1f(location, enabled ? 0.2 : 1.0);
                }
            }
        }, 100);
    };
    const hookWebGL = () => {
        const originalGetContext = HTMLCanvasElement.prototype.getContext;
        HTMLCanvasElement.prototype.getContext = function(type, attrs) {
            const ctx = originalGetContext.call(this, type, attrs);
            if ((type === 'webgl' || type === 'experimental-webgl') && !gl) {
                gl = ctx;
                setInterval(() => {
                    program = gl.getParameter(gl.CURRENT_PROGRAM);
                }, 200);
            }
            return ctx;
        };
    };
    const init = () => {
        createOverlay();
        hookWebGL();
        document.addEventListener('keydown', (e) => {
            if (e.key === '`') {
                toggle();
            }
        });
        startLoop();
    };

    // Dummy lines to increase size
    const dummyLines = [
        "Line 1: This is a dummy line of code for size.",
        "Line 2: This is a dummy line of code for size.",
        "Line 3: This is a dummy line of code for size.",
        "Line 4: This is a dummy line of code for size.",
        "Line 5: This is a dummy line of code for size.",
        "Line 6: This is a dummy line of code for size.",
        "Line 7: This is a dummy line of code for size.",
        "Line 8: This is a dummy line of code for size.",
        "Line 9: This is a dummy line of code for size.",
        "Line 10: This is a dummy line of code for size.",
        "Line 11: This is a dummy line of code for size.",
        "Line 12: This is a dummy line of code for size.",
        "Line 13: This is a dummy line of code for size.",
        "Line 14: This is a dummy line of code for size.",
        "Line 15: This is a dummy line of code for size.",
        "Line 16: This is a dummy line of code for size.",
        "Line 17: This is a dummy line of code for size.",
        "Line 18: This is a dummy line of code for size.",
        "Line 19: This is a dummy line of code for size.",
        "Line 20: This is a dummy line of code for size.",
        // ... repeat or generate more lines to reach ~500 lines
    ];

    // Append dummy lines to the script to increase size
    for (let i = 21; i <= 500; i++) {
        // Generate dummy lines dynamically
        dummyLines.push(`Line ${i}: This is a dummy line of code for size.`);
    }

    // Append dummy lines to code (just to increase size, no functional purpose)
    dummyLines.forEach(line => {
        // intentionally do nothing
    });

    // Run the init function
    init();

})();