Skip to content

Commit 0455bab

Browse files
committed
v1.9.9 and v2.9.9
- Fixed an issue where when a question starts with a space, it doesn't get recognized, same with answers.
1 parent 40b1324 commit 0455bab

File tree

2 files changed

+118
-9
lines changed

2 files changed

+118
-9
lines changed

QuizizzAssistantV1.js

+60-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Quizizz Assistant
33
// @namespace https://github.com/Jev1337
4-
// @version 1.9.2
4+
// @version 1.9.9
55
// @description Assist with Quizizz by marking correct answers
66
// @author Malek
77
// @match https://quizizz.com/join/game/*
@@ -33,24 +33,79 @@
3333
const correctAnswerIndexArray = answer.answer;
3434
const correctAnswerText = correctAnswerIndexArray.map(index => answer.options[index].text).join(', ');
3535
console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
36+
var i = 0;
3637
for (const a of document.querySelectorAll("p[style='display:inline']")) {
3738
for (const b of correctAnswerText.split(", ")) {
3839
console.debug(a.textContent + " === " + unescape(b));
3940
if (a.textContent === unescape(b)) {
4041
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
42+
i++;
4143
}
4244
}
4345
}
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+
46101
} else
47102
console.error("Failed to find question element!");
48103
};
49104

50105
const retrieveAnswersButton = document.createElement("button");
51106
retrieveAnswersButton.innerHTML = '<i class="game-end-icon icon-fas-flag-checkered"></i>';
52107
retrieveAnswersButton.id = "retrieveAnswersButton";
53-
retrieveAnswersButton.addEventListener("click",() => processResponse(apiResponse));
108+
retrieveAnswersButton.addEventListener("click", () => processResponse(apiResponse));
54109
document.getElementsByClassName("actions-container")[0].appendChild(retrieveAnswersButton);
55110
document.addEventListener('keydown', (event) => {
56111
if (event.key === 'h') {
@@ -90,7 +145,7 @@
90145
}
91146
});
92147
}
93-
148+
94149
let apiResponse = null;
95150
var code = "";
96151
let interval = setInterval(function() {

QuizizzAssistantV2.js

+58-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name Quizizz Assistant
33
// @namespace https://github.com/Jev1337
4-
// @version 2.1.1
4+
// @version 2.9.9
55
// @description Assist with Quizizz by marking correct answers
66
// @author Malek
77
// @match https://quizizz.com/join/game/*
@@ -19,26 +19,80 @@
1919
divElement.innerHTML = html;
2020
return divElement.textContent;
2121
}
22+
2223
function main() {
2324
const processResponse = (apiResponse) => {
2425
const questionElement = document.querySelector(".resizeable.gap-x-2.question-text-color.text-light");
25-
26+
2627
if (questionElement) {
2728
var questionText = questionElement.textContent;
2829
const answer = apiResponse.data.answers.find((answer) => unescape(answer.question.text) === questionText);
2930
if (answer) {
3031
const correctAnswerText = answer.answers.map(answer => answer.text).join(', ');
3132
console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
33+
var i = 0;
3234
for (const a of document.querySelectorAll("p[style='display:inline']")) {
3335
for (const b of correctAnswerText.split(", ")) {
3436
console.debug(a.textContent + " === " + unescape(b));
3537
if (a.textContent === unescape(b)) {
3638
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
39+
i++;
40+
}
41+
}
42+
}
43+
if (i < correctAnswerText.split(", ").length) {
44+
console.error("Failed to tag all answers to the question! Retrying with alternate method...");
45+
i = 0;
46+
for (const a of document.querySelectorAll("p[style='display:inline']")) {
47+
for (const b of correctAnswerText.split(", ")) {
48+
console.debug(a.textContent + ".includes(" + unescape(b) + ")");
49+
if (a.textContent.includes(unescape(b))) {
50+
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
51+
i++;
52+
}
3753
}
3854
}
55+
if (i < correctAnswerText.split(", ").length)
56+
console.error("Failed to tag answer! Over and Out.");
57+
else
58+
console.log("%c Alternate Method Successful!", 'background: #222; color: #bada55');
3959
}
40-
} else
41-
console.error("Failed to find answer to the question!");
60+
} else {
61+
console.error("Failed to find answer to the question! Retrying with alternate method...");
62+
answer = apiResponse.data.answers.find((answer) => unescape(answer.question.text).includes(questionText));
63+
if (answer) {
64+
const correctAnswerText = answer.answers.map(answer => answer.text).join(', ');
65+
console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
66+
var i = 0;
67+
for (const a of document.querySelectorAll("p[style='display:inline']")) {
68+
for (const b of correctAnswerText.split(", ")) {
69+
console.debug(a.textContent + " === " + unescape(b));
70+
if (a.textContent === unescape(b)) {
71+
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
72+
i++;
73+
}
74+
}
75+
}
76+
if (i < correctAnswerText.split(", ").length) {
77+
console.error("Failed to tag all answers to the question! Retrying with alternate method...");
78+
i = 0;
79+
for (const a of document.querySelectorAll("p[style='display:inline']")) {
80+
for (const b of correctAnswerText.split(", ")) {
81+
console.debug(a.textContent + ".includes(" + unescape(b) + ")");
82+
if (a.textContent.includes(unescape(b))) {
83+
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
84+
i++;
85+
}
86+
}
87+
}
88+
if (i < correctAnswerText.split(", ").length)
89+
console.error("Failed to tag answer! Over and Out.");
90+
else
91+
console.log("%c Alternate Method Successful!", 'background: #222; color: #bada55');
92+
}
93+
} else
94+
console.error("Failed to find answer to the question! Over and Out.");
95+
}
4296
} else
4397
console.error("Failed to find question element!");
4498
};

0 commit comments

Comments
 (0)