Hack the Chrome Dino game with a GUI to make the dinosaur invincible and control speed.
当前为
// ==UserScript==
// @name Dino Game Hack with GUI and Speed Control
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Hack the Chrome Dino game with a GUI to make the dinosaur invincible and control speed.
// @author Phan Manh Hieu
// @match *://chromedino.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to override the gameOver function
function makeInvincible() {
Runner.prototype.gameOver = function() {};
}
// Function to reset the game to normal
function resetGame() {
location.reload();
}
// Function to adjust speed
function setSpeed(value) {
Runner.instance_.setSpeed(value);
}
// Create GUI
function createGUI() {
const guiContainer = document.createElement('div');
guiContainer.style.position = 'fixed';
guiContainer.style.top = '10px';
guiContainer.style.right = '10px';
guiContainer.style.zIndex = '1000';
guiContainer.style.backgroundColor = '#fff';
guiContainer.style.border = '1px solid #ccc';
guiContainer.style.padding = '10px';
guiContainer.style.borderRadius = '5px';
guiContainer.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
guiContainer.style.display = 'flex';
guiContainer.style.flexDirection = 'column';
guiContainer.style.gap = '10px';
const invincibleButton = document.createElement('button');
invincibleButton.textContent = 'Invincible Mode';
invincibleButton.onclick = makeInvincible;
guiContainer.appendChild(invincibleButton);
const resetButton = document.createElement('button');
resetButton.textContent = 'Reset Game';
resetButton.onclick = resetGame;
guiContainer.appendChild(resetButton);
const speedLabel = document.createElement('label');
speedLabel.textContent = 'Set Speed:';
guiContainer.appendChild(speedLabel);
const speedSlider = document.createElement('input');
speedSlider.type = 'range';
speedSlider.min = '1';
speedSlider.max = '100';
speedSlider.value = '10';
speedSlider.oninput = function() {
setSpeed(speedSlider.value);
};
guiContainer.appendChild(speedSlider);
document.body.appendChild(guiContainer);
}
// Wait for the game to load
window.addEventListener('load', createGUI);
})();