forked from WSfg123123/QuizizzHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quizizzGood.js
130 lines (118 loc) · 5.63 KB
/
quizizzGood.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
let quizDataPath = "https://quizizz.com/api/main/quiz/";
let quizData;
let questionData;
let prevUrl = "";
let autoProceed = confirm("Would you like to auto-proceed?");
if (getCookie("hackId") != "") {
quizData = getQuizData();
questionData = quizData.data.quiz.info.questions;
}
let currentUrl = window.location.href;
if (prevUrl != currentUrl) {
prevUrl = currentUrl;
inject();
}
function inject() {
document.head.insertAdjacentHTML('beforeend', `<style type="text/css">
correct-answer-x3Ca8B {
color: lime !important;
}
</style>`);
}
let url = window.location.href.toString();
if (url.includes("quizizz.com/join/quiz/") && url.includes("/start")) {
setCookie("hackId", url.split("/")[5], 0.1);
//window.open(quizDataPath + getCookie("hackId"));
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();}
setTimeout(function() {location.reload();}, 100);
}
let prevQuestionNum;
let tick = setInterval(function() {
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")) {
clearInterval(tick);
clearInterval(next);
location.reload();
}
let newQuestionNum;
try {
newQuestionNum = document.getElementsByClassName("current-question")[0].innerHTML;
} catch(err) {
}
if (newQuestionNum != prevQuestionNum) {
setTimeout(function() {compareQuestion()}, 1000);
prevQuestionNum = newQuestionNum;
}
}, 100);
let answer;
function compareQuestion() {
let Choices = document.getElementsByClassName("options-container")[0].children[0].children;
let currentQuestionText = document.querySelector("#questionText > div");
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");
//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");
currentQuestionText = currentQuestionText.innerHTML;
// console.log(currentQuestionText);
for (let question of Object.keys(questionData)) {
question = questionData[question];
let questionText = question.structure.query.text.replaceAll(" ", " ").replace(" ", " ");
// console.log(questionText);
if (currentQuestionText == questionText) {
answer = question.structure.answer;
if (typeof answer != "object") {
// console.log(question.structure.options[answer].text);
for (let i = 0; i < Choices.length; i++) {
let option = Choices[i].children[0].children[0].children[1].children[0].children[0];//.children[0];
if (option.outerHTML == question.structure.options[answer].text.replaceAll(" ", " ").replace(" ", " ")) {
option.innerHTML = "<correct-answer-x3Ca8B><u>" + option.innerHTML + "</u></correct-answer-x3Ca8B>"
if (autoProceed) {option.click();}
}
}
} else {
for (let i = 0; i < Choices.length; i++) {
let option = Choices[i].children[0].children[0].children[1].children[0].children[0].children[0];
for (let index of Object.keys(answer)) {
index = answer[index];
if (option.outerHTML == question.structure.options[index].text.replaceAll(" ", " ").replace(" ", " ")) {
option.innerHTML = "<correct-answer-x3Ca8B><u>" + option.innerHTML + "</u></correct-answer-x3Ca8B>"
if (autoProceed) {option.click();}
}
}
}
setTimeout(function(){submitButton.click();}, 100);
}
}
}
}
let next = setInterval(function(){
try {
document.querySelector("div > div.right-navigator-wrapper > div.show-tooltip.error > div.right-navigator:not(.disable)").click();
} catch(err) {
}
}, 10);
function getQuizData() {
let xhttp = new XMLHttpRequest;
xhttp.open("GET", quizDataPath + getCookie("hackId"), false);
xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhttp.send();
return JSON.parse(xhttp.responseText);
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}