Large Size X-Ray Toggle

Toggle dungeon transparency with large code size

スクリプトをインストールするには、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         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();

})();