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 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 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 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);
})();