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

  1. // ==UserScript==
  2. // @name Dino Game Hack with GUI and Speed Control
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Hack the Chrome Dino game with a GUI to make the dinosaur invincible and control speed.
  6. // @author Phan Manh Hieu
  7. // @match *://chromedino.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to override the gameOver function
  15. function makeInvincible() {
  16. Runner.prototype.gameOver = function() {};
  17. }
  18.  
  19. // Function to reset the game to normal
  20. function resetGame() {
  21. location.reload();
  22. }
  23.  
  24. // Function to adjust speed
  25. function setSpeed(value) {
  26. Runner.instance_.setSpeed(value);
  27. }
  28.  
  29. // Create GUI
  30. function createGUI() {
  31. const guiContainer = document.createElement('div');
  32. guiContainer.style.position = 'fixed';
  33. guiContainer.style.top = '10px';
  34. guiContainer.style.right = '10px';
  35. guiContainer.style.zIndex = '1000';
  36. guiContainer.style.backgroundColor = '#fff';
  37. guiContainer.style.border = '1px solid #ccc';
  38. guiContainer.style.padding = '10px';
  39. guiContainer.style.borderRadius = '5px';
  40. guiContainer.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  41. guiContainer.style.display = 'flex';
  42. guiContainer.style.flexDirection = 'column';
  43. guiContainer.style.gap = '10px';
  44.  
  45. const invincibleButton = document.createElement('button');
  46. invincibleButton.textContent = 'Invincible Mode';
  47. invincibleButton.onclick = makeInvincible;
  48. guiContainer.appendChild(invincibleButton);
  49.  
  50. const resetButton = document.createElement('button');
  51. resetButton.textContent = 'Reset Game';
  52. resetButton.onclick = resetGame;
  53. guiContainer.appendChild(resetButton);
  54.  
  55. const speedLabel = document.createElement('label');
  56. speedLabel.textContent = 'Set Speed:';
  57. guiContainer.appendChild(speedLabel);
  58.  
  59. const speedSlider = document.createElement('input');
  60. speedSlider.type = 'range';
  61. speedSlider.min = '1';
  62. speedSlider.max = '100';
  63. speedSlider.value = '10';
  64. speedSlider.oninput = function() {
  65. setSpeed(speedSlider.value);
  66. };
  67. guiContainer.appendChild(speedSlider);
  68.  
  69. document.body.appendChild(guiContainer);
  70. }
  71.  
  72. // Wait for the game to load
  73. window.addEventListener('load', createGUI);
  74. })();