Sleazy Fork is available in English.

ttrs bot

Times Tables Rockstars bot.

  1. // ==UserScript==
  2. // @name ttrs bot
  3. // @namespace https://github.com/jibstack64/ttrockstars-bot
  4. // @version 0.1
  5. // @description Times Tables Rockstars bot.
  6. // @author olibot13
  7. // @match https://play.ttrockstars.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=mozilla.org
  9. // @grant GM_log
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. GM_log("on.");
  16.  
  17. if(typeof(String.prototype.trim) === "undefined") {
  18. String.prototype.trim = function() {
  19. return String(this).replace(/^\s+|\s+$/g, '');
  20. };
  21. }
  22.  
  23. /*const keyMap = new Map();
  24. const numbers = "0123456789"
  25. for (var i = 0; i < 10; i++) {
  26. keyMap.set(numbers[i], 48+i)
  27. }*/
  28.  
  29. var running = false;
  30. setInterval(() => {
  31. var equation = document.getElementsByClassName("notranslate h-full noselect current")[0];
  32. var input = document.getElementsByClassName("input-holder width-100")[0];
  33. if (input == undefined || input == null) {
  34. input = document.getElementsByClassName("input-holder width-100 hint")[0];
  35. }
  36. var enter = document.getElementsByClassName("key-ent ng-star-inserted")[0];
  37. var top = document.getElementsByClassName("next-game-question padding-5")[0];
  38. var keypad = document.getElementsByClassName("keyboard mat-white-color bg-2")[0];
  39. var play;
  40.  
  41. if (equation != undefined) {
  42. if (running) {
  43. return;
  44. }
  45. // start running
  46. running = true;
  47. // add "hacks enabled" message
  48. let el = document.createElement("a");
  49. el.setAttribute("href", "open.ojdawson.xyz");
  50. el.setAttribute("target", "_blank");
  51. for (var i = 0; i < top.children.length; i++) {
  52. top.children[i].remove()
  53. }
  54. el.style = "background-color: black; color: greenyellow; width: auto;align-items: center;margin-top: 10px;margin-bottom: 10px;padding: 5px;border: 2px solid red; font-size: 20px; font-style: bold; font-family: monospace;";
  55. el.innerHTML = "(on)";
  56. top.appendChild(el);
  57.  
  58. var id = setInterval(() => {
  59. if (running) {
  60. let raw = equation.innerHTML.replace("×", "*").replace("÷", "/");
  61. while (raw.includes("<!---->")) {
  62. raw = raw.replace("<!---->", "");
  63. }
  64. raw = raw.trim();
  65. let answer = String(eval(raw));
  66. GM_log("answer: " + answer);
  67.  
  68. // example: 30 <!---->÷<!----><!----> 5 <!----><!----><!----><!---->
  69. /*let el = "<span class=\"notranslate ng-star-inserted\">"+String(answer)+"</span>";
  70. if (!input.innerHTML.includes(el)) {
  71. input.innerHTML = "<span class=\"notranslate ng-star-inserted\">"+String(answer)+"</span>" + input.innerHTML
  72. }*/
  73.  
  74. [...answer].forEach(char => {
  75. for (var row = 0; row < keypad.children.length; row++) {
  76. for (var key = 0; key < keypad.children[row].children.length; key++) {
  77. let elem = keypad.children[row].children[key]
  78. if (elem.innerHTML.trim() == char) {
  79. elem.click();
  80. return;
  81. }
  82. }
  83. }
  84. });
  85. enter.click();
  86. } else {
  87. clearInterval(id);
  88. }
  89. }, 225);
  90. } else {
  91. running = false;
  92. play = document.getElementsByClassName("mat-focus-indicator margin-5 play-button stamp mat-raised-button mat-button-base mat-accent ng-star-inserted")[0];
  93. if (play != undefined) {
  94. play.click();
  95. }
  96. var gameOver = document.getElementsByClassName("stamp center mat-white-color")[0];
  97. if (gameOver != undefined) {
  98. gameOver.innerHTML = "game won 😉"
  99. }
  100. }
  101.  
  102. }, 100);
  103. })();