☰

Tunnel Rush Slow-Motion (Poki)

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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