|
1 | 1 | // ==UserScript==
|
2 | 2 | // @name Quizizz Assistant
|
3 | 3 | // @namespace https://github.com/Jev1337
|
4 |
| -// @version 1.9.2 |
| 4 | +// @version 1.9.9 |
5 | 5 | // @description Assist with Quizizz by marking correct answers
|
6 | 6 | // @author Malek
|
7 | 7 | // @match https://quizizz.com/join/game/*
|
|
33 | 33 | const correctAnswerIndexArray = answer.answer;
|
34 | 34 | const correctAnswerText = correctAnswerIndexArray.map(index => answer.options[index].text).join(', ');
|
35 | 35 | console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
|
| 36 | + var i = 0; |
36 | 37 | for (const a of document.querySelectorAll("p[style='display:inline']")) {
|
37 | 38 | for (const b of correctAnswerText.split(", ")) {
|
38 | 39 | console.debug(a.textContent + " === " + unescape(b));
|
39 | 40 | if (a.textContent === unescape(b)) {
|
40 | 41 | a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
|
| 42 | + i++; |
41 | 43 | }
|
42 | 44 | }
|
43 | 45 | }
|
44 |
| - }else |
45 |
| - console.error("Failed to find answer to the question!"); |
| 46 | + if (i < correctAnswerText.split(", ").length) { |
| 47 | + console.error("Failed to tag all answers to the question! Retrying with alternate method..."); |
| 48 | + i = 0; |
| 49 | + for (const a of document.querySelectorAll("p[style='display:inline']")) { |
| 50 | + for (const b of correctAnswerText.split(", ")) { |
| 51 | + console.debug(a.textContent + ".includes(" + unescape(b)+ ")"); |
| 52 | + if (a.textContent.includes(unescape(b))) { |
| 53 | + a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed"); |
| 54 | + i++; |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + if (i < correctAnswerText.split(", ").length) |
| 59 | + console.error("Failed to tag answer! Over and Out."); |
| 60 | + else |
| 61 | + console.log("%c Alternate Method Successful!", 'background: #222; color: #bada55'); |
| 62 | + } |
| 63 | + } else { |
| 64 | + console.error("Failed to find answer to the question! Retrying with alternate method..."); |
| 65 | + const answer = apiResponse.answers.find((answer) => unescape(answer.question).includes(questionText)); |
| 66 | + if (answer) { |
| 67 | + const correctAnswerIndexArray = answer.answer; |
| 68 | + const correctAnswerText = correctAnswerIndexArray.map(index => answer.options[index].text).join(', '); |
| 69 | + console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55'); |
| 70 | + i = 0; |
| 71 | + for (const a of document.querySelectorAll("p[style='display:inline']")) { |
| 72 | + for (const b of correctAnswerText.split(", ")) { |
| 73 | + console.debug(a.textContent + " === " + unescape(b)); |
| 74 | + if (a.textContent === unescape(b)) { |
| 75 | + a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed"); |
| 76 | + i++; |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + if (i < correctAnswerText.split(", ").length) { |
| 81 | + console.error("Failed to tag answer to the question! Retrying with alternate method..."); |
| 82 | + i = 0; |
| 83 | + for (const a of document.querySelectorAll("p[style='display:inline']")) { |
| 84 | + for (const b of correctAnswerText.split(", ")) { |
| 85 | + console.debug(a.textContent + ".includes(" + unescape(b) + ")"); |
| 86 | + if (a.textContent.includes(unescape(b))) { |
| 87 | + a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed"); |
| 88 | + i++; |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + if (i < correctAnswerText.split(", ").length) |
| 93 | + console.error("Failed to tag answers to the question! Over and Out."); |
| 94 | + else |
| 95 | + console.log("%c Alternate Method Successful!", 'background: #222; color: #bada55'); |
| 96 | + } |
| 97 | + }else |
| 98 | + console.error("Failed to find answer to the question! Over and Out."); |
| 99 | + } |
| 100 | + |
46 | 101 | } else
|
47 | 102 | console.error("Failed to find question element!");
|
48 | 103 | };
|
49 | 104 |
|
50 | 105 | const retrieveAnswersButton = document.createElement("button");
|
51 | 106 | retrieveAnswersButton.innerHTML = '<i class="game-end-icon icon-fas-flag-checkered"></i>';
|
52 | 107 | retrieveAnswersButton.id = "retrieveAnswersButton";
|
53 |
| - retrieveAnswersButton.addEventListener("click",() => processResponse(apiResponse)); |
| 108 | + retrieveAnswersButton.addEventListener("click", () => processResponse(apiResponse)); |
54 | 109 | document.getElementsByClassName("actions-container")[0].appendChild(retrieveAnswersButton);
|
55 | 110 | document.addEventListener('keydown', (event) => {
|
56 | 111 | if (event.key === 'h') {
|
|
90 | 145 | }
|
91 | 146 | });
|
92 | 147 | }
|
93 |
| - |
| 148 | + |
94 | 149 | let apiResponse = null;
|
95 | 150 | var code = "";
|
96 | 151 | let interval = setInterval(function() {
|
|
0 commit comments