Browser Game Slowdown

Universal Pointer Lock Toggle

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Browser Game Slowdown
// description  slow down browser games
// @match        *://*/*
// @grant        none
// @version 0.0.1.20260306235559
// @namespace https://greasyfork.org/users/1547770
// @description Universal Pointer Lock Toggle
// ==/UserScript==

(function() {
    let slowdown = 4; // 2 = half speed, 4 = quarter speed, 8 = super slow
    let frame = 0;

    const originalRAF = window.requestAnimationFrame;

    window.requestAnimationFrame = function(callback) {
        frame++;
        if (frame % slowdown === 0) {
            return originalRAF.call(window, callback);
        }
    };

    // Press "L" to toggle slowdown on/off
    let enabled = true;
    document.addEventListener("keydown", e => {
        if (e.key.toLowerCase() === "l") {
            enabled = !enabled;
            window.requestAnimationFrame = enabled
                ? function(callback) {
                    frame++;
                    if (frame % slowdown === 0) {
                        return originalRAF.call(window, callback);
                    }
                }
                : originalRAF;
        }
    });
})();