Advertisement
Sufferrrrrr

Quizziz cheat

Sep 19th, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let quizDataPath = "https://quizizz.com/api/main/quiz/";
  2. let quizData;
  3. let questionData;
  4. let prevUrl = "";
  5. let autoProceed = confirm("Would you like to auto-proceed?");
  6.  
  7. if (getCookie("hackId") != "") {
  8.     quizData = getQuizData();
  9.     questionData = quizData.data.quiz.info.questions;
  10. }
  11.  
  12. let currentUrl = window.location.href;
  13. if (prevUrl != currentUrl) {
  14.     prevUrl = currentUrl;
  15.     inject();
  16. }
  17.  
  18. function inject() {
  19.     document.head.insertAdjacentHTML('beforeend', `<style type="text/css">
  20.     correct-answer-x3Ca8B {
  21.     color: lime !important;
  22.     }
  23.     </style>`);
  24. }
  25.  
  26. let url = window.location.href.toString();
  27. if (url.includes("quizizz.com/join/quiz/") && url.includes("/start")) {
  28.     setCookie("hackId", url.split("/")[5], 0.1);
  29.     //window.open(quizDataPath + getCookie("hackId"));
  30.     if (autoProceed) {document.querySelector("body > div > div.root-component > div > div > div > div.pre-game-screen > div.main-action-section > div.action-item-wrapper.default-card-styles.cta-section > div > div > button.primary-button.play-again > i").click();}
  31.     setTimeout(function() {location.reload();}, 100);
  32. }
  33.  
  34. let prevQuestionNum;
  35.  
  36. let tick = setInterval(function() {
  37.     if (document.querySelector("body > div > div.root-component > div > div > div > div.page-container > div > div > div.main-section > div.top-section-wrapper > div > div.actions-container > button.primary-action-btn")) {
  38.         clearInterval(tick);
  39.         clearInterval(next);
  40.         location.reload();
  41.     }
  42.     let newQuestionNum;
  43.     try {
  44.         newQuestionNum = document.getElementsByClassName("current-question")[0].innerHTML;
  45.     } catch(err) {
  46.     }
  47.     if (newQuestionNum != prevQuestionNum) {
  48.         setTimeout(function() {compareQuestion()}, 1000);
  49.         prevQuestionNum = newQuestionNum;
  50.     }
  51. }, 100);
  52.  
  53. let answer;
  54. function compareQuestion() {
  55.     let Choices = document.getElementsByClassName("options-container")[0].children[0].children;
  56.     let currentQuestionText = document.querySelector("#questionText > div");
  57.     let submitButton = document.querySelector("body > div > div.root-component > div > div > div > div.page-container.in-quiz > div.screen.screen-game > div.control-center > div > div.submit-actions.flex-view.all-center.exp-subtext > div.show-tooltip.default > button > span");
  58.     //if (currentQuestionText == null) currentQuestionText = document.querySelector("body > div > div.root-component > div > div > div > div.page-container.in-quiz > div.screen.screen-game > div.transitioner.transitioner-component > div > div > div > div > div > div.question-container.themed > div > div > div > div > p");
  59.     currentQuestionText = currentQuestionText.innerHTML;
  60.     // console.log(currentQuestionText);
  61.     for (let question of Object.keys(questionData)) {
  62.         question = questionData[question];
  63.         let questionText = question.structure.query.text.replaceAll("  ", " ").replace("  ", " ");
  64.         // console.log(questionText);
  65.         if (currentQuestionText == questionText) {
  66.             answer = question.structure.answer;
  67.             if (typeof answer != "object") {
  68.                 // console.log(question.structure.options[answer].text);
  69.                 for (let i = 0; i < Choices.length; i++) {
  70.                     let option = Choices[i].children[0].children[0].children[1].children[0].children[0];//.children[0];
  71.                     if (option.outerHTML == question.structure.options[answer].text.replaceAll("  ", " ").replace("  ", " ")) {
  72.                         option.innerHTML = "<correct-answer-x3Ca8B><u>" + option.innerHTML + "</u></correct-answer-x3Ca8B>"
  73.                         if (autoProceed) {option.click();}
  74.                     }
  75.                 }
  76.             } else {
  77.                 for (let i = 0; i < Choices.length; i++) {
  78.                     let option = Choices[i].children[0].children[0].children[1].children[0].children[0].children[0];
  79.                     for (let index of Object.keys(answer)) {
  80.                         index = answer[index];
  81.                         if (option.outerHTML == question.structure.options[index].text.replaceAll("  ", " ").replace("  ", " ")) {
  82.                             option.innerHTML = "<correct-answer-x3Ca8B><u>" + option.innerHTML + "</u></correct-answer-x3Ca8B>"
  83.                             if (autoProceed) {option.click();}
  84.                         }
  85.                     }
  86.                 }
  87.                 setTimeout(function(){submitButton.click();}, 100);
  88.             }
  89.         }
  90.     }
  91. }
  92.  
  93. let next = setInterval(function(){
  94.     try {
  95.         document.querySelector("div > div.right-navigator-wrapper > div.show-tooltip.error > div.right-navigator:not(.disable)").click();
  96.     } catch(err) {
  97.  
  98.     }
  99. }, 10);
  100.  
  101. function getQuizData() {
  102.     let xhttp = new XMLHttpRequest;
  103.     xhttp.open("GET", quizDataPath + getCookie("hackId"), false);
  104.     xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
  105.     xhttp.send();
  106.     return JSON.parse(xhttp.responseText);
  107. }
  108.  
  109. function setCookie(cname, cvalue, exdays) {
  110.     var d = new Date();
  111.     d.setTime(d.getTime() + (exdays*24*60*60*1000));
  112.     var expires = "expires="+ d.toUTCString();
  113.     document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  114.   }
  115.  
  116. function getCookie(cname) {
  117.     var name = cname + "=";
  118.     var decodedCookie = decodeURIComponent(document.cookie);
  119.     var ca = decodedCookie.split(';');
  120.     for(var i = 0; i <ca.length; i++) {
  121.         var c = ca[i];
  122.         while (c.charAt(0) == ' ') {
  123.         c = c.substring(1);
  124.         }
  125.         if (c.indexOf(name) == 0) {
  126.         return c.substring(name.length, c.length);
  127.         }
  128.     }
  129.     return "";
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement