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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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'));
        }
    });
})();