Cryzen.io FPS Booster (Dynamic Resolution)

Optimize settings for better FPS in Cryzen.io with dynamic resolution scaling and memory leak fixes.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Cryzen.io FPS Booster (Dynamic Resolution)
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Optimize settings for better FPS in Cryzen.io with dynamic resolution scaling and memory leak fixes.
// @author       Your Name
// @match        *://cryzen.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let optimizationEnabled = true;
    let lowResolutionEnabled = false; // Flag to track if low resolution mode is active
    const FPS_THRESHOLD_LOW = 30;  // Reduce resolution if FPS drops below this
    const FPS_THRESHOLD_HIGH = 50; // Restore full resolution if FPS rises above this
    const OPTIMIZATION_INTERVAL = 3000; // Apply optimizations every 3 seconds

    let lastCheck = performance.now();
    let fps = 0;
    let lastTime = performance.now();
    
    const fpsDisplay = document.createElement('div');
    fpsDisplay.style.position = 'fixed';
    fpsDisplay.style.top = '10px';
    fpsDisplay.style.right = '10px';
    fpsDisplay.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
    fpsDisplay.style.color = 'white';
    fpsDisplay.style.padding = '5px';
    fpsDisplay.style.zIndex = '1000';
    document.body.appendChild(fpsDisplay);

    function adjustCanvasResolution(scaleFactor) {
        const canvas = document.querySelector('canvas');
        if (canvas) {
            const devicePixelRatio = window.devicePixelRatio * scaleFactor;
            canvas.width = window.innerWidth * devicePixelRatio;
            canvas.height = window.innerHeight * devicePixelRatio;
            console.log(`Canvas resolution adjusted. Scale Factor: ${scaleFactor}`);
        }
    }

    function optimizeGame() {
        if (!optimizationEnabled) return;

        // Hide high-detail elements
        document.querySelectorAll('.high-detail').forEach(element => {
            element.style.display = 'none';
        });
    }

    function monitorFPS() {
        setInterval(() => {
            const now = performance.now();
            const elapsedTime = now - lastTime;

            fpsDisplay.innerText = `FPS: ${fps}`;
            
            // Dynamic Resolution Adjustment
            if (fps < FPS_THRESHOLD_LOW && !lowResolutionEnabled) {
                lowResolutionEnabled = true;
                adjustCanvasResolution(0.5); // Reduce resolution
            } else if (fps > FPS_THRESHOLD_HIGH && lowResolutionEnabled) {
                lowResolutionEnabled = false;
                adjustCanvasResolution(1); // Restore full resolution
            }

            fps = 0;
            lastTime = now;
        }, 1000);
    }

    function countFrames() {
        fps++;
        requestAnimationFrame(countFrames);
    }

    function throttleOptimization() {
        setInterval(() => {
            optimizeGame();
        }, OPTIMIZATION_INTERVAL);
    }

    countFrames();
    monitorFPS();
    throttleOptimization();
})();