UOOC Answer Tester

【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】UOOC Answer Tester(UOOC 答案测试器):测试 UOOC 单选题答案.

当前为 2020-12-31 提交的版本,查看 最新版本

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

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

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         UOOC Answer Tester
// @namespace    http://tampermonkey.net/
// @version      0.1.0
// @description  【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】UOOC Answer Tester(UOOC 答案测试器):测试 UOOC 单选题答案.
// @description:en  【使用前先看介绍/有问题可反馈】【欢迎一键三连(好评+打赏+收藏),你的支持是作者维护下去的最大动力!】UOOC Answer Tester(UOOC 答案测试器):测试 UOOC 单选题答案.
// @author       cc
// @match        http://www.uooc.net.cn/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    window.AnswerTester = {};
    function setOption(option) {
        let questions = frames[0].document.querySelector('.queItems');
        if (typeof option === 'string') {
            for (let i = 1; i < questions.children.length; i++) {
                let options = questions.children[i].querySelectorAll('input');
                options[option.charCodeAt() - 'A'.charCodeAt()].click();
            }
        } else {
            for (let i = 1; i < questions.children.length; i++) {
                let options = questions.children[i].querySelectorAll('input');
                options[option[i - 1].charCodeAt() - 'A'.charCodeAt()].click();
            }
        }
    };
    function getOption() {
        let questions = frames[0].document.querySelector('.queItems');
        let right = [];
        for (let i = 1; i < questions.children.length; i++) {
            let score = questions.children[i].querySelector('.scores span').innerHTML;
            let pattern = /\d+\.?\d*/g;
            score = parseFloat(pattern.exec(score)[0]);
            right.push(Boolean(score > 0));
        }
        return right;
    };
    function findOption(rights) {
        let questionCount = rights[0].length;
        let optionCount = rights.length;
        let answer = [];
        for (let i = 0; i < questionCount; i++) {
            for (let j = 0; j < optionCount; j++) {
                if (rights[j][i]) {
                    answer[i] = String.fromCharCode('A'.charCodeAt() + j);
                    break;
                }
            }
        }
        return answer;
    };
    function main() {
        // copy and execute the following code
        AnswerTester.setOption('A');
        // when you have submitted your answers, please copy and execute the following code
        let r1 = AnswerTester.getOption();
        // copy and execute the following code
        AnswerTester.setOption('B');
        // when you have submitted your answers, please copy and execute the following code
        let r2 = AnswerTester.getOption();
        // copy and execute the following code
        AnswerTester.setOption('C');
        // when you have submitted your answers, please copy and execute the following code
        let r3 = AnswerTester.getOption();
        // copy and execute the following code
        AnswerTester.setOption('D');
        // when you have submitted your answers, please copy and execute the following code
        let r4 = AnswerTester.getOption();
        // please copy and execute the following code
        let r = [r1, r2, r3, r4];
        let answer = AnswerTester.findOption(r);
        AnswerTester.setOption(answer);
        // now you can submit your answers
    };
    window.AnswerTester = {
        setOption: setOption,
        getOption: getOption,
        findOption: findOption,
        main: main,
    };
})();