Advertisement
Guest User

[100% working] Gimkit Auto Answer!

a guest
Feb 29th, 2020
11,906
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.66 KB | None | 0 0
  1. \\ Copy from window.geteventlisteners to below. Paste this to the Console.
  2.  
  3. window.getEventListeners = getEventListeners //For some reason, getEventListeners is not available unless we do this.
  4.  
  5. //TODO: Dynamically figure out prices, in case they change.
  6. let moneyPerQuestion = [undefined, 10, 100, 1e3, 1e4, 7.5e4, 3e5, 1e6, 1e7, 1e8]
  7. let streakBonus = [undefined, 15, 1.5e2, 1.5e3, 1.5e4, 115e3, 450e3, 15e5, 15e6, 2e8]
  8. let multiplier = [undefined, 50, 300, 2e3, 12e3, 85e3, 7e5, 65e5, 65e6, 1e9]
  9.  
  10. //Insurance is currently ignored.
  11. let insurance = [undefined, 10, 250, 1e3, 25e3, 1e5, 1e6 , 5e6, 25e6, 5e7]
  12.  
  13. const transporter = {}
  14. transporter.toggleLoc = () => { // If in shop - goes to questions, if in questions goes to shop
  15. clickElement(document.querySelector('div[style="font-weight: 900; cursor: pointer; font-size: 22px;"]'))
  16. };
  17. transporter.toShop = () => {
  18. clickElement(document.querySelectorAll('svg.MuiSvgIcon-root')[0])
  19. clickElement(document.querySelectorAll('nav.MuiList-root.MuiList-padding svg.MuiSvgIcon-root')[1])
  20. };
  21. transporter.toQuestion = () => {
  22. clickElement(document.querySelectorAll('svg.MuiSvgIcon-root')[0])
  23. clickElement(document.querySelectorAll('nav.MuiList-root.MuiList-padding svg.MuiSvgIcon-root')[0])
  24. };
  25. function clickElement(elem) {
  26.  
  27. //Mobile event dispatch order
  28. let events = ["touchstart", "touchend", "mouseover", "mousemove", "mousedown", "mouseup", "click"]
  29.  
  30. console.log(elem)
  31. events.forEach((event) => {
  32. if (event.includes("touch")) {
  33. elem.dispatchEvent(new TouchEvent(event, {bubbles: true}))
  34. }
  35. else if (event.includes("mouse") || event === "click") {
  36. elem.dispatchEvent(new MouseEvent(event, {bubbles: true}))
  37. }
  38. })
  39. }
  40.  
  41. transporter.simpleClick = clickElement
  42.  
  43.  
  44. //TODO: Handle view correct answer setting being off.
  45.  
  46. //We will remember what the questions were, and what the correct answer to them was. This will mean, that,
  47. //after we have guessed the correct answer to a question, we won't miss it in the future.
  48. let results = {}
  49.  
  50. const sleep = m => new Promise(r => setTimeout(r, m))
  51.  
  52. function getMoney() {
  53. return Number(document.querySelector("body > div > div").innerText.split(",").join("").split("\n")[0].slice(1))
  54. }
  55.  
  56. async function answerQuestion() {
  57. transporter.toQuestion()
  58. //Element 0 is the question. 1-4 are the answer choices.
  59. let elements = document.querySelectorAll("span.notranslate.lang-en")
  60.  
  61. let questionName = elements[0].innerText
  62. let index = 1
  63.  
  64. if (results[questionName]) {
  65. let answer = results[questionName]
  66. for (let i = 1; i < elements.length; i++) {
  67. if (elements[i].innerText === answer) {
  68. index = i
  69. break;
  70. }
  71. }
  72. }
  73. let guessing = elements[index].innerText
  74. getEventListeners(document).click[0].listener({isTrusted: true, target: elements[index], type: "click"})
  75. console.log(elements)
  76. console.log(index)
  77.  
  78. await sleep(450)
  79.  
  80. let lost = document.querySelector("body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div").innerText.startsWith("-")
  81.  
  82. // One of shop and viewCorrectAnswer exist
  83. if (!lost) {
  84. //We got the question correct
  85.  
  86. //Save the answer to the question.
  87. results[questionName] = guessing
  88.  
  89. let money = getMoney()
  90.  
  91. let shopIndex; //Money per question, streak, multiplier, insurance (not useful).
  92.  
  93. let moneyIndex = moneyPerQuestion.findIndex((x) => {
  94. return money >= x
  95. })
  96. let streakIndex = streakBonus.findIndex((x) => {
  97. return money >= x
  98. })
  99. let multiplierIndex = multiplier.findIndex((x) => {
  100. return money >= x
  101. })
  102.  
  103. let purchaseIndex
  104.  
  105. if (moneyIndex !== -1) {
  106. shopIndex = 0;
  107. purchaseIndex = moneyIndex;
  108. moneyPerQuestion[moneyIndex] = undefined
  109. } else if (streakIndex !== -1) {
  110. shopIndex = 1;
  111. purchaseIndex = streakIndex
  112. streakBonus[streakIndex] = undefined
  113. } else if (multiplierIndex !== -1) {
  114. shopIndex = 2;
  115. purchaseIndex = multiplierIndex
  116. multiplier[multiplierIndex] = undefined
  117. }
  118.  
  119. console.log(money)
  120. console.log(shopIndex)
  121. console.log(purchaseIndex)
  122. console.log(moneyIndex, streakIndex, multiplierIndex)
  123.  
  124. if (shopIndex !== undefined) {
  125. transporter.toShop()
  126. //TODO: Add powerups.
  127.  
  128. await sleep(400)
  129.  
  130. let options = document.querySelectorAll("body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div")
  131. console.log(options)
  132. transporter.simpleClick(options[shopIndex])
  133.  
  134. await sleep(400)
  135.  
  136. //Indexes 3-12 are purchase options.
  137. let selections = document.querySelectorAll("body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div > div")
  138. clickElement(selections[purchaseIndex + 3]) // Original attempts I see... for some reason none of these "shop selections work" just checking why - will be fixed
  139. //Select the upgrade
  140. await sleep(300)
  141. transporter.simpleClick(selections[2]) //Buy it.
  142. await sleep(300)
  143. //document.querySelectorAll("body > div > div > div > div > div")[2].click() //Click to go back to the questions.
  144. transporter.toQuestion()
  145. } else {
  146. //let nextQuestion = document.querySelector("#root > div > div.sc-lkqHmb.fDovdT > div:nth-child(1) > div > div > div.sc-bxivhb.guENId > span:nth-child(2) > div > div > div > div")
  147. //transporter.simpleClick(nextQuestion)
  148. transporter.toQuestion()
  149. }
  150. } else {
  151. //TODO: View Correct Answer button no longer being clicked. Probably requires the same getEventListeners change.
  152.  
  153. //Click "View Correct Answer"
  154. let viewCorrectAnswer = document.querySelector("#root > div > div > div > div > div > div:nth-child(2) > span:nth-child(1) > div")
  155. transporter.simpleClick(viewCorrectAnswer)
  156. await sleep(400)
  157. //Grab the answer
  158. let correctAnswer = document.querySelector("body > div > div > div:nth-child(3) > div:nth-child(1) > div > div > div > div > div:nth-child(3)").innerText
  159. //Store the correct answer for later use.
  160. results[questionName] = correctAnswer
  161. //transporter.simpleClick(document.querySelector("span>div>div>div>div")) // Clicks the next button thing
  162. transporter.toQuestion()
  163. }
  164. await sleep(400)
  165.  
  166. }
  167.  
  168. let answering = false
  169.  
  170. function stopAnswering() {
  171. answering = false
  172. }
  173.  
  174. async function startAnswering() {
  175. answering = true
  176. while (answering === true) {
  177. await answerQuestion()
  178. }
  179. }
  180.  
  181.  
  182.  
  183. //Allow pressing s to start
  184. window.addEventListener("keyup", function(e) {
  185. if (e.key === "s") {
  186. startAnswering()
  187. }
  188. })
  189. //Allow pressing e to end
  190. window.addEventListener("keyup", function(e) {
  191. if (e.key === "e") {
  192. stopAnswering()
  193. }
  194. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement