Please Wait While we Load Website For You😊
Get TikTok Likes in Just 03 Pkr/- at Snakify SMM Store BUY NOW!
Posts

Hacking the Chrome Dino Game

Hack the Chrome Dino Game: Ultimate Guide with Code Examples

Hack the Chrome Dino Game: Ultimate Guide with Code Examples

Google Chrome includes an endless runner Dinosaur (T-Rex) game that 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.

Not too important if you’re not a programmer, but this game is written in JavaScript, and fortunately for us, the class and object are globally exposed. Due to JavaScript’s dynamic nature, we can override functions on the class to change the functionality. We can do all this from the Chrome console.

Playing the Game

Just in case this is your first time seeing this game, it is fairly straightforward to play:

  • 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 the next 100 points.

Open Chrome Console

To start hacking the game, follow these steps:

  1. Make sure you are on the No Internet Connection page.
  2. Right-click anywhere on the page and select Inspect.
  3. Go to the Console tab. This is where we will enter the commands to tweak the game.

After every command, press Enter. All the commands are case-sensitive. If you see undefined after entering a command correctly, don’t worry—that is expected (for those who want to know more, it is the return type of the function we called).

Immortality (God Mode)

Follow the commands to make the Dino un-killable:

// Store the original game over function
var original = Runner.prototype.gameOver;

// Make the game over function empty
Runner.prototype.gameOver = function(){};
    

Code copied to clipboard!

How to Stop?

When you want to stop the game, revert back to the original game over function. This would only work if you had entered both commands in order for Immortality.

Runner.prototype.gameOver = original;
    

Code copied to clipboard!

Tweaking Speed

Type the following command in the Console and press Enter. You can use any other speed in place of 1000.

Runner.instance_.setSpeed(1000);
    

Code copied to clipboard!

To go back to normal speed:

Runner.instance_.setSpeed(10);
    

Code copied to clipboard!

Setting the Current Score

Let’s set the score to 12345. You can set any other score less than 99999. The current score is reset on game over.

Runner.instance_.distanceRan = 12345 / Runner.instance_.distanceMeter.config.COEFFICIENT;
    

Code copied to clipboard!

Jumping Height

You can control how high the Dino jumps by using the below function. Adjust the value as necessary.

Runner.instance_.tRex.setJumpVelocity(10);
    

Code copied to clipboard!

Walk in Air

Make the Dino walk in mid-air by disabling gravity:

Runner.instance_.tRex.groundYPos = 0;
    

Code copied to clipboard!

To bring the Dino back to the ground:

Runner.instance_.tRex.groundYPos = 93;
    

Code copied to clipboard!

Auto-play

This code periodically checks for the closest obstacle (cactus or pterodactyl) and then jumps or ducks based on the obstacle’s position.

function dispatchKey(type, key) {
    document.dispatchEvent(new KeyboardEvent(type, {keyCode: key}));
}
setInterval(function () {
    const KEY_CODE_SPACE_BAR = 32;
    const KEY_CODE_ARROW_DOWN = 40;
    const CANVAS_HEIGHT = Runner.instance_.dimensions.HEIGHT;
    const DINO_HEIGHT = Runner.instance_.tRex.config.HEIGHT;

    const obstacle = Runner.instance_.horizon.obstacles[0];
    const speed = Runner.instance_.currentSpeed;

    if (obstacle) {
        const w = obstacle.width;
        const x = obstacle.xPos; // measured from left of canvas
        const y = obstacle.yPos; // measured from top of canvas
        const yFromBottom = CANVAS_HEIGHT - y - obstacle.typeConfig.height;
        const isObstacleNearby = x < 25 * speed - w / 2;

        if (isObstacleNearby) {
            if (yFromBottom > DINO_HEIGHT) {
                // Pterodactyl going from above, do nothing
            } else if (y > CANVAS_HEIGHT / 2) {
                // Jump
                dispatchKey("keyup", KEY_CODE_ARROW_DOWN);
                dispatchKey("keydown", KEY_CODE_SPACE_BAR);
            } else {
                // Duck
                dispatchKey("keydown", KEY_CODE_ARROW_DOWN);
            }
        }
    }
}, Runner.instance_.msPerFrame);
    

Code copied to clipboard!

Conclusion

With these hacks, you can now take full control of the Chrome Dino game. Whether you want to make the game easier, more challenging, or just have some fun customizing it, these techniques will help you get there. Feel free to experiment with the code and see what other cool modifications you can come up with!

If you found this guide helpful, share it with your friends and let them enjoy the hacked Chrome Dino game too!

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Snakify Tech Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...