☰

Tunnel Rush Slow-Motion (Poki)

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

您需要先安裝使用者腳本管理器擴展,如 Tampermonkey、Greasemonkey 或 Violentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 Tampermonkey 或 Violentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 Tampermonkey或 Violentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 Tampermonkey或 Userscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 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);
        }
    });
})();