Cauull

Javascript Untuk View Answer Brainly

Sep 21st, 2020
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.10 KB | None | 0 0
  1. var x = document.createElement("link");
  2. x.rel = 'stylesheet';
  3. x.type = 'text/css'
  4. x.href = "https://cdn.jsdelivr.net/gh/EastArctica/JS-Plugins@master/Un-Released/Kahoot/KahootModal.css"
  5. document.head.appendChild(x);
  6.  
  7.  
  8.  
  9. var xhttp = new XMLHttpRequest()
  10. var URL = window.location.href
  11. var found = URL.search("https://quizizz.com/join/game/");
  12. if (found == 0) { found = true }
  13. if (found) {
  14. var Modal = document.createElement("div")
  15. Modal.id = "mainModal"
  16. Modal.className = "mainModal"
  17. Modal.style = "position: fixed; z-index: 2147483647; left: 0px; top: 0px; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4); display: none;"
  18. var ModalContent = document.createElement("div")
  19. ModalContent.className = "modal-content"
  20. ModalContent.id = "ModalContent"
  21. var Close = document.createElement("span")
  22. Close.className = "close"
  23. Close.innerHTML = "×"
  24. var btn = document.createElement("button")
  25. btn.id = "ModalButton"
  26. btn.innerText = "View Answers"
  27. btn.onclick = function() {
  28. Modal.style.display = "block";
  29. }
  30. Close.onclick = function() {
  31. Modal.style.display = "none";
  32. }
  33. window.onclick = function(event) {
  34. if (event.target == Modal) {
  35. Modal.style.display = "none";
  36. }
  37. }
  38. document.getElementsByClassName("actions-container")[0].appendChild(btn)
  39. ModalContent.appendChild(Close)
  40. Modal.appendChild(ModalContent)
  41. document.getElementsByClassName("root-bootstrapper-container")[0].prepend(Modal)
  42. if (!window.idiidk) {
  43. window.idiidk = function() {
  44. const offset = 33;
  45. class Encoding {
  46. static encode(t, e, o = 2) {
  47. const s = this.encodeRaw(e, !0);
  48. return `${s}${this.encodeRaw(t,!1,e)}${String.fromCharCode(33+s.length)}${o}`
  49. }
  50. static encodeRaw(t, e, o = "quizizz.com") {
  51. let s = 0;
  52. s = e ? o.charCodeAt(0) : o.charCodeAt(0) + o.charCodeAt(o.length - 1);
  53. const r = [];
  54. for (let o = 0; o < t.length; o++) {
  55. const n = t[o].charCodeAt(0),
  56. c = e ? this.safeAdd(n, s) : this.addOffset(n, s, o, 2);
  57. r.push(String.fromCharCode(c))
  58. }
  59. return r.join("")
  60. }
  61. static decode(t, e = !1) {
  62. if (e) {
  63. const e = this.extractHeader(t);
  64. return this.decodeRaw(e, !0)
  65. } {
  66. const e = this.decode(this.extractHeader(t), !0),
  67. o = this.extractData(t);
  68. return this.decodeRaw(o, !1, e)
  69. }
  70. }
  71. static decodeRaw(t, e, o = "quizizz.com") {
  72. const s = this.extractVersion(t);
  73. let r = 0;
  74. r = e ? o.charCodeAt(0) : o.charCodeAt(0) + o.charCodeAt(o.length - 1), r = -r;
  75. const n = [];
  76. for (let o = 0; o < t.length; o++) {
  77. const c = t[o].charCodeAt(0),
  78. a = e ? this.safeAdd(c, r) : this.addOffset(c, r, o, s);
  79. n.push(String.fromCharCode(a))
  80. }
  81. return n.join("")
  82. }
  83. static addOffset(t, e, o, s) {
  84. return 2 === s ? this.verifyCharCode(t) ? this.safeAdd(t, o % 2 == 0 ? e : -e) : t : this.safeAdd(t, o % 2 == 0 ? e : -e)
  85. }
  86. static extractData(t) {
  87. const e = t.charCodeAt(t.length - 2) - 33;
  88. return t.slice(e, -2)
  89. }
  90. static extractHeader(t) {
  91. const e = t.charCodeAt(t.length - 2) - 33;
  92. return t.slice(0, e)
  93. }
  94. static extractVersion(t) {
  95. if ("string" == typeof t && t[t.length - 1]) {
  96. const e = parseInt(t[t.length - 1], 10);
  97. if (!isNaN(e)) return e
  98. }
  99. return null
  100. }
  101. static safeAdd(t, e) {
  102. const o = t + e;
  103. return o > 65535 ? o - 65535 + 0 - 1 : o < 0 ? 65535 - (0 - o) + 1 : o
  104. }
  105. static verifyCharCode(t) {
  106. if ("number" == typeof t) return !(t >= 55296 && t <= 56319 || t >= 56320 && t <= 57343)
  107. }
  108. static generateIdentifier(t, e, o = 1, s = (new Date).getTime()) {
  109. let r = e;
  110. return "function" == typeof e && (r = e()), "".concat(t, ".").concat(r, "|").concat(o, ".").concat(s)
  111. }
  112. }
  113. var URL = window.location.href
  114. var GameType = URL.slice(URL.search("gameType=")+9, URL.length)
  115. const prevConx = localStorage.getItem("previousContext"),
  116. parsedConx = JSON.parse(prevConx),
  117. encodedRoomHash = parsedConx.game.roomHash,
  118. roomHash = Encoding.decode(encodedRoomHash.split("-")[1]),
  119. data = {
  120. roomHash: roomHash,
  121. type: GameType
  122. };
  123. fetch("https://game.quizizz.com/play-api/v3/getQuestions", {
  124. method: "POST",
  125. headers: {
  126. "Content-Type": "application/json"
  127. },
  128. body: JSON.stringify(data)
  129. }).then(t => t.json()).then(t => {
  130. let e = 0;
  131. for (const o of Object.keys(t.questions)) {
  132. e++;
  133. const s = t.questions[o],
  134. r = s.structure.kind,
  135. n = s.structure.answer,
  136. c = Encoding.decode(n);
  137. ModalContent.insertAdjacentHTML( 'beforeend', `<b>Question: </b>`)
  138. ModalContent.insertAdjacentHTML( 'beforeend', `${s.structure.query.text}<br>`)
  139. if (c[0] == "[") {
  140. newc = c.slice(1, c.length-1)
  141. newc = newc.split(",");
  142. // c has been turned into an array :)
  143. ModalContent.insertAdjacentHTML( 'beforeend', `<b>Answers:</b><br>`)
  144. for (let i = 0; i < newc.length; i++) {
  145. ModalContent.insertAdjacentHTML( 'beforeend', `${s.structure.options[Number(newc[i])].text || s.structure.options[Number(newc[i])].media[0].url} <br>`)
  146. }
  147. ModalContent.insertAdjacentHTML( 'beforeend', `<br>`)
  148. } else {
  149. //console.log(s.structure)
  150. ModalContent.insertAdjacentHTML( 'beforeend', `<b>Answer:</b> ${s.structure.options[c].text || s.structure.options[c].media[0].url} <br><br>`)
  151. }
  152. }
  153. });
  154. }
  155. window.idiidk();
  156. } else {
  157. window.idiidk();
  158. }
  159. }
Add Comment
Please, Sign In to add comment