☰

Tunnel Rush Slow-Motion (Poki)

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

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

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

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