This JavaScript snippet allows you to override the Chrome Dinosaur game’s gameOver function so that the game only ends when a specific score is reached. Until that score is reached, the dinosaur can keep running without dying.
Made by ChatGPT.
- Set a target score at which the game will end.
- Prevents the game from ending prematurely.
- Works directly in the browser console.
- Open the Chrome Dinosaur game (
chrome://dino) in your browser. - Open Developer Tools:
- Press
F12orCtrl+Shift+I(Windows/Linux) - Press
Cmd+Option+I(Mac)
- Press
- Go to the Console tab.
- Copy and paste the following code:
// Set your target score here
const targetScore = 1000;
// Save the original gameOver function
const originalGameOver = Runner.instance_.gameOver;
// Override gameOver temporarily based on score
Runner.instance_.gameOver = function() {
const currentScore = Runner.instance_.distanceMeter.digits.join('') * 1; // convert digits to number
if (currentScore >= targetScore) {
// Call original gameOver if score reached
originalGameOver.call(this);
} else {
// Otherwise, do nothing (keep playing)
console.log(`Score ${currentScore} not yet ${targetScore}, keep playing!`);
}
};
Press Enter to activate the override.
Play the game! The game will only end when the target score is reached.
Customization
Change the value of targetScore to any number you want. Example:
javascript
Copy code
const targetScore = 5000; // Game ends at 5000 points
Notes
This code works only in the Chrome Dinosaur game.
It modifies the game’s internal gameOver function and may not work if the game version changes.
To restore normal behavior, refresh the page.
License
This project is released under the MIT License.
Credit: Code generated by ChatGPT.