Skip to content

Commit 40b1324

Browse files
authored
v1.9.2
Fixed a debugging issue
1 parent ea1e4a0 commit 40b1324

File tree

1 file changed

+110
-110
lines changed

1 file changed

+110
-110
lines changed

QuizizzAssistantV1.js

+110-110
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,111 @@
1-
// ==UserScript==
2-
// @name Quizizz Assistant
3-
// @namespace https://github.com/Jev1337
4-
// @version 1.9.1
5-
// @description Assist with Quizizz by marking correct answers
6-
// @author Malek
7-
// @match https://quizizz.com/join/game/*
8-
// @grant GM_xmlhttpRequest
9-
// @connect api.cheatnetwork.eu
10-
// ==/UserScript==
11-
12-
13-
//ZeroGPT :)
14-
(function() {
15-
'use strict';
16-
17-
function unescape(html) {
18-
const divElement = document.createElement("div");
19-
divElement.innerHTML = html;
20-
return divElement.textContent;
21-
}
22-
23-
24-
function main() {
25-
26-
const processResponse = (apiResponse) => {
27-
const questionElement = document.querySelector(".resizeable.gap-x-2.question-text-color.text-light");
28-
29-
if (questionElement) {
30-
var questionText = questionElement.textContent;
31-
const answer = apiResponse.answers.find((answer) => unescape(answer.question) === questionText);
32-
if (answer) {
33-
const correctAnswerIndexArray = answer.answer;
34-
const correctAnswerText = correctAnswerIndexArray.map(index => answer.options[index].text).join(', ');
35-
console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
36-
for (const a of document.querySelectorAll("p[style='display:inline']")) {
37-
console.debug(a.textContent + " === " + unescape(b));
38-
for (const b of correctAnswerText.split(", ")) {
39-
if (a.textContent === unescape(b)) {
40-
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
41-
}
42-
}
43-
}
44-
}else
45-
console.error("Failed to find answer to the question!");
46-
} else
47-
console.error("Failed to find question element!");
48-
};
49-
50-
const retrieveAnswersButton = document.createElement("button");
51-
retrieveAnswersButton.innerHTML = '<i class="game-end-icon icon-fas-flag-checkered"></i>';
52-
retrieveAnswersButton.id = "retrieveAnswersButton";
53-
retrieveAnswersButton.addEventListener("click",() => processResponse(apiResponse));
54-
document.getElementsByClassName("actions-container")[0].appendChild(retrieveAnswersButton);
55-
document.addEventListener('keydown', (event) => {
56-
if (event.key === 'h') {
57-
if (retrieveAnswersButton.style.visibility == "hidden") {
58-
retrieveAnswersButton.style.visibility = "visible";
59-
} else {
60-
retrieveAnswersButton.style.visibility = "hidden";
61-
}
62-
}
63-
if (event.key === 'p') {
64-
processResponse(apiResponse);
65-
}
66-
});
67-
}
68-
69-
function level1() {
70-
console.log("Trying to get answers of room code: " + code);
71-
GM_xmlhttpRequest({
72-
method: "GET",
73-
url: `https://api.cheatnetwork.eu/quizizz/${code}/answers`,
74-
onload: (response) => {
75-
if (response.status === 200) {
76-
apiResponse = JSON.parse(response.responseText);
77-
console.log('%c Answers Retrieved! ', 'background: #222; color: #bada55');
78-
console.debug(apiResponse);
79-
main();
80-
} else if (response.status === 403) {
81-
console.error("Please login to CheatNetwork to use this script.");
82-
} else {
83-
console.error("Failed to retrieve answers. Please check the room code.");
84-
level1();
85-
}
86-
},
87-
onerror: () => {
88-
console.error("Failed to retrieve answers. Please try again.");
89-
level1();
90-
}
91-
});
92-
}
93-
94-
let apiResponse = null;
95-
var code = "";
96-
let interval = setInterval(function() {
97-
console.log("Checking for room code...");
98-
if (document.getElementsByClassName("room-code").length > 0) {
99-
clearInterval(interval);
100-
code = document.getElementsByClassName("room-code")[0].innerText;
101-
level1();
102-
}
103-
if (document.getElementsByClassName("code").length > 0) {
104-
clearInterval(interval);
105-
code = document.getElementsByClassName("code")[0].innerText;
106-
code = code.replace(/\s/g, '');
107-
level1();
108-
}
109-
}, 1000);
110-
1+
// ==UserScript==
2+
// @name Quizizz Assistant
3+
// @namespace https://github.com/Jev1337
4+
// @version 1.9.2
5+
// @description Assist with Quizizz by marking correct answers
6+
// @author Malek
7+
// @match https://quizizz.com/join/game/*
8+
// @grant GM_xmlhttpRequest
9+
// @connect api.cheatnetwork.eu
10+
// ==/UserScript==
11+
12+
13+
//ZeroGPT :)
14+
(function() {
15+
'use strict';
16+
17+
function unescape(html) {
18+
const divElement = document.createElement("div");
19+
divElement.innerHTML = html;
20+
return divElement.textContent;
21+
}
22+
23+
24+
function main() {
25+
26+
const processResponse = (apiResponse) => {
27+
const questionElement = document.querySelector(".resizeable.gap-x-2.question-text-color.text-light");
28+
29+
if (questionElement) {
30+
var questionText = questionElement.textContent;
31+
const answer = apiResponse.answers.find((answer) => unescape(answer.question) === questionText);
32+
if (answer) {
33+
const correctAnswerIndexArray = answer.answer;
34+
const correctAnswerText = correctAnswerIndexArray.map(index => answer.options[index].text).join(', ');
35+
console.log('%c Answer(s): ' + unescape(correctAnswerText), 'background: #222; color: #bada55');
36+
for (const a of document.querySelectorAll("p[style='display:inline']")) {
37+
for (const b of correctAnswerText.split(", ")) {
38+
console.debug(a.textContent + " === " + unescape(b));
39+
if (a.textContent === unescape(b)) {
40+
a.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.classList.add("option-pressed");
41+
}
42+
}
43+
}
44+
}else
45+
console.error("Failed to find answer to the question!");
46+
} else
47+
console.error("Failed to find question element!");
48+
};
49+
50+
const retrieveAnswersButton = document.createElement("button");
51+
retrieveAnswersButton.innerHTML = '<i class="game-end-icon icon-fas-flag-checkered"></i>';
52+
retrieveAnswersButton.id = "retrieveAnswersButton";
53+
retrieveAnswersButton.addEventListener("click",() => processResponse(apiResponse));
54+
document.getElementsByClassName("actions-container")[0].appendChild(retrieveAnswersButton);
55+
document.addEventListener('keydown', (event) => {
56+
if (event.key === 'h') {
57+
if (retrieveAnswersButton.style.visibility == "hidden") {
58+
retrieveAnswersButton.style.visibility = "visible";
59+
} else {
60+
retrieveAnswersButton.style.visibility = "hidden";
61+
}
62+
}
63+
if (event.key === 'p') {
64+
processResponse(apiResponse);
65+
}
66+
});
67+
}
68+
69+
function level1() {
70+
console.log("Trying to get answers of room code: " + code);
71+
GM_xmlhttpRequest({
72+
method: "GET",
73+
url: `https://api.cheatnetwork.eu/quizizz/${code}/answers`,
74+
onload: (response) => {
75+
if (response.status === 200) {
76+
apiResponse = JSON.parse(response.responseText);
77+
console.log('%c Answers Retrieved! ', 'background: #222; color: #bada55');
78+
console.debug(apiResponse);
79+
main();
80+
} else if (response.status === 403) {
81+
console.error("Please login to CheatNetwork to use this script.");
82+
} else {
83+
console.error("Failed to retrieve answers. Please check the room code.");
84+
level1();
85+
}
86+
},
87+
onerror: () => {
88+
console.error("Failed to retrieve answers. Please try again.");
89+
level1();
90+
}
91+
});
92+
}
93+
94+
let apiResponse = null;
95+
var code = "";
96+
let interval = setInterval(function() {
97+
console.log("Checking for room code...");
98+
if (document.getElementsByClassName("room-code").length > 0) {
99+
clearInterval(interval);
100+
code = document.getElementsByClassName("room-code")[0].innerText;
101+
level1();
102+
}
103+
if (document.getElementsByClassName("code").length > 0) {
104+
clearInterval(interval);
105+
code = document.getElementsByClassName("code")[0].innerText;
106+
code = code.replace(/\s/g, '');
107+
level1();
108+
}
109+
}, 1000);
110+
111111
})();

0 commit comments

Comments
 (0)