Dino Game Hack with GUI, Speed Control and Auto Jump

Hack the Chrome Dino game with a GUI to make the dinosaur invincible, control speed, and auto jump over obstacles.

目前為 2024-07-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Dino Game Hack with GUI, Speed Control and Auto Jump
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Hack the Chrome Dino game with a GUI to make the dinosaur invincible, control speed, and auto jump over obstacles.
// @author       Max Stewie
// @match        *://chromedino.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let autoJumpEnabled = false;

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

    // Function to enable auto jump
    function enableAutoJump() {
        autoJumpEnabled = true;
        autoJump();
    }

    // Function to disable auto jump
    function disableAutoJump() {
        autoJumpEnabled = false;
    }

    // Function to handle auto jump
    function autoJump() {
        if (autoJumpEnabled) {
            const obstacles = Runner.instance_.horizon.obstacles;
            if (obstacles.length > 0) {
                const obstacle = obstacles[0];
                const obstacleXPos = obstacle.xPos;
                const dinoXPos = Runner.instance_.tRex.xPos;
                const obstacleWidth = obstacle.width;

                // Jump when the obstacle is close to the dinosaur
                if (obstacleXPos < dinoXPos + obstacleWidth + 20 && obstacleXPos > dinoXPos) {
                    Runner.instance_.tRex.startJump(Runner.instance_.currentSpeed);
                }
            }
        }
        requestAnimationFrame(autoJump);
    }

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

        const autoJumpButton = document.createElement('button');
        autoJumpButton.textContent = 'Enable Auto Jump';
        autoJumpButton.onclick = function() {
            if (autoJumpEnabled) {
                disableAutoJump();
                autoJumpButton.textContent = 'Enable Auto Jump';
            } else {
                enableAutoJump();
                autoJumpButton.textContent = 'Disable Auto Jump';
            }
        };
        guiContainer.appendChild(autoJumpButton);

        document.body.appendChild(guiContainer);
    }

    // Wait for the game to load
    window.addEventListener('load', createGUI);
})();