Timer Accelerator (Testing & Debugging Tool)

Speeds up client-side timers for development, testing, and educational purposes.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Timer Accelerator (Testing & Debugging Tool)
// @namespace    https://github.com/hgcfkuyfliyfl/
// @version      2.1
// @description  Speeds up client-side timers for development, testing, and educational purposes.
// @author       Wisdom Ng'oma
// @license      MIT
// @match        *://*/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const SPEED_FACTOR = 100;
    let startTime = Date.now();
    let performanceStart = performance.now();

    // Override Date.now
    const originalDateNow = Date.now;
    Date.now = function() {
        return startTime + (originalDateNow() - startTime) * SPEED_FACTOR;
    };

    // Override performance.now
    const originalPerformanceNow = performance.now;
    performance.now = function() {
        return performanceStart + (originalPerformanceNow() - performanceStart) * SPEED_FACTOR;
    };

    // Override timers
    const originalSetTimeout = window.setTimeout;
    const originalSetInterval = window.setInterval;

    window.setTimeout = function(callback, delay, ...args) {
        return originalSetTimeout(callback, Math.max(1, delay / SPEED_FACTOR), ...args);
    };

    window.setInterval = function(callback, delay, ...args) {
        return originalSetInterval(callback, Math.max(1, delay / SPEED_FACTOR), ...args);
    };

    console.log(`Time Accelerator Active: ${SPEED_FACTOR}x`);
})();