Flashlight

Press L to power main flashlight. Press X, ESC, B, N, or Q to toggle light OFF/ON while L remains active. Ignores bottom center menu bar.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Flashlight
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Press L to power main flashlight. Press X, ESC, B, N, or Q to toggle light OFF/ON while L remains active. Ignores bottom center menu bar.
// @author       Qwerty Matthew
// @license      MIT
// @match        *://*.minefun.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let masterOn = false;
    let secondaryActive = true;
    let flashlightOverlay = null;

    function createFlashlightOverlay() {
        if (flashlightOverlay) return;

        flashlightOverlay = document.createElement('div');
        flashlightOverlay.id = 'flashlight-ambient-overlay';

        flashlightOverlay.style = `
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            pointer-events: none;
            z-index: 999999;
            backdrop-filter: brightness(1.8) contrast(0.85) saturate(1.1);
            -webkit-backdrop-filter: brightness(1.8) contrast(0.85) saturate(1.1);
            /* Keep bottom-left (345px) and bottom-right (345px) illuminated, clip center bottom by 58px */
            clip-path: polygon(
                0 0, 
                100% 0, 
                100% 100%, 
                calc(100% - 345px) 100%, 
                calc(100% - 345px) calc(100% - 58px), 
                345px calc(100% - 58px), 
                345px 100%, 
                0 100%
            );
            opacity: 0;
            transition: opacity 0.15s ease-in-out;
        `;

        document.body.appendChild(flashlightOverlay);
    }

    function updateOverlayState() {
        if (masterOn && secondaryActive) {
            flashlightOverlay.style.opacity = '1';
        } else {
            flashlightOverlay.style.opacity = '0';
        }
    }

    function toggleMaster() {
        masterOn = !masterOn;
        if (masterOn) {
            secondaryActive = true;
        }
        updateOverlayState();
    }

    function toggleSecondary() {
        if (!masterOn) return;
        secondaryActive = !secondaryActive;
        updateOverlayState();
    }

    document.addEventListener('keydown', (e) => {
        if (e.repeat) return;

        const active = document.activeElement;
        if (active.tagName === 'INPUT' || active.tagName === 'TEXTAREA' || active.isContentEditable) return;

        if (e.code === 'KeyL') {
            toggleMaster();
        } else if (
            e.code === 'KeyX' ||
            e.code === 'Escape' ||
            e.code === 'KeyB' ||
            e.code === 'KeyN' ||
            e.code === 'KeyQ'
        ) {
            toggleSecondary();
        }
    });

    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', createFlashlightOverlay);
    } else {
        createFlashlightOverlay();
    }
})();