☰

MineFun.io Fake Infinite Items Toggle

Fake ∞ items + toggle on/off bằng hover chuột (chỉ visual, không hack thật)

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         MineFun.io Fake Infinite Items Toggle
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Fake ∞ items + toggle on/off bằng hover chuột (chỉ visual, không hack thật)
// @author       You
// @match        https://minefun.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let isInfinite = false;
    let toggleButton = null;
    let interval = null;

    function createToggleButton() {
        if (toggleButton) return;

        toggleButton = document.createElement('div');
        toggleButton.innerHTML = '∞ ITEMS: OFF';
        toggleButton.style.position = 'fixed';
        toggleButton.style.top = '10px';
        toggleButton.style.right = '10px';
        toggleButton.style.background = '#222';
        toggleButton.style.color = 'white';
        toggleButton.style.padding = '10px 15px';
        toggleButton.style.borderRadius = '8px';
        toggleButton.style.cursor = 'pointer';
        toggleButton.style.zIndex = '99999';
        toggleButton.style.fontFamily = 'Arial, sans-serif';
        toggleButton.style.userSelect = 'none';
        toggleButton.style.border = '2px solid #444';

        document.body.appendChild(toggleButton);

        // Toggle khi click
        toggleButton.addEventListener('click', () => {
            isInfinite = !isInfinite;
            updateButton();
            if (isInfinite) {
                startFakeInfinite();
            } else {
                stopFakeInfinite();
            }
        });

        // Hoặc hover để bật/tắt nhanh (như yêu cầu)
        let hoverTimeout;
        toggleButton.addEventListener('mouseenter', () => {
            hoverTimeout = setTimeout(() => {
                isInfinite = true;
                updateButton();
                startFakeInfinite();
            }, 400); // hover 0.4 giây thì bật
        });

        toggleButton.addEventListener('mouseleave', () => {
            clearTimeout(hoverTimeout);
            // Nếu muốn tắt khi rời chuột thì uncomment dòng dưới
            // isInfinite = false;
            // updateButton();
            // stopFakeInfinite();
        });
    }

    function updateButton() {
        if (!toggleButton) return;
        toggleButton.innerHTML = `∞ ITEMS: ${isInfinite ? 'ON' : 'OFF'}`;
        toggleButton.style.background = isInfinite ? '#d32f2f' : '#222';
        toggleButton.style.borderColor = isInfinite ? '#f44336' : '#444';
    }

    function startFakeInfinite() {
        if (interval) return;

        interval = setInterval(() => {
            // Tìm các số lượng item trong inventory (thay đổi tùy phiên bản game)
            document.querySelectorAll('div[class*="amount"], span[class*="count"], div[class*="quantity"]')
                .forEach(el => {
                    if (el.textContent.match(/^\d+$/)) {
                        el.textContent = '∞';
                        el.style.color = '#ffeb3b';
                        el.style.fontWeight = 'bold';
                    }
                });

            // Thử đổi số coin / tiền nếu có
            document.querySelectorAll('div[class*="coin"], span[class*="money"], div[class*="balance"]')
                .forEach(el => {
                    if (el.textContent.match(/\d+/)) {
                        el.textContent = '∞';
                        el.style.color = '#4caf50';
                    }
                });
        }, 800);
    }

    function stopFakeInfinite() {
        if (interval) {
            clearInterval(interval);
            interval = null;
        }
        // Có thể reset lại số về giá trị thật nếu muốn, nhưng khó vì không biết giá trị gốc
    }

    // Chờ game load
    const observer = new MutationObserver(() => {
        if (document.body) {
            createToggleButton();
        }
    });

    observer.observe(document.documentElement || document.body, { childList: true, subtree: true });

    // Thử chạy ngay
    setTimeout(createToggleButton, 3000);
})();