AutoPlay Chrome Dinosaur Game with JavaScript

I’m sure you played Chrome dino/ T-Rex game whenever your internet goes out. Sometimes it become so addictive right. But as a programmer we always find hacks or crack to gain more score. So, today using simple JavaScript code we automate the chrome’s dino run game.

Code 1

Using this code dino ignores the obstacles. Means dino will not jump. It just ignores it or you can say just go pass through it.

  • Open the dinosaur game in chrome, make sure your internet is not connected.
  • Right-click anywhere on the page and select Inspect.
  • Go to the Console tab. This is where we will enter the commands to tweak the game.

Immortality

Just paste the following code in console tab and hit enter.

Runner.instance_.gameOver=()=>{}

And hit space and arrow key to start game. Now you can see dino ignore the obstacles.

Tweaking Speed

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

Runner.instance_.setSpeed(1000)

explore more functions.

Code 2

Dino will also ignore the obstacles with this code but in this code, the dino will jump and down itself. This will looks more natural then previous.

Just open console tab and paste following code.

function keyDown(e) {
    Podium = {};
    var n = document.createEvent("KeyboardEvent");
    Object.defineProperty(n, "keyCode", {
        get: function () {
            return this.keyCodeVal;
        },
    }),
        n.initKeyboardEvent ? n.initKeyboardEvent("keydown", !0, !0, document.defaultView, e, e, "", "", !1, "") : n.initKeyEvent("keydown", !0, !0, document.defaultView, !1, !1, !1, !1, e, 0),
        (n.keyCodeVal = e),
        document.body.dispatchEvent(n);
}
function keyUp(e) {
    Podium = {};
    var n = document.createEvent("KeyboardEvent");
    Object.defineProperty(n, "keyCode", {
        get: function () {
            return this.keyCodeVal;
        },
    }),
        n.initKeyboardEvent ? n.initKeyboardEvent("keyup", !0, !0, document.defaultView, e, e, "", "", !1, "") : n.initKeyEvent("keyup", !0, !0, document.defaultView, !1, !1, !1, !1, e, 0),
        (n.keyCodeVal = e),
        document.body.dispatchEvent(n);
}
setInterval(function () {
    Runner.instance_.horizon.obstacles.length > 0 &&
        (Runner.instance_.horizon.obstacles[0].xPos < 25 * Runner.instance_.currentSpeed - Runner.instance_.horizon.obstacles[0].width / 2 && Runner.instance_.horizon.obstacles[0].yPos > 75 && (keyUp(40), keyDown(38)),
        Runner.instance_.horizon.obstacles[0].xPos < 30 * Runner.instance_.currentSpeed - Runner.instance_.horizon.obstacles[0].width / 2 && Runner.instance_.horizon.obstacles[0].yPos <= 75 && keyDown(40));
}, 5);

Start the game by pressing Space or Up Arrow key.

Hope you like this automation.

Also check,

Support CodeSnail

If you appreciate my work, or if it has helped you along your journey. It would mean a lot to me if you could write a message on my wall and share a cup of coffee (or tea) with me.

Buy Me A Coffee

Related Articles

1 thought on “AutoPlay Chrome Dinosaur Game with JavaScript ”

Leave a Comment

Copy link
Powered by Social Snap