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

  1. // ==UserScript==
  2. // @name Dino Game Hack with GUI, Speed Control and Auto Jump
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.5
  5. // @description Hack the Chrome Dino game with a GUI to make the dinosaur invincible, control speed, and auto jump over obstacles.
  6. // @author Max Stewie
  7. // @match *://chromedino.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. let autoJumpEnabled = false;
  15.  
  16. // Function to override the gameOver function
  17. function makeInvincible() {
  18. Runner.prototype.gameOver = function() {};
  19. }
  20.  
  21. // Function to reset the game to normal
  22. function resetGame() {
  23. location.reload();
  24. }
  25.  
  26. // Function to adjust speed
  27. function setSpeed(value) {
  28. Runner.instance_.setSpeed(value);
  29. }
  30.  
  31. // Function to enable auto jump
  32. function enableAutoJump() {
  33. autoJumpEnabled = true;
  34. autoJump();
  35. }
  36.  
  37. // Function to disable auto jump
  38. function disableAutoJump() {
  39. autoJumpEnabled = false;
  40. }
  41.  
  42. // Function to handle auto jump
  43. function autoJump() {
  44. if (autoJumpEnabled) {
  45. const obstacles = Runner.instance_.horizon.obstacles;
  46. if (obstacles.length > 0) {
  47. const obstacle = obstacles[0];
  48. const obstacleXPos = obstacle.xPos;
  49. const dinoXPos = Runner.instance_.tRex.xPos;
  50. const obstacleWidth = obstacle.width;
  51.  
  52. // Jump when the obstacle is close to the dinosaur
  53. if (obstacleXPos < dinoXPos + obstacleWidth + 20 && obstacleXPos > dinoXPos) {
  54. Runner.instance_.tRex.startJump(Runner.instance_.currentSpeed);
  55. }
  56. }
  57. }
  58. requestAnimationFrame(autoJump);
  59. }
  60.  
  61. // Create GUI
  62. function createGUI() {
  63. const guiContainer = document.createElement('div');
  64. guiContainer.style.position = 'fixed';
  65. guiContainer.style.top = '10px';
  66. guiContainer.style.right = '10px';
  67. guiContainer.style.zIndex = '1000';
  68. guiContainer.style.backgroundColor = '#fff';
  69. guiContainer.style.border = '1px solid #ccc';
  70. guiContainer.style.padding = '10px';
  71. guiContainer.style.borderRadius = '5px';
  72. guiContainer.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
  73. guiContainer.style.display = 'flex';
  74. guiContainer.style.flexDirection = 'column';
  75. guiContainer.style.gap = '10px';
  76.  
  77. const invincibleButton = document.createElement('button');
  78. invincibleButton.textContent = 'Invincible Mode';
  79. invincibleButton.onclick = makeInvincible;
  80. guiContainer.appendChild(invincibleButton);
  81.  
  82. const resetButton = document.createElement('button');
  83. resetButton.textContent = 'Reset Game';
  84. resetButton.onclick = resetGame;
  85. guiContainer.appendChild(resetButton);
  86.  
  87. const speedLabel = document.createElement('label');
  88. speedLabel.textContent = 'Set Speed:';
  89. guiContainer.appendChild(speedLabel);
  90.  
  91. const speedSlider = document.createElement('input');
  92. speedSlider.type = 'range';
  93. speedSlider.min = '1';
  94. speedSlider.max = '100';
  95. speedSlider.value = '10';
  96. speedSlider.oninput = function() {
  97. setSpeed(speedSlider.value);
  98. };
  99. guiContainer.appendChild(speedSlider);
  100.  
  101. const autoJumpButton = document.createElement('button');
  102. autoJumpButton.textContent = 'Enable Auto Jump';
  103. autoJumpButton.onclick = function() {
  104. if (autoJumpEnabled) {
  105. disableAutoJump();
  106. autoJumpButton.textContent = 'Enable Auto Jump';
  107. } else {
  108. enableAutoJump();
  109. autoJumpButton.textContent = 'Disable Auto Jump';
  110. }
  111. };
  112. guiContainer.appendChild(autoJumpButton);
  113.  
  114. document.body.appendChild(guiContainer);
  115. }
  116.  
  117. // Wait for the game to load
  118. window.addEventListener('load', createGUI);
  119. })();