Flashlight

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu betiği yüklemek için bir betik yöneticisi eklentisi yüklemeniz gerekecektir.

(Zaten bir betik yöneticim var, hadi yükleyelim!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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