☰

Tunnel Rush Slow-Motion (Poki)

Druk op S om het spel trager of weer normaal te zetten

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        Tunnel Rush Slow-Motion (Poki)
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @grant       none
// @version     1.2
// @run-at      document-start
// @description Druk op S om het spel trager of weer normaal te zetten
// ==/UserScript==

(function() {
    'use strict';

    let speed = 1.0;
    let fakeTime = performance.now();
    let lastRealTime = fakeTime;

    // 1. Vertraag performance.now()
    const origPerfNow = performance.now.bind(performance);
    performance.now = function() {
        const realNow = origPerfNow();
        fakeTime += (realNow - lastRealTime) * speed;
        lastRealTime = realNow;
        return fakeTime;
    };

    // 2. Vertraag requestAnimationFrame (waar Unity vaak op draait)
    const origRAF = window.requestAnimationFrame.bind(window);
    window.requestAnimationFrame = function(callback) {
        return origRAF(function(timestamp) {
            callback(performance.now());
        });
    };

    function toggleSlowMo() {
        speed = (speed === 1.0) ? 0.35 : 1.0;
        const badge = document.getElementById('tr-speed-badge');
        if (badge) {
            badge.textContent = (speed === 1.0) ? 'Snelheid: Normaal (S)' : 'Snelheid: SLOW-MO (S)';
            badge.style.color = (speed === 1.0) ? '#00ff88' : '#ffaa00';
        }
    }

    // Luister naar de 'S'-toets (ook als je in het spel klikt)
    window.addEventListener('keydown', function(e) {
        if (e.key.toLowerCase() === 's') {
            toggleSlowMo();
        }
    }, true);

    // Maak een knop linksonder op de hoofdpagina
    window.addEventListener('DOMContentLoaded', function() {
        if (window.top === window.self && location.hostname.includes('poki')) {
            const badge = document.createElement('div');
            badge.id = 'tr-speed-badge';
            badge.textContent = 'Snelheid: Normaal (S)';
            badge.style.cssText = 'position:fixed; bottom:12px; left:12px; z-index:99999; background:rgba(0,0,0,0.85); color:#00ff88; padding:8px 14px; border-radius:8px; font-family:sans-serif; font-size:13px; font-weight:bold; cursor:pointer; border:1px solid #444;';
            badge.onclick = toggleSlowMo;
            document.body.appendChild(badge);
        }
    });
})();