Git游戏

您现在的位置是:首页 > 攻略大全 > 黑科技

黑科技

一万亿免费抽卡加速脚本

2025-02-19 黑科技4283
欢迎加入黑科技QQ群:934074044 交流,请勿在其它群炫耀修改成果,谢谢合作!
// ==UserScript==// @name One Trillion Free Draws Accelerator// @namespace http://tampermonkey.net/// @version 1.8// @description 加速游戏 https://gityxs.github.io/one-trillion-free-draws/ 并提供...

// ==UserScript==

// @name         One Trillion Free Draws Accelerator

// @namespace    http://tampermonkey.net/

// @version      1.8

// @description  加速游戏 https://gityxs.github.io/one-trillion-free-draws/ 并提供用户控制界面

// @author       YourName

// @match        https://gityxs.github.io/one-trillion-free-draws/*

// @grant        none

// @run-at       document-end

// ==/UserScript==


(function() {

    'use strict';


    // 初始加速倍率

    let SPEED_MULTIPLIER = 5;


    // 安全速度范围

    const SAFE_SPEED_RANGE = { min: 0.1, max: 20.0 };


    // 备份原始 API

    const originalAPIs = {

        raf: window.requestAnimationFrame.bind(window),

        performanceNow: performance.now.bind(performance),

        DateNow: Date.now

    };


    // 劫持 performance.now

    function overridePerformanceNow() {

        Object.defineProperty(performance, 'now', {

            value: () => originalAPIs.performanceNow() * SPEED_MULTIPLIER,

            configurable: true,

            writable: false

        });

        console.log('[引擎] performance.now 已劫持');

    }


    // 劫持 requestAnimationFrame

    function overrideRequestAnimationFrame() {

        window.requestAnimationFrame = (callback) => {

            return originalAPIs.raf((timestamp) => {

                callback(timestamp * SPEED_MULTIPLIER);

            });

        };

        console.log('[引擎] requestAnimationFrame 已劫持');

    }


    // 同步时间源

    function syncTimeSources() {

        const baseTime = Date.now();

        Date.now = () => baseTime + (performance.now() - baseTime);

        console.log('[引擎] 时间源已同步');

    }


    // 恢复原始 API

    function restoreOriginalAPIs() {

        Object.defineProperty(performance, 'now', {

            value: originalAPIs.performanceNow,

            configurable: true

        });

        window.requestAnimationFrame = originalAPIs.raf;

        Date.now = originalAPIs.DateNow;

        console.log('[引擎] 原始 API 已恢复');

    }


    // 创建用户控制界面

    function createControlUI() {

        // 检查是否已经存在控制界面,避免重复创建

        if (document.getElementById('game-accelerator-ui')) {

            return;

        }


        // 创建一个容器 div

        const controlDiv = document.createElement('div');

        controlDiv.id = 'game-accelerator-ui';

        controlDiv.style.position = 'fixed';

        controlDiv.style.bottom = '40px';

        controlDiv.style.left = '25px';

        controlDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';

        controlDiv.style.color = 'white';

        controlDiv.style.padding = '10px';

        controlDiv.style.borderRadius = '5px';

        controlDiv.style.zIndex = '9999';

        controlDiv.style.fontFamily = 'Arial, sans-serif';


        // 创建加速倍率显示

        const speedDisplay = document.createElement('div');

        speedDisplay.id = 'speed-display';

        speedDisplay.textContent = `Speed: ${SPEED_MULTIPLIER}x`;

        speedDisplay.style.marginBottom = '10px';


        // 创建加速倍率滑块

        const speedSlider = document.createElement('input');

        speedSlider.type = 'range';

        speedSlider.min = SAFE_SPEED_RANGE.min;

        speedSlider.max = SAFE_SPEED_RANGE.max;

        speedSlider.step = '0.1';

        speedSlider.value = SPEED_MULTIPLIER;

        speedSlider.style.width = '150px';


        // 监听滑块变化事件

        speedSlider.addEventListener('input', function() {

            SPEED_MULTIPLIER = parseFloat(speedSlider.value);

            speedDisplay.textContent = `Speed: ${SPEED_MULTIPLIER}x`;

            console.log(`[面板] Game speed changed to ${SPEED_MULTIPLIER}x`);

        });


        // 将元素添加到控制界面

        controlDiv.appendChild(speedDisplay);

        controlDiv.appendChild(speedSlider);


        // 将控制界面添加到页面中

        document.body.appendChild(controlDiv);

    }


    // 初始化加速引擎

    function initializeAccelerationEngine() {

        try {

            overridePerformanceNow();

            overrideRequestAnimationFrame();

            syncTimeSources();

            console.log('[引擎] 加速引擎已激活');

        } catch (error) {

            console.error('[引擎] 初始化失败:', error);

            setTimeout(initializeAccelerationEngine, 1500); // 重试初始化

        }

    }


    // 等待页面加载完成后再初始化

    function waitForPageLoad() {

        if (document.readyState === 'complete') {

            initializeAccelerationEngine();

            createControlUI();

        } else {

            window.addEventListener('load', () => {

                initializeAccelerationEngine();

                createControlUI();

            });

        }

    }


    // 确保脚本只运行一次

    if (!window.hasRunAccelerator) {

        window.hasRunAccelerator = true;

        waitForPageLoad();


        // 页面卸载时恢复原始 API

        window.addEventListener('beforeunload', () => {

            restoreOriginalAPIs();

        });

    }

})();


文章评论

共有0条评论来说两句吧...