ZEIT Akademie Quiz Solver

Shows the solutions to the current quiz questions

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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');
})()