Greasy Fork 支持简体中文。

TTRockstars Devil

Automatic answer bot for https://play.ttrockstars.com/

  1. // ==UserScript==
  2. // @name TTRockstars Devil
  3. // @namespace https://github.com/usercromix/TTrockstars-Devil
  4. // @version 1.0
  5. // @description Automatic answer bot for https://play.ttrockstars.com/
  6. // @author usercromix
  7. // @license TTrockstars Devil © 2024 by usercromix, © All Rights Reserved
  8. // @match https://play.ttrockstars.com/*
  9. // @icon https://play.ttrockstars.com/ttrs-favicon.png
  10. // @grant GM_log
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. GM_log("Your script is running.");
  17.  
  18. // Key code for enabling/disabling the bot (default is 'B' key)
  19. var toggleKey = 66; // 'B' key code
  20. var speed = 0.225; // Default speed (equivalent to 225 milliseconds)
  21.  
  22. // Variable to track whether the bot is running or not
  23. var running = false;
  24.  
  25. // Function to toggle the bot state
  26. function toggleBot() {
  27. running = !running;
  28. GM_log("Bot " + (running ? "enabled" : "disabled"));
  29. }
  30.  
  31. // Function to change the toggle key
  32. function changeToggleKey(newKeyCode) {
  33. toggleKey = newKeyCode;
  34. GM_log("Toggle key changed to: " + String.fromCharCode(newKeyCode));
  35. }
  36.  
  37. // Function to set the speed
  38. function setSpeed(newSpeed) {
  39. speed = newSpeed;
  40. GM_log("Speed set to: " + newSpeed);
  41. }
  42.  
  43. // Event listener to toggle the bot when the toggle key is pressed
  44. document.addEventListener("keydown", function(event) {
  45. if (event.keyCode === toggleKey) {
  46. toggleBot();
  47. } else if (event.shiftKey && event.keyCode !== 16) { // Only Shift key, excluding Shift itself
  48. toggleMenu();
  49. }
  50. });
  51.  
  52. // Toggle the menu visibility
  53. function toggleMenu() {
  54. var menu = document.getElementById("menu");
  55. if (menu.style.display === "block") {
  56. menu.style.display = "none";
  57. } else {
  58. menu.style.display = "block";
  59. }
  60. }
  61.  
  62. // Set up an interval function that runs every 100 milliseconds
  63. setInterval(() => {
  64. var equation = document.getElementsByClassName("notranslate height-100 noselect current")[0];
  65. var input = document.getElementsByClassName("input-holder width-100")[0];
  66. if (input == undefined || input == null) {
  67. input = document.getElementsByClassName("input-holder width-100 hint")[0];
  68. }
  69. var enter = document.getElementsByClassName("key-ent ng-star-inserted")[0];
  70. var top = document.getElementsByClassName("next-game-question padding-5")[0];
  71. var keypad = document.getElementsByClassName("keyboard mat-white-color bg-2")[0];
  72. var play;
  73.  
  74. if (equation != undefined) {
  75. if (!running) {
  76. return;
  77. }
  78.  
  79. let el = document.createElement("div");
  80. el.setAttribute("href", "https://github.com/usercromix/TTrockstars-Devil");
  81. el.setAttribute("target", "_blank");
  82. for (var i = 0; i < top.children.length; i++) {
  83. top.children[i].remove();
  84. }
  85. el.style = "background-color: peachpuff; color: black; width: auto; align-items: center; margin-top: 10px; margin-bottom: 10px; padding: 5px; border-radius: 10px; text-align: center; font-family: 'Fredoka One', sans-serif;";
  86. el.innerHTML = "Exploit Enabled";
  87. top.appendChild(el);
  88.  
  89. var id = setInterval(() => {
  90. if (running) {
  91. let raw = equation.innerHTML.replace("×", "*").replace("÷", "/");
  92. console.log(raw);
  93. while (raw.includes("<!---->")) {
  94. raw = raw.replace("<!---->", "");
  95. }
  96. raw = raw.replace(/<\s*span[^>]*>.*?<\s*\/\s*span\s*>/g, '');
  97. raw = raw.trim();
  98. console.log(raw);
  99. let answer = String(eval(raw));
  100. GM_log("answer: " + answer);
  101.  
  102. [...answer].forEach(char => {
  103. for (var row = 0; row < keypad.children.length; row++) {
  104. for (var key = 0; key < keypad.children[row].children.length; key++) {
  105. let elem = keypad.children[row].children[key];
  106. if (elem.innerHTML.trim() == char) {
  107. elem.click();
  108. elem.style.transform = "scale(0.9)";
  109. setTimeout(() => {
  110. elem.style.transform = "scale(1)";
  111. }, 100);
  112. return;
  113. }
  114. }
  115. }
  116. });
  117. enter.click();
  118. } else {
  119. clearInterval(id);
  120. }
  121. }, speed * 1000); // Convert speed to milliseconds
  122. } else {
  123. running = false;
  124. var gameOver = document.getElementsByClassName("stamp center mat-white-color")[0];
  125. if (gameOver != undefined) {
  126. gameOver.innerHTML = "You like the hacks?😊";
  127. }
  128. }
  129. }, 100);
  130.  
  131. // Create the menu
  132. var menu = document.createElement("div");
  133. menu.id = "menu";
  134. menu.style = "display: none; position: fixed; top: 10px; left: 10px; z-index: 9999; background-color: rgba(255, 255, 255, 0.8); border: 1px solid #ccc; padding: 20px; border-radius: 10px; width: 300px; font-family: Arial, sans-serif; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s;";
  135.  
  136. // Menu content
  137. var menuContent = "<div style='margin-bottom: 20px; text-align: center; font-size: 20px; font-weight: bold; color: #333;'>TTRockstars Devil Menu</div>" +
  138. "<div style='margin-bottom: 20px;'>Recommended to change toggle key before going into a round! Also, speed might be a little buggy so change it if you know how to use! To open and close menu Shift + M on keyboard</div>" +
  139. "<label style='margin-bottom: 15px; display: block;'>Toggle Key: <input type='text' id='toggleKey' value='" + String.fromCharCode(toggleKey) + "' style='width: 30px; text-align: center;'></label>" +
  140. "<label style='margin-bottom: 15px; display: block;'>Speed: <input type='text' id='speed' value='" + speed + "' style='width: 50px; text-align: center;'></label>" +
  141. "<button id='apply' style='padding: 8px 15px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; margin-right: 10px; transition: transform 0.3s;'>Apply Changes</button>" +
  142. "<button id='closeMenu' style='padding: 8px 15px; background-color: #f44336; color: white; border: none; border-radius: 5px; cursor: pointer; transition: transform 0.3s;'>Close</button>";
  143. menu.innerHTML = menuContent;
  144.  
  145. document.body.appendChild(menu);
  146.  
  147. // Add event listener for applying changes
  148. document.getElementById("apply").addEventListener("click", function() {
  149. var newToggleKey = document.getElementById("toggleKey").value.toUpperCase().charCodeAt(0);
  150. changeToggleKey(newToggleKey);
  151. var newSpeed = parseFloat(document.getElementById("speed").value);
  152. setSpeed(newSpeed);
  153. this.style.transform = "scale(0.9)";
  154. setTimeout(() => {
  155. this.style.transform = "scale(1)";
  156. }, 100);
  157. });
  158.  
  159. // Add event listener to close the menu
  160. document.getElementById("closeMenu").addEventListener("click", function() {
  161. toggleMenu();
  162. this.style.transform = "scale(0.9)";
  163. setTimeout(() => {
  164. this.style.transform = "scale(1)";
  165. }, 100);
  166. });
  167.  
  168. // Add hover animation for buttons
  169. var buttons = document.querySelectorAll("#menu button");
  170. buttons.forEach(button => {
  171. button.addEventListener("mouseenter", function() {
  172. this.style.transform = "scale(0.95)";
  173. });
  174. button.addEventListener("mouseleave", function() {
  175. this.style.transform = "scale(1)";
  176. });
  177. });
  178.  
  179. })();