dev_codeSet

Quizizz-hack

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