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.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

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