UOOC Answer Tester

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

目前為 2021-02-11 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         UOOC Answer Tester
// @name:en      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,
    };
})();