Minefun Real Rain Mode

Mưa tằm tã toàn map + tiếng mưa + UI bật/tắt kéo được

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Minefun Real Rain Mode
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Mưa tằm tã toàn map + tiếng mưa + UI bật/tắt kéo được
// @author       You
// @match        *://minefun.io/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // ====== SETTINGS ======
    let enabled = true;
    let rainAmount = 350;
    let dropSpeed = 18;
    let rainSize = 1;
    let uiScale = 1;

    // ====== CANVAS ======
    const canvas = document.createElement("canvas");
    const ctx = canvas.getContext("2d");

    canvas.style.position = "fixed";
    canvas.style.top = "0";
    canvas.style.left = "0";
    canvas.style.width = "100%";
    canvas.style.height = "100%";
    canvas.style.pointerEvents = "none";
    canvas.style.zIndex = "999999";

    document.body.appendChild(canvas);

    function resizeCanvas() {
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
    }

    resizeCanvas();
    window.addEventListener("resize", resizeCanvas);

    // ====== RAIN DROPS ======
    const rainDrops = [];

    function createRain() {
        rainDrops.length = 0;

        for (let i = 0; i < rainAmount; i++) {
            rainDrops.push({
                x: Math.random() * canvas.width,
                y: Math.random() * canvas.height,
                l: Math.random() * 1 + 0.5,
                xs: -2 + Math.random() * 2,
                ys: dropSpeed + Math.random() * 10
            });
        }
    }

    createRain();

    // ====== RAIN SOUND ======
    const rainAudio = new Audio(
        "https://cdn.pixabay.com/download/audio/2022/03/15/audio_c8d1d6d95f.mp3?filename=rain-ambient-110397.mp3"
    );

    rainAudio.loop = true;
    rainAudio.volume = 0.35;

    function startRainSound() {
        rainAudio.play().catch(() => {});
    }

    document.addEventListener("click", startRainSound, { once: true });

    // ====== DARK SKY EFFECT ======
    const skyOverlay = document.createElement("div");

    skyOverlay.style.position = "fixed";
    skyOverlay.style.top = "0";
    skyOverlay.style.left = "0";
    skyOverlay.style.width = "100%";
    skyOverlay.style.height = "100%";
    skyOverlay.style.background =
        "linear-gradient(rgba(20,20,20,0.35), rgba(0,0,0,0.15))";
    skyOverlay.style.pointerEvents = "none";
    skyOverlay.style.zIndex = "999998";

    document.body.appendChild(skyOverlay);

    // ====== DRAW ======
    function drawRain() {
        if (!enabled) {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            requestAnimationFrame(drawRain);
            return;
        }

        ctx.clearRect(0, 0, canvas.width, canvas.height);

        ctx.strokeStyle = "rgba(180,200,255,0.45)";
        ctx.lineWidth = rainSize;
        ctx.lineCap = "round";

        for (let i = 0; i < rainDrops.length; i++) {
            const r = rainDrops[i];

            ctx.beginPath();
            ctx.moveTo(r.x, r.y);
            ctx.lineTo(r.x + r.l * r.xs, r.y + r.l * r.ys);
            ctx.stroke();

            r.x += r.xs;
            r.y += r.ys;

            if (r.x > canvas.width || r.y > canvas.height) {
                r.x = Math.random() * canvas.width;
                r.y = -20;
            }
        }

        requestAnimationFrame(drawRain);
    }

    drawRain();

    // ====== UI ======
    const panel = document.createElement("div");

    panel.style.position = "fixed";
    panel.style.top = "120px";
    panel.style.left = "20px";
    panel.style.zIndex = "1000000";
    panel.style.background = "rgba(0,0,0,0.6)";
    panel.style.color = "white";
    panel.style.padding = "8px";
    panel.style.borderRadius = "10px";
    panel.style.fontFamily = "Arial";
    panel.style.userSelect = "none";
    panel.style.backdropFilter = "blur(5px)";
    panel.style.transform = `scale(${uiScale})`;

    panel.innerHTML = `
        <div id="rainHeader" style="
            font-weight:bold;
            margin-bottom:6px;
            cursor:move;
            text-align:center;
        ">
            🌧 RAIN
        </div>

        <button id="toggleRain" style="
            width:100%;
            padding:5px;
            border:none;
            border-radius:6px;
            background:#4a90e2;
            color:white;
            cursor:pointer;
        ">
            ON
        </button>

        <div style="
            display:flex;
            gap:5px;
            margin-top:6px;
        ">
            <button id="minusUI" style="
                flex:1;
                border:none;
                border-radius:5px;
                padding:4px;
                cursor:pointer;
            ">-</button>

            <button id="plusUI" style="
                flex:1;
                border:none;
                border-radius:5px;
                padding:4px;
                cursor:pointer;
            ">+</button>
        </div>
    `;

    document.body.appendChild(panel);

    // ====== TOGGLE ======
    const toggleBtn = document.getElementById("toggleRain");

    toggleBtn.onclick = () => {
        enabled = !enabled;

        toggleBtn.textContent = enabled ? "ON" : "OFF";

        if (enabled) {
            skyOverlay.style.display = "block";
            canvas.style.display = "block";
            rainAudio.play().catch(() => {});
        } else {
            skyOverlay.style.display = "none";
            canvas.style.display = "none";
            rainAudio.pause();
        }
    };

    // ====== UI SCALE ======
    document.getElementById("plusUI").onclick = () => {
        uiScale += 0.1;
        panel.style.transform = `scale(${uiScale})`;
    };

    document.getElementById("minusUI").onclick = () => {
        uiScale = Math.max(0.5, uiScale - 0.1);
        panel.style.transform = `scale(${uiScale})`;
    };

    // ====== DRAGGABLE ======
    let dragging = false;
    let offsetX = 0;
    let offsetY = 0;

    const header = document.getElementById("rainHeader");

    header.onmousedown = (e) => {
        dragging = true;

        offsetX = e.clientX - panel.offsetLeft;
        offsetY = e.clientY - panel.offsetTop;
    };

    document.onmouseup = () => {
        dragging = false;
    };

    document.onmousemove = (e) => {
        if (!dragging) return;

        panel.style.left = (e.clientX - offsetX) + "px";
        panel.style.top = (e.clientY - offsetY) + "px";
    };

})();