Universal HTML5 Speed Hack (speed up every site)

change the speed of the site. works on every site (performance.now, Date.now, setTimeout, requestAnimationFrame)

Versión del día 27/7/2025. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name         Universal HTML5 Speed Hack (speed up every site)
// @namespace    https://chat.openai.com/
// @version      1.11
// @description  change the speed of the site. works on every site (performance.now, Date.now, setTimeout, requestAnimationFrame)
// @author       kuba; i did use chatgpt for this though
// @match        *://*/*
// @grant        none
// @run-at       document-end
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    let speed = 1.0;

    function injectSpeedHack(win) {
        try {
            const script = win.document.createElement('script');
            script.textContent = `(() => {
                const realPerfNow = performance.now.bind(performance);
                const realDateNow = Date.now;
                const realSetTimeout = window.setTimeout;
                const realRAF = window.requestAnimationFrame;
                const start = realPerfNow();
                window.__speedHack = ${speed};

                performance.now = () => start + (realPerfNow() - start) * window.__speedHack;
                Date.now = () => realDateNow() * window.__speedHack;
                window.setTimeout = (fn, delay, ...args) => realSetTimeout(fn, delay / window.__speedHack, ...args);
                window.requestAnimationFrame = (cb) => realRAF(t => cb(t * window.__speedHack));

                console.log('[SpeedHack] Active at ' + window.__speedHack + 'x');
            })();`;
            win.document.documentElement.appendChild(script);
        } catch (e) {
            console.warn('[SpeedHack] Injection failed:', e);
        }
    }

    function updateSpeed(newSpeed) {
        speed = newSpeed;
        const win = window;
        win.__speedHack = speed;
        injectSpeedHack(win);
        for (const frame of document.querySelectorAll("iframe")) {
            try {
                frame.contentWindow.__speedHack = speed;
                injectSpeedHack(frame.contentWindow);
            } catch (e) {
                // Ignore cross-origin
            }
        }
    }

    function addSpeedControlUI() {
        const ui = document.createElement("div");
        ui.style.position = "fixed";
        ui.style.top = "10px";
        ui.style.right = "10px";
        ui.style.padding = "10px";
        ui.style.background = "rgba(0,0,0,0.7)";
        ui.style.color = "white";
        ui.style.zIndex = 999999;
        ui.style.borderRadius = "8px";
        ui.style.fontSize = "14px";
        ui.style.fontFamily = "sans-serif";
        ui.innerHTML = `
            <label style="display:block;">Speed: <span id="speedVal">${speed.toFixed(2)}x</span></label>
            <input type="range" id="speedSlider" min="0.1" max="5" value="${speed}" step="0.1" style="width:150px;">
        `;
        document.body.appendChild(ui);

        const slider = ui.querySelector("#speedSlider");
        const valText = ui.querySelector("#speedVal");

        slider.addEventListener("input", () => {
            const val = parseFloat(slider.value);
            valText.textContent = val.toFixed(2) + "x";
            updateSpeed(val);
        });
    }

    // Initialize on current window and all same-origin iframes
    function initialize() {
        injectSpeedHack(window);
        for (const frame of document.querySelectorAll("iframe")) {
            try {
                injectSpeedHack(frame.contentWindow);
            } catch (e) {
                // Cross-origin iframe – ignore
            }
        }
        addSpeedControlUI();
    }

    // Wait a bit for page to stabilize
    setTimeout(initialize, 500);
})();