dev_codeSet

Quizizz-hack AUTOMATIC CONTESTADOR

Oct 8th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.32 KB | None | 0 0
  1. if (window.location.href.search("quizizz.com/join/game/") == -1 && window.location.href.search("gameType=") == -1) {
  2. throw new Error("Nie bierzesz udziału w quizie jeżeli uważasz, że to błąd zgłoś się na 🔥Kai🔥#2041");
  3. }
  4. if (window.QuizizzBot && !window.QuizizzBotDebug) {
  5. throw new Error("Bot Quizizz jest już uruchomiony! Zaawansowane: użyj w konsoli Window.QuizizzBotDebug");
  6. }
  7. window.QuizizzBot = true
  8. let WaitTime = prompt("¡Ingrese cada cuantos segundos debe responder el bot!")
  9. if (Number(WaitTime) === NaN) {
  10. alert("Zły numer. Sprobój ponownie")
  11. throw new Error("Zły numer");
  12. } else {
  13. WaitTime = Number(WaitTime)*1000
  14. }
  15.  
  16. document.head.insertAdjacentHTML('beforeend', `<style type="text/css">
  17. correct-answer-x3Ca8B {
  18. color: lime !important;
  19. }
  20. </style>`);
  21.  
  22. class Encoding {
  23. static encodeRaw(t, e, o="quizizz.com") {
  24. let s = 0;
  25. s = e ? o.charCodeAt(0) : o.charCodeAt(0) + o.charCodeAt(o.length - 1);
  26. let r = [];
  27. for (let o = 0; o < t.length; o++) {
  28. let n = t[o].charCodeAt(0)
  29. , c = e ? this.safeAdd(n, s) : this.addOffset(n, s, o, 2);
  30. r.push(String.fromCharCode(c))
  31. }
  32. return r.join("")
  33. }
  34.  
  35. static decode(t, e=!1) {
  36. if (e) {
  37. let e = this.extractHeader(t);
  38. return this.decodeRaw(e, !0)
  39. }
  40. {
  41. let e = this.decode(this.extractHeader(t), !0)
  42. , o = this.extractData(t);
  43. return this.decodeRaw(o, !1, e)
  44. }
  45. }
  46.  
  47. static decodeRaw(t, e, o="quizizz.com") {
  48. let s = this.extractVersion(t);
  49. let r = 0;
  50. r = e ? o.charCodeAt(0) : o.charCodeAt(0) + o.charCodeAt(o.length - 1),
  51. r = -r;
  52. let n = [];
  53. for (let o = 0; o < t.length; o++) {
  54. let c = t[o].charCodeAt(0)
  55. , a = e ? this.safeAdd(c, r) : this.addOffset(c, r, o, s);
  56. n.push(String.fromCharCode(a))
  57. }
  58. return n.join("")
  59. }
  60.  
  61. static addOffset(t, e, o, s) {
  62. return 2 === s ? this.verifyCharCode(t) ? this.safeAdd(t, o % 2 == 0 ? e : -e) : t : this.safeAdd(t, o % 2 == 0 ? e : -e)
  63. }
  64.  
  65. static extractData(t) {
  66. let e = t.charCodeAt(t.length - 2) - 33;
  67. return t.slice(e, -2)
  68. }
  69.  
  70. static extractHeader(t) {
  71. let e = t.charCodeAt(t.length - 2) - 33;
  72. return t.slice(0, e)
  73. }
  74.  
  75. static extractVersion(t) {
  76. if ("string" == typeof t && t[t.length - 1]) {
  77. let e = parseInt(t[t.length - 1], 10);
  78. if (!isNaN(e))
  79. return e
  80. }
  81. return null
  82. }
  83.  
  84. static safeAdd(t, e) {
  85. let o = t + e;
  86. return o > 65535 ? o - 65535 + 0 - 1 : o < 0 ? 65535 - (0 - o) + 1 : o
  87. }
  88.  
  89. static verifyCharCode(t) {
  90. if ("number" == typeof t)
  91. return !(t >= 55296 && t <= 56319 || t >= 56320 && t <= 57343)
  92. }
  93. }
  94.  
  95. function GetSetData() {
  96. let URL = window.location.href
  97. , GameType = URL.slice(URL.search("gameType=") + 9, URL.length)
  98. , prevConx = localStorage.getItem("previousContext")
  99. , parsedConx = JSON.parse(prevConx)
  100. , encodedRoomHash = parsedConx.game.roomHash
  101. , roomHash = Encoding.decode(encodedRoomHash.split("-")[1])
  102. , data = {
  103. roomHash: roomHash,
  104. type: GameType
  105. };
  106.  
  107. let xhttp = new XMLHttpRequest
  108. xhttp.open("POST", "https://game.quizizz.com/play-api/v3/getQuestions", false)
  109. xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
  110. xhttp.send(JSON.stringify(data))
  111. return JSON.parse(xhttp.responseText)
  112. }
  113.  
  114. function GetAnswer(Question) {
  115. switch (Question.structure.kind) {
  116. case "BLANK":
  117. // Text Response, we have no need for image detection in answers
  118. let ToRespond = []
  119. for (let i = 0; i < Question.structure.options.length; i++) {
  120. ToRespond.push(Question.structure.options[i].text)
  121. }
  122. return ToRespond;
  123. case "MSQ":
  124. // Multiple Choice
  125. let Answers = Encoding.decode(Question.structure.answer)
  126. Answers = JSON.parse(Answers)
  127. let TextArray = []
  128. for (let i = 0; i < Answers.length; i++) {
  129. if (Answers[i].text == "") {
  130. TextArray.push(Question.structure.options[Answers[i]].media[0].url)
  131. } else {
  132. TextArray.push(Question.structure.options[Answers[i]].text)
  133. }
  134. }
  135. return TextArray;
  136. case "MCQ":
  137. // Single Choice
  138. let AnswerNum = Encoding.decode(Question.structure.answer)
  139. let Answer = Question.structure.options[AnswerNum].text
  140. if (Answer == "") {
  141. Answer = Question.structure.options[AnswerNum].media[0].url
  142. }
  143. return Answer;
  144. }
  145. }
  146.  
  147. function GetQuestion(Set) {
  148. for (let v of Object.keys(Set.questions)) {
  149. v = Set.questions[v]
  150. switch (GetQuestionType()) {
  151. case "Both":
  152. let BothSRC = document.getElementsByClassName("question-media")[0].children[0].src
  153. BothSRC = BothSRC.slice(0, BothSRC.search("/?w=") - 1)
  154. if (v.structure.query.media[0]) {
  155. if (v.structure.query.media[0].url == BothSRC) {
  156. let BothQuestion = document.getElementsByClassName("question-text")[0].children[0].children[0].innerHTML
  157. if (BothQuestion.replace(/&nbsp;/g, "") == v.structure.query.text.replace(/&nbsp;/g, "")) {
  158. return (v)
  159. }
  160. }
  161. }
  162. break
  163. case "Media":
  164. let CurrentSRC = document.getElementsByClassName("question-media")[0].children[0].src
  165. CurrentSRC = CurrentSRC.slice(0, CurrentSRC.search("/?w=") - 1)
  166. if (v.structure.query.media[0]) {
  167. if (v.structure.query.media[0].url == CurrentSRC) {
  168. return (v)
  169. }
  170. }
  171. break
  172. case "Text":
  173. let ToSearchA = document.getElementsByClassName("question-text")[0].children[0].children[0].innerHTML
  174. let ToSearchB = v.structure.query.text
  175. ToSearchB = ToSearchB.replace('<br/>', '<br>')
  176. if (ToSearchA == ToSearchB) {
  177. return (v)
  178. }
  179. break
  180. }
  181. }
  182. return "Error: No question found"
  183. }
  184.  
  185. function GetQuestionType() {
  186. if (document.getElementsByClassName("question-media")[0]) {
  187. // Media was detected, check if text is too
  188. if (document.getElementsByClassName("question-text")[0]) {
  189. // Detected text aswell, send it to the onchanged
  190. return ("Both")
  191. } else {
  192. // Failed to detect text aswell, Media is all that we need to send
  193. return ("Media")
  194. }
  195. } else {
  196. // Media wasn't detected, no need to check if text was because it has to be
  197. return ("Text")
  198. }
  199. }
  200.  
  201. let CurrentQuestionNum = ""
  202. let LastRedemption
  203.  
  204. async function QuestionChangedLoop() {
  205. setTimeout(function() {
  206. let NewNum = document.getElementsByClassName("current-question")[0]
  207. let RedemptionQues = document.getElementsByClassName("redemption-marker")[0]
  208. if (NewNum) {
  209. if (NewNum.innerHTML != CurrentQuestionNum) {
  210. if (document.getElementsByClassName("typed-option-input")[0]) {
  211. let Set = GetSetData()
  212. let Question = GetQuestion(Set)
  213. if (Question == "Error: No question found") {
  214. alert("Failed to find question! This is a weird issue I don't understand, you will just have to answer this question legit for now.")
  215. } else {
  216. let Answer = GetAnswer(Question)
  217. if (Array.isArray(Answer)) {
  218. // We are on a question with multiple answers
  219. let ToShow = ""
  220. for (let x = 0; x < Answer.length; x++) {
  221. if (ToShow == "") {
  222. ToShow = Answer[x]
  223. } else {
  224. ToShow = ToShow + " | " + Answer[x]
  225. }
  226. }
  227. let ToShowNew = "Press Ctrl+C to copy (Answers are seperated by ' | ')"
  228. prompt(ToShowNew, ToShow)
  229. } else {
  230. let NewAnswer = "Press Ctrl+C to copy."
  231. prompt(NewAnswer, Answer);
  232. }
  233. }
  234. } else {
  235. let Choices = document.getElementsByClassName("options-container")[0].children[0].children
  236. for (let i = 0; i < Choices.length; i++) {
  237. if (!Choices[i].classList.contains("emoji")) {
  238. let Choice = Choices[i].children[0].children[0].children[0].children[0]
  239. let Set = GetSetData()
  240. let Question = GetQuestion(Set)
  241. if (Question === "Error: No question found") {
  242. alert("Failed to find question! This is a weird issue I don't understand, you will just have to answer this question legit for now.")
  243. } else {
  244. let Answer = GetAnswer(Question)
  245. if (Array.isArray(Answer)) {
  246. // We are on a question with multiple answers
  247. for (let x = 0; x < Answer.length; x++) {
  248. if (Choice.innerHTML.replace(/&nbsp;/g, "") == Answer[x].replace(/&nbsp;/g, "")) {
  249. setTimeout(function() {
  250. Choice.parentElement.click()
  251. }, WaitTime)
  252. }
  253. }
  254. } else {
  255. if (Choice.innerHTML.replace(/&nbsp;/g, "") == Answer.replace(/&nbsp;/g, "")) {
  256. setTimeout(function() {
  257. Choice.parentElement.click()
  258. }, WaitTime)
  259. } else if (Choice.style.backgroundImage.slice(5, Choice.style.backgroundImage.length - 2).slice(0, Choice.style.backgroundImage.slice(5, Choice.style.backgroundImage.length - 2).search("/?w=") - 1) == GetAnswer(GetQuestion(GetSetData()))) {
  260. setTimeout(function() {
  261. Choice.parentElement.click()
  262. }, WaitTime)
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. CurrentQuestionNum = NewNum.innerHTML
  270. }
  271. } else if (RedemptionQues) {
  272. if (LastRedemption != GetQuestion(GetSetData())) {
  273. let Choices = document.getElementsByClassName("options-container")[0].children[0].children
  274. for (let i = 0; i < Choices.length; i++) {
  275. if (!Choices[i].classList.contains("emoji")) {
  276. let Choice = Choices[i].children[0].children[0].children[0].children[0]
  277. if (Choice.innerHTML.replace(/&nbsp;/g, "") == GetAnswer(GetQuestion(GetSetData())).replace(/&nbsp;/g, "")) {
  278. setTimeout(function() {
  279. Choice.parentElement.click()
  280. }, WaitTime)
  281. }
  282. }
  283. }
  284. LastRedemption = GetQuestion(GetSetData())
  285. }
  286. }
  287. QuestionChangedLoop()
  288. }, 100)
  289. }
  290. QuestionChangedLoop()
Add Comment
Please, Sign In to add comment