JavaScript Code Plays Google Dinosaur/T-Rex Game Automatically

Have you ever played Google Dinosaur/T-Rex Game in chrome? I hope you did, whenever your internet goes down.

To be honest, it’s a really addicting game that keeps you busy while Google Chrome continuously tries (behind the scenes) to get the connection back on your computer, tablet or even mobile.

The sole purpose of writing this article is to give you some JavaScript code that automatically plays Google Dinosaur/T-Rex Game for you. So, you just have to press the play button and relax!

Below is the step by step process on how you can automate Google Dinosaur/T-Rex Game Using JavaScript.

Step 1:-

Open Google Chrome in your computer.

Step 2:-

Now enter chrome://dino/ in the URL address bar and press “Enter”. Or simply disconnect your internet and try to visit any website. After performing this step you will see the Google Dinosaur/T-Rex Game.

Step 3:-

Press “F12” on your keyboard. It will open a new window/box on your screen. You need to click the “Console” button/tab on this new window.

Step 4:-

It’s time to add some code here.

Just copy the code given below and paste it inside the “Console” window. After that press “Enter”.

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);

Screenshot

Step 5:-

Start the game by pressing “Space” or “Up Arrow” key.


Now its time for the code to show some magic.

Basically after applying the code our dinosaur will be smart enough to do auto jumps or lay down according to the situation.

A great thing about this code is that it will work correctly during night phase also.

I hope you enjoyed this blog post. Feel free to leave your suggestions or reactions in the comments down below.

By the way, isn’t it interesting enough to share it with your friends and family members?

Furqan

Well. I've been working for the past three years as a web designer and developer. I have successfully created websites for small to medium sized companies as part of my freelance career. During that time I've also completed my bachelor's in Information Technology.

View Comments

Recent Posts

MiniMax-M1 vs GPT-4o vs Claude 3 Opus vs LLaMA 3 Benchmarks

MiniMax-M1 is a new open-weight large language model (456 B parameters, ~46 B active) built with hybrid…

June 22, 2025

How to Use Husky with npm to Manage Git Hooks

Managing Git hooks manually can quickly become tedious and error-prone—especially in fast-moving JavaScript or Node.js…

June 22, 2025

How to Use Lefthook with npm to Manage Git Hooks

Git hooks help teams enforce code quality by automating checks at key stages like commits…

June 22, 2025

Lefthook vs Husky: Which Git Hooks Tool is Better? [2025]

Choosing the right Git hooks manager directly impacts code quality, developer experience, and CI/CD performance.…

June 22, 2025

Llama 3.1 vs GPT-4 Benchmarks

We evaluated the performance of Llama 3.1 vs GPT-4 models on over 150 benchmark datasets…

July 24, 2024

Transforming Manufacturing with Industrial IoT Solutions and Machine Learning

The manufacturing industry is undergoing a significant transformation with the advent of Industrial IoT Solutions.…

July 6, 2024