Minefun Sky Color Shift

Change sky colors locally (client-side only)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Minefun Sky Color Shift
// @namespace    https://greasyfork.org
// @version      1.2
// @description  Change sky colors locally (client-side only)
// @match        *://*minefun*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // ===== STYLE INJECTION =====
    const style = document.createElement("style");
    style.innerHTML = `
    .sky-filter {
        filter: hue-rotate(0deg) saturate(2) brightness(1.2) !important;
        transition: filter 0.5s linear;
    }

    #skyBtn {
        position: fixed;
        top: 100px;
        right: 20px;
        z-index: 99999;
        padding: 10px 14px;
        background: #111;
        color: white;
        border: 1px solid #444;
        cursor: pointer;
        user-select: none;
        font-family: sans-serif;
    }
    `;
    document.head.appendChild(style);

    // ===== APPLY TO GAME ROOT =====
    function applySky() {
        // Minefun thường dùng body hoặc canvas wrapper
        document.body.classList.add("sky-filter");
    }

    function removeSky() {
        document.body.classList.remove("sky-filter");
    }

    // ===== BUTTON =====
    const btn = document.createElement("div");
    btn.id = "skyBtn";
    btn.innerText = "Sky OFF";
    document.body.appendChild(btn);

    let enabled = false;
    let hue = 0;
    let interval = null;

    const colorsSpeed = 20;

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

        if (enabled) {
            btn.innerText = "Sky ON";

            applySky();

            interval = setInterval(() => {
                hue += 15;
                if (hue > 360) hue = 0;

                document.body.style.filter =
                    `hue-rotate(${hue}deg) saturate(2) brightness(1.3)`;

            }, colorsSpeed);

        } else {
            btn.innerText = "Sky OFF";

            clearInterval(interval);
            removeSky();
            document.body.style.filter = "none";
        }
    };

    // ===== DRAG BUTTON =====
    let drag = false, ox, oy;

    btn.addEventListener("mousedown", (e) => {
        drag = true;
        ox = e.clientX - btn.offsetLeft;
        oy = e.clientY - btn.offsetTop;
    });

    document.addEventListener("mousemove", (e) => {
        if (!drag) return;
        btn.style.left = (e.clientX - ox) + "px";
        btn.style.top = (e.clientY - oy) + "px";
        btn.style.right = "auto";
    });

    document.addEventListener("mouseup", () => drag = false);

})();