Minefun Ultimate FPS Boost & Tracker

Hiển thị FPS, nút bật tắt Boost siêu mượt, ép xung WebGL cho Minefun.io

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Minefun Ultimate FPS Boost & Tracker
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Hiển thị FPS, nút bật tắt Boost siêu mượt, ép xung WebGL cho Minefun.io
// @author       You
// @match        *://minefun.io/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. ÉP XUNG WEBGL TỪ LÕI (Chạy ngay khi load trang) ---
    const originalGetContext = HTMLCanvasElement.prototype.getContext;
    HTMLCanvasElement.prototype.getContext = function(type, options) {
        if (type === 'webgl' || type === 'webgl2') {
            options = options || {};
            options.antialias = false; // Tắt khử răng cưa (Giảm lag cực mạnh)
            options.preserveDrawingBuffer = false;
            options.powerPreference = "high-performance"; // Ép card đồ họa chạy tối đa
            options.desynchronized = true; // Giảm độ trễ chuyển động
            options.alpha = false; 
        }
        return originalContext = originalGetContext.call(this, type, options);
    };

    let isBoosted = false;
    let currentFps = 0;
    const originalPixelRatio = window.devicePixelRatio;

    // --- 2. TẠO GIAO DIỆN NÚT BẬT/TẮT VÀ HIỂN THỊ FPS ---
    window.addEventListener('DOMContentLoaded', () => {
        const uiContainer = document.createElement('div');
        uiContainer.style.position = 'fixed';
        uiContainer.style.top = '10px';
        uiContainer.style.left = '10px';
        uiContainer.style.zIndex = '999999';
        uiContainer.style.display = 'flex';
        uiContainer.style.gap = '10px';
        uiContainer.style.alignItems = 'center';
        uiContainer.style.fontFamily = 'Arial, sans-serif';

        // Bảng FPS
        const fpsDisplay = document.createElement('div');
        fpsDisplay.style.background = 'rgba(0, 0, 0, 0.7)';
        fpsDisplay.style.color = '#00FF00'; // Màu xanh lá mượt mà
        fpsDisplay.style.padding = '5px 10px';
        fpsDisplay.style.borderRadius = '5px';
        fpsDisplay.style.fontWeight = 'bold';
        fpsDisplay.style.fontSize = '16px';
        fpsDisplay.innerText = 'FPS: 0';

        // Nút Boost
        const boostBtn = document.createElement('button');
        boostBtn.innerText = 'BẬT BOOST (OFF)';
        boostBtn.style.background = '#ff4757';
        boostBtn.style.color = 'white';
        boostBtn.style.border = 'none';
        boostBtn.style.padding = '5px 10px';
        boostBtn.style.borderRadius = '5px';
        boostBtn.style.cursor = 'pointer';
        boostBtn.style.fontWeight = 'bold';

        boostBtn.addEventListener('click', toggleBoost);

        uiContainer.appendChild(fpsDisplay);
        uiContainer.appendChild(boostBtn);
        document.body.appendChild(uiContainer);

        // --- 3. LOGIC TÍNH TOÁN FPS ---
        let lastTime = performance.now();
        let frames = 0;

        function updateFPS() {
            let now = performance.now();
            frames++;
            if (now >= lastTime + 1000) {
                currentFps = Math.round((frames * 1000) / (now - lastTime));
                fpsDisplay.innerText = `FPS: ${currentFps}`;
                
                // Đổi màu FPS theo độ mượt
                if (currentFps >= 60) fpsDisplay.style.color = '#00FF00'; // Xanh lá = Ngon
                else if (currentFps >= 30) fpsDisplay.style.color = '#ffa502'; // Cam = Tạm
                else fpsDisplay.style.color = '#ff4757'; // Đỏ = Lag

                frames = 0;
                lastTime = now;
            }
            requestAnimationFrame(updateFPS);
        }
        requestAnimationFrame(updateFPS);

        // --- 4. LOGIC BOOST MƯỢT MÀ ---
        function toggleBoost() {
            isBoosted = !isBoosted;
            if (isBoosted) {
                boostBtn.innerText = '🔥 BOOST ĐANG BẬT';
                boostBtn.style.background = '#2ed573';
                
                // Giảm độ phân giải nội bộ của game để tăng FPS đột biến
                Object.defineProperty(window, 'devicePixelRatio', {
                    get: function() { return 0.5; } // Hạ tỷ lệ điểm ảnh xuống một nửa
                });

                // Ép Canvas render mượt hơn
                document.querySelectorAll('canvas').forEach(canvas => {
                    canvas.style.imageRendering = 'pixelated';
                });
            } else {
                boostBtn.innerText = 'BẬT BOOST (OFF)';
                boostBtn.style.background = '#ff4757';
                
                // Trả về bình thường
                Object.defineProperty(window, 'devicePixelRatio', {
                    get: function() { return originalPixelRatio; }
                });

                document.querySelectorAll('canvas').forEach(canvas => {
                    canvas.style.imageRendering = 'auto';
                });
            }
            
            // Cập nhật lại kích thước cửa sổ để game nhận diện setting mới
            window.dispatchEvent(new Event('resize'));
        }
    });
})();