☰

Tunnel Rush Slow-Motion (Poki)

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
        }
    });
})();