Hack Chrome Dino Game - Ultimate Guide
Google Chrome includes an endless runner Dinosaur (T-Rex) game which appears in the absence of an internet connection. Let’s put on our hacker hats and try to mess with this game.
If you are unable to get the No Internet page, open a new tab and type chrome://dino
and press enter.
The game is written in JavaScript, and we can override functions to modify its behavior using the Chrome console.
Playing
- Space Bar / Up: Jump (also to start the game)
- Down: Duck (pterodactyls appear after 450 points)
- Alt: Pause
- The game enters a black background mode after every multiple of 700 points for 100 points.
Open Chrome Console
Right-click anywhere on the No Internet page, select Inspect, then go to the Console tab. Enter the commands below to tweak the game.
Enable Immortality (God Mode)
var original = Runner.prototype.gameOver; Runner.prototype.gameOver = function(){};
Change Game Speed
Runner.instance_.setSpeed(1000);
Set a Custom Score
Runner.instance_.distanceRan = 12345 / Runner.instance_.distanceMeter.config.COEFFICIENT;
Adjust Jumping Height
Runner.instance_.tRex.setJumpVelocity(10);
Walk in Air
Runner.instance_.tRex.groundYPos = 0;
To go back to the ground:
Runner.instance_.tRex.groundYPos = 93;
Auto-Play
function dispatchKey(type, key) { document.dispatchEvent(new KeyboardEvent(type, {keyCode: key})); } setInterval(function () { const SPACE_BAR = 32; const ARROW_DOWN = 40; const canvasHeight = Runner.instance_.dimensions.HEIGHT; const dinoHeight = Runner.instance_.tRex.config.HEIGHT; const obstacle = Runner.instance_.horizon.obstacles[0]; const speed = Runner.instance_.currentSpeed; if (obstacle) { const { width: w, xPos: x, yPos: y, typeConfig } = obstacle; const yFromBottom = canvasHeight - y - typeConfig.height; const isObstacleNearby = x < 25 * speed - w / 2; if (isObstacleNearby) { if (yFromBottom > dinoHeight) { return; // Pterodactyl flying above } if (y > canvasHeight / 2) { dispatchKey("keyup", ARROW_DOWN); dispatchKey("keydown", SPACE_BAR); } else { dispatchKey("keydown", ARROW_DOWN); } } } }, Runner.instance_.msPerFrame);