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, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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();
    }
})();