Dino Game Hack with GUI and Speed Control

Hack the Chrome Dino game with a GUI to make the dinosaur invincible and control speed.

当前为 2024-07-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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