ZEIT Akademie Quiz Solver

Shows the solutions to the current quiz questions

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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
// @icon            https://github.com/Tosox/ZEIT-Akademie-Quiz-Solver/blob/master/assets/icon.png?raw=true
// @description     Shows the solutions to the current quiz questions
// @version         1.0.3
// @license         MIT
// @copyright       Copyright (c) 2025 Tosox
// @match           https://www.zeitakademie.de/*
// @grant           GM_registerMenuCommand
// @grant           GM_notification
// @grant           unsafeWindow
// ==/UserScript==

(function() {
    "use strict";

    function getCurrentSolution() {
        const oQuiz = unsafeWindow.oQuiz;
        if (!oQuiz) {
            return null;
        }

        const currentIndex = oQuiz.quizSession.activeQuestionIndex;
        if (!oQuiz.quizValues.questions[currentIndex]) {
            return null;
        }

        const answers = oQuiz.quizValues.questions[currentIndex].answers;
        return answers.find(a => a.correctAnswer);
    }

    GM_registerMenuCommand("Show Solution (S)", function() {
        const solution = getCurrentSolution()
        if (!solution) {
            GM_notification({
                text: "There is no active quiz at the moment",
                timeout: 3000
            });
            return;
        }

        GM_notification({
            text: `Answer ${Number(solution.id) + 1}: ${solution.answer}`,
            timeout: 3000
        });
    }, 's');

    GM_registerMenuCommand("Solve Quiz (Q)", function() {
        const solution = getCurrentSolution();
        if (!solution) {
            GM_notification({
                text: "There is no active quiz at the moment",
                timeout: 3000
            });
            return;
        }

        function clickAnswers() {
            setTimeout(function() {
                const solution = getCurrentSolution();
                if (!solution) {
                    return;
                }

                const btnAnswer = document.getElementById(`button${solution.id}`);
                if (btnAnswer) {
                    btnAnswer.click();
                }

                const btnNext = document.getElementById("buttonNextCard");
                if (btnNext) {
                    btnNext.click();
                    clickAnswers();
                }
            }, 1500);
        }

        clickAnswers();
    }, 'q');
})()