// ==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 // @downloadURL 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, }; })();