Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created June 25, 2026 08:01
Show Gist options
  • Select an option

  • Save Shilo/af19dabd4d438ae8f40516b83cea7b3d to your computer and use it in GitHub Desktop.

Select an option

Save Shilo/af19dabd4d438ae8f40516b83cea7b3d to your computer and use it in GitHub Desktop.
Web game/app speed modifier. [Use responsibility, dont cheat multiplayer games]
window.__setGameSpeed = (speedMultiplier) => {
window.__requestAnimationFrame ??= window.requestAnimationFrame.bind(window);
const startTime = window.performance.now();
window.requestAnimationFrame = function (callback) {
return window.__requestAnimationFrame(function (timestamp) {
const elapsedTime = timestamp - startTime;
const fakeTimestamp = startTime + elapsedTime * speedMultiplier;
callback(fakeTimestamp);
});
};
console.log(`Game speed set to ${speedMultiplier}x.`);
};
@Shilo

Shilo commented Jun 25, 2026

Copy link
Copy Markdown
Author

Example:

__setGameSpeed(2);
__setGameSpeed(1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment