Chrome Dino Game Helper

Helper functions for the Chrome Dino game

目前为 2024-04-25 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Chrome Dino Game Helper
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-04-24
  5. // @description Helper functions for the Chrome Dino game
  6. // @author You
  7. // @match https://chromedino.com/
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=chromedino.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Define a function to check if the Runner object is available
  17. function checkRunner() {
  18. if (typeof Runner !== 'undefined') {
  19. // Runner object is available, add the gameOver function
  20. Runner.prototype.gameOver = function() {
  21. console.log("hi");
  22. };
  23. // Add toggle menu
  24. addToggleMenu();
  25. } else {
  26. // Runner object is not available yet, wait and try again
  27. setTimeout(checkRunner, 100);
  28. }
  29. }
  30.  
  31. // Function to add toggle menu
  32. function addToggleMenu() {
  33. const menuDiv = document.createElement('div');
  34. menuDiv.innerHTML = `
  35. <div id="helperMenu" style="position: fixed; top: 10px; right: 10px; z-index: 9999; background-color: rgba(255, 255, 255, 0.8); padding: 10px; border: 1px solid #ccc;">
  36. <label><input type="checkbox" id="gameOverToggle"> Game Over Toggle</label>
  37. </div>
  38. `;
  39. document.body.appendChild(menuDiv);
  40.  
  41. const toggleCheckbox = document.getElementById('gameOverToggle');
  42. toggleCheckbox.addEventListener('change', function() {
  43. if (toggleCheckbox.checked) {
  44. // Enable game over function
  45. Runner.prototype.gameOver = function() {
  46. console.log("hi");
  47. };
  48. } else {
  49. // Disable game over function
  50. delete Runner.prototype.gameOver;
  51. }
  52. });
  53. }
  54.  
  55. // Start checking for the Runner object
  56. checkRunner();
  57. })();