Flashlight

Press L to toggle an ambient light for high stakes mining trips and late night building.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Flashlight
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Press L to toggle an ambient light for high stakes mining trips and late night building.
// @author       Qwerty Matthew
// @license      MIT
// @match        *://*.minefun.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let flashlightOn = false;
    let flashlightOverlay = null;

    // --- 1. CREATE THE OVERLAY ---
    function createFlashlightOverlay() {
        if (flashlightOverlay) return;

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

        // This styles a full-screen layer that sits on top of the game,
        // adjusting contrast and brightness smoothly without breaking mouse clicks.
        flashlightOverlay.style = `
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            pointer-events: none; /* Crucial: Allows you to still click and look around in game */
            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);
            display: none; /* Start turned off */
            transition: backdrop-filter 0.1s ease-in-out;
        `;

        document.body.appendChild(flashlightOverlay);
        createNotificationUI();
    }

    // --- 2. OPTIONAL STATUS TEXT ---
    let statusText;
    function createNotificationUI() {
        statusText = document.createElement('div');
        statusText.style = `
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(0, 0, 0, 0.7);
            color: #00ffcc;
            padding: 8px 16px;
            border-radius: 20px;
            font-family: sans-serif;
            font-size: 14px;
            font-weight: bold;
            z-index: 1000000;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.2s ease;
        `;
        document.body.appendChild(statusText);
    }

    function showNotification(text) {
        if (!statusText) return;
        statusText.innerText = text;
        statusText.style.opacity = '1';
        setTimeout(() => {
            statusText.style.opacity = '0';
        }, 1500);
    }

    // --- 3. TOGGLE FUNCTION ---
    function toggleFlashlight() {
        flashlightOn = !flashlightOn;

        if (flashlightOn) {
            flashlightOverlay.style.display = 'block';
            showNotification('🔦 Flashlight: ON');
        } else {
            flashlightOverlay.style.display = 'none';
            showNotification('🌑 Flashlight: OFF');
        }
    }

    // --- 4. KEYBOARD LISTENER ---
    document.addEventListener('keydown', (e) => {
        if (e.code === 'KeyL') {
            // Ignore if you are currently typing in chat or menu inputs
            if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') return;

            toggleFlashlight();
        }
    });

    // Run setup when page is ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', createFlashlightOverlay);
    } else {
        createFlashlightOverlay();
    }
})();