-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZEIT-Akademie-Quiz-Solver.user.js
79 lines (65 loc) · 2.53 KB
/
ZEIT-Akademie-Quiz-Solver.user.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
// ==UserScript==
// @name ZEIT Akademie Quiz Solver
// @author Tosox
// @namespace https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver
// @homepage https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver
// @supportURL https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver/issues
// @updateURL https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver/releases/latest/download/ZEIT-Akademie-Quiz-Solver.user.js
// @downloadURL https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver/releases/latest/download/ZEIT-Akademie-Quiz-Solver.user.js
// @icon https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver/blob/master/readme-res/icon.png?raw=true
// @description Shows the solutions to the current quiz questions
// @version 1.0.2
// @license MIT
// @copyright Copyright (c) 2024 Tosox
// @match https://www.zeitakademie.de/*
// @grant GM_registerMenuCommand
// @grant unsafeWindow
// ==/UserScript==
(function(){
"use strict";
function getCurrentSolution() {
var oQuiz = unsafeWindow.oQuiz
if (!oQuiz) {
return null
}
var currentIndex = oQuiz.quizSession.activeQuestionIndex
if (!oQuiz.quizValues.questions[currentIndex]) {
return null
}
var answers = oQuiz.quizValues.questions[currentIndex].answers
return answers.find(a => a.correctAnswer)
}
GM_registerMenuCommand("Show Solution (S)", function() {
var solution = getCurrentSolution()
if (!solution) {
alert("There is no active quiz at the moment")
return
}
alert(`Answer ${solution.id + 1}: ${solution.answer}`)
}, 's')
GM_registerMenuCommand("Solve Quiz (Q)", function() {
var solution = getCurrentSolution()
if (!solution) {
alert("There is no active quiz at the moment")
return
}
function clickAnswers() {
setTimeout(function() {
var solution = getCurrentSolution()
if (!solution) {
return
}
var btnAnswer = document.getElementById(`button${solution.id}`)
if (btnAnswer) {
btnAnswer.click()
}
var btnNext = document.getElementById("buttonNextCard")
if (btnNext) {
btnNext.click()
}
clickAnswers()
}, 1500)
}
clickAnswers()
}, 'q')
})()