// ==UserScript== // @name Niro's GS Speedrun Timer // @namespace http://tampermonkey.net/ // @version 1.2 // @description Adds a MM:SS:msmsms timer to the top right of the screen with start, stop, reset controls, gold and WR splits // @author Niro ("nirokr" on Discord or @NiroGS on YouTube) // @match https://nirogs.github.io/GetawayShootout/* // @match https://htmlxm.github.io/h4/getaway-shootout/* // @match https://ubg44.github.io/GetawayShootout/* // @match https://watchdocumentaries.com/getaway-shootout-game/* // @match https://ducklife4.github.io/play/getaway-shootout.html // @match https://sites.google.com/site/thegamecompilation/getaway-shootout* // @match https://play.unity.com/en/games/f5c4d162-bae9-48ee-8238-1b7f039503ed/getaway-shootout* // @match https://www.twoplayergames.org/game/getaway-shootout* // @match https://tbg95.github.io/getaway-shootout/* // @match https://pizzaedition.one/g/getawayshootout/* // @match https://sites.google.com/view/iogames/getaway-shootout-io* // @match https://lablockedgames.com/getaway-shootout* // @match https://www.sites.google.com/site/unblockedgamestop/getaway-shootout* // @match https://coolunblockedgame.com/game/getaway-shootout/* // @match https://getawayshootout.io/* // @match https://eggy-car.github.io/detail/getaway-shootout.html // @match https://nirogs.github.io/NewGetawayShootout/* // @match https://narrow-one.github.io/n6/rooftop-snipers-2/* // @match https://www.friv.com/z/games/bipandpiplaserlab/index-x.html // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Prompt number of getaways and define stages let getawayStages = []; let numGetaways = parseInt(prompt("How many getaways? (3, 4, or 5)", "3")); if (numGetaways === 3) { getawayStages = ["Market", "Bus", "Train"]; } else if (numGetaways === 4) { getawayStages = ["Plane", "Market", "Bus", "Train"]; } else if (numGetaways === 5) { getawayStages = ["Train", "Office", "Market", "Bus", "Train"]; } else { alert("Invalid input! Defaulting to 3 getaways."); getawayStages = ["Market", "Bus", "Train"]; numGetaways = 3; } // WR/Goal splits for each Getaway count! Edit the times manually in milliseconds if you want! :D const goldTimes = { 3: [11600, 28266, 40300], // 3 Maps Splits 4: [13733, 35733, 61033, 72533], // 4 Maps Splits 5: [5233, 47766, 69766, 92366, 102666] // 5 Maps Splits }; // Create timer display let timerDiv = document.createElement('div'); Object.assign(timerDiv.style, { position: 'fixed', top: '15%', right: '10px', background: 'rgba(0,0,0,0.7)', color: 'white', padding: '5px 10px', fontSize: '18px', fontFamily: 'monospace', borderRadius: '2px', zIndex: '99999' }); timerDiv.innerText = '00:00.000'; document.body.appendChild(timerDiv); // Create splits display let splitsDiv = document.createElement('div'); Object.assign(splitsDiv.style, { position: 'fixed', top: 'calc(15% + 30px)', right: '10px', background: 'rgba(0,0,0,0.7)', color: 'white', padding: '5px 10px', fontSize: '14px', fontFamily: 'monospace', borderRadius: '2px', zIndex: '99999', textAlign: 'right' }); document.body.appendChild(splitsDiv); let startTime = 0, elapsedTime = 0, running = false, finished = false; let animationFrame, splits = Array(getawayStages.length).fill("--:--:---"); function updateTimer() { let now = performance.now() - startTime + elapsedTime; let m = Math.floor(now/60000).toString().padStart(2,'0'); let s = Math.floor((now%60000)/1000).toString().padStart(2,'0'); let ms = Math.floor(now%1000).toString().padStart(3,'0'); timerDiv.innerText = `${m}:${s}.${ms}`; if (running) animationFrame = requestAnimationFrame(updateTimer); } function updateSplits() { splitsDiv.innerHTML = splits.map((split, idx) => { const name = getawayStages[idx] || `Split ${idx+1}`; let color = 'white'; if (!split.includes('-')) { const [mm, ss, mss] = split.split(':').map(Number); const timeMs = mm*60000 + ss*1000 + mss; const gold = goldTimes[numGetaways]?.[idx]; if (gold !== undefined && timeMs < gold) color = 'gold'; } return `
${name}: ${split}
`; }).join(''); } updateSplits(); document.addEventListener('keydown', (e) => { if (e.key === '1' && !e.repeat && !finished) { if (!running) { startTime = performance.now(); running = true; updateTimer(); return; } const now = performance.now() - startTime + elapsedTime; const m = Math.floor(now/60000).toString().padStart(2,'0'); const s = Math.floor((now%60000)/1000).toString().padStart(2,'0'); const ms = Math.floor(now%1000).toString().padStart(3,'0'); const idx = splits.findIndex(t => t === "--:--:---"); if (idx !== -1 && running) { splits[idx] = `${m}:${s}:${ms}`; updateSplits(); if (idx === splits.length-1) { elapsedTime += performance.now() - startTime; running = false; finished = true; cancelAnimationFrame(animationFrame); // add a small finish buffer const final = elapsedTime + 2500; const fm = Math.floor(final/60000).toString().padStart(2,'0'); const fs = Math.floor((final%60000)/1000).toString().padStart(2,'0'); const fms = Math.floor(final%1000).toString().padStart(3,'0'); timerDiv.innerText = `${fm}:${fs}.${fms}`; } } } else if (e.key === '2' && running) { elapsedTime += performance.now() - startTime; running = false; cancelAnimationFrame(animationFrame); } else if (e.key === '0') { running = false; finished = false; elapsedTime = 0; splits = Array(getawayStages.length).fill("--:--:---"); timerDiv.innerText = '00:00.000'; updateSplits(); cancelAnimationFrame(animationFrame); } }); window.addEventListener('beforeunload', (e) => { e.preventDefault(); e.returnValue = 'Are you sure you want to leave? Your timer progress will be lost.'; }); })();