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

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

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

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

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

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

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

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

Advertisement:

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

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

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

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

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

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

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

Advertisement:

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