BeanHacks

Epic ep hack

  1. // ==UserScript==
  2. // @name BeanHacks
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description Epic ep hack
  6. // @author Tnttiger111
  7. // @match *://*.educationperfect.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (async function () {
  12. "use strict";
  13. let semiTOGGLE = false;
  14. let autoTOGGLE = false;
  15. let fullDict = {};
  16. let cutDict = {};
  17. let answerSub = "";
  18. let msg = "";
  19.  
  20. function sleep(ms) {
  21. return new Promise(resolve => setTimeout(resolve, ms));
  22. }
  23.  
  24. function cutString(string) {
  25. string = String(string.replace(/ *\([^)]*\) */g, "").split("; ")[0]);
  26. string = String(string.split(", ")[0]);
  27. return string;
  28. }
  29.  
  30. function wordList(className) {
  31. let words = [];
  32. document.querySelectorAll("div." + className).forEach(i => words.push(i.innerText));
  33. return words;
  34. }
  35.  
  36. function mergeLists(l1, l2) {
  37. for (let i = 0; i < l1.length; i++) {
  38. fullDict[l2[i]] = cutString(l1[i]);
  39. fullDict[l1[i]] = cutString(l2[i]);
  40. cutDict[cutString(l2[i])] = cutString(l1[i]);
  41. cutDict[cutString(l1[i])] = cutString(l2[i]);
  42. }
  43. }
  44.  
  45. async function submitButton() {
  46. let explanation = document.querySelector("button#explanation-button");
  47. if (explanation) return explanation;
  48. console.log("didn't find hax button");
  49. return document.querySelector("button.submit-button");
  50. }
  51.  
  52. function deleteModals() {
  53. document.querySelectorAll("div[uib-modal-window=modal-window]").forEach(i => i.remove());
  54. document.querySelectorAll("div[uib-modal-backdrop=modal-backdrop]").forEach(i => i.remove());
  55. }
  56.  
  57. function findAnswer(question) {
  58. let answer = fullDict[question];
  59. if (answer === undefined) answer = fullDict[question.replace(",", ";")];
  60. if (answer === undefined) answer = cutDict[cutString(question)];
  61. return answer
  62. }
  63.  
  64. async function correctAnswer(question) {
  65. msg = msg + "Thought question: \n" + question + "\n";
  66. for (let i = 0; i < 300; i++) {
  67. if (cutString(document.querySelector("td#question-field").innerText) === cutString(question)) break;
  68. await sleep(10);
  69. }
  70. msg = msg + "Modal question: " + document.querySelector("td#question-field").innerText + "\n";
  71. let answer = cutString(document.querySelector("td#correct-answer-field").innerText);
  72. document.querySelector("button#continue-button").disabled = false;
  73. document.querySelector("button#continue-button").click();
  74. msg = msg + "Modal cut answer: \n" + answer + "\n";
  75. fullDict[question] = answer;
  76. }
  77.  
  78. async function submitAnswer(answer) {
  79. msg = "Thought answered: \n" + answer + "\n";
  80. (await submitButton()).click();
  81. document.querySelector("input#answer-text").value = answer;
  82. }
  83.  
  84. async function answerLoop() {
  85. let failCount = 0;
  86. while (semiTOGGLE || autoTOGGLE) {
  87. try {
  88. let question = document.querySelector("#question-text").innerText;
  89. let answer = findAnswer(question);
  90. if (answer === undefined) console.log("no answer found");
  91. answerSub = answer
  92.  
  93. if (semiTOGGLE === true) {
  94. try {
  95. await navigator.clipboard.writeText(answerSub)
  96. }
  97. catch {
  98. console.log("if you're on Safari, ignore this error, if not, please report this as a bug at EducationPerfected if something isn't working")
  99. }
  100. }
  101.  
  102. if (autoTOGGLE === true) {
  103. await submitAnswer(answerSub);
  104. }
  105.  
  106. if (document.querySelector("td#correct-answer-field") != null && document.querySelector("#question-field") != null) {
  107. await correctAnswer(question);
  108. console.log(msg);
  109. msg = "";
  110. deleteModals();
  111. }
  112. failCount = 0;
  113. } catch (err) {
  114. failCount++;
  115. if (failCount > 30) {
  116. semiTOGGLE = false;
  117. autoTOGGLE = false;
  118. console.log(err);
  119. deleteModals();
  120. alert("Error, Auto-Answer Stopped.");
  121. }
  122. }
  123. await sleep(0);
  124. }
  125. }
  126.  
  127. document.addEventListener("keydown", async (event) => {
  128. if ((event.altKey && event.key.toLowerCase() === "r") || (event.key.toLowerCase() === "®")) {
  129. mergeLists(wordList("targetLanguage"), wordList("baseLanguage"));
  130. console.log(fullDict, cutDict);
  131. alert("Word List Refreshed");
  132. }
  133.  
  134. else if ((event.altKey && event.key.toLowerCase() === "a") || (event.key.toLowerCase() === "å")) {
  135. if (semiTOGGLE === false) {
  136. autoTOGGLE = false;
  137. semiTOGGLE = true;
  138. await sleep(10);
  139. alert("Starting Semi-Auto-Answer");
  140. await answerLoop();
  141. } else {
  142. deleteModals();
  143. alert("Stopping Semi-Auto-Answer");
  144. semiTOGGLE = false;
  145. }
  146. }
  147.  
  148. else if ((event.metaKey && semiTOGGLE === true) || (event.ctrlKey && semiTOGGLE === true)) {
  149. navigator.clipboard.writeText(answerSub).then(function(arr) {}, function(arr) {
  150. console.log(`Failed to Copy Answer: ${arr}`)
  151. });
  152. }
  153.  
  154. else if ((event.altKey && event.key.toLowerCase() === "s") || (event.key.toLowerCase() === "ß")) {
  155. if (autoTOGGLE === false) {
  156. semiTOGGLE = false;
  157. autoTOGGLE = true;
  158. await sleep(10);
  159. alert("Starting Fully-Auto-Answer");
  160. await answerLoop();
  161. } else {
  162. deleteModals();
  163. alert("Stopping Fully-Auto-Answer");
  164. autoTOGGLE = false;
  165. }
  166. }
  167. });
  168. console.log("BeanHacks by Tnttiger111");
  169. })();