我是宪法小标兵!!

宪法答题自动练习(100%正确率但不支持考试)

目前為 2020-12-04 提交的版本,檢視 最新版本

// ==UserScript==
// @name         我是宪法小标兵!!
// @namespace    XFDT2020
// @version      0.1
// @description  宪法答题自动练习(100%正确率但不支持考试)
// @author       PY-DNG
// @include      http://static.qspfw.com/xf2020/learn-practice.html*
// @include      http://static.qspfw.com/xf2020/learning-page.html*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

(function() {
    'use strict';

    if (location.href.indexOf('learning-page') != -1) {
        if (document.querySelector('#afterClassPractice')) {
            toExam();
        }
        return;
    }


    const red = "rgb(217, 0, 27)";
    const green = "rgb(2, 155, 90)";

    examTime = 100000;
    let choices, question, answer;
    let i, j, curNum, totalNum;
    curNum = Math.floor(document.querySelector('#currentTopic').innerHTML);
    totalNum = Math.floor(document.querySelector('#totalTopic').innerHTML);

    for (j = curNum-1; j < totalNum; j++) {
        choices = document.querySelectorAll('.prev');
        choices[0].click();
        question = document.querySelector('#exam_question').innerHTML;
        for (i = 0; i < choices.length; i++) {
            if (window.getComputedStyle(choices[i]).backgroundColor === green) {
                choices[i].parentElement.click();
                answer = choices[i].parentElement.querySelector('.content').innerHTML;
                GM_setValue(question, answer);
                console.log(question, answer);
                break;
            }
        }
        nextQuestion();
    }
    nextExam();
})();