// ==UserScript== // @name NUIST/NWAFU/GDOU/QFNU/TSGZY实验室安全测试 // @namespace myetyet // @version 2.3 // @description 南京信息工程大学、西北农林科技大学、广东海洋大学、曲阜师范大学、唐山工业职业技术学院实验室实验室安全网上考试答案自动填充 // @author myetyet // @match http://examsafety.nuist.edu.cn/redir.php?catalog_id=6&cmd=dati // @match https://labsafe.nwafu.edu.cn/redir.php?catalog_id=6&cmd=dati // @match http://210.38.136.71:8090/redir.php?catalog_id=6&cmd=dati // @match http://aqjy.qfnu.edu.cn/redir.php?catalog_id=6&cmd=dati // @match http://aqks.tsgzy.edu.cn/redir.php?catalog_id=6&cmd=dati&moni= // @match https://sys.tzc.edu.cn/labexam/redir.php?catalog_id=6&cmd=dati // @match http://192.168.61.191/redir.php?catalog_id=6&cmd=dati // @require https://greasyfork.org/scripts/391129-nuist-examsafety-question-bank/code/NUIST%20examsafety%20Question%20Bank.js?version=752750 // @run-at document-end // @grant none // @compatible chrome // @license GPL-3.0-only // @downloadURL none // ==/UserScript== (function() { 'use strict'; var questions = document.getElementsByClassName("shiti"); var _question, question, index, answer; var notfounds = new Array(); var dislocations = new Array(); var notfound = 0, dislocation = 0; for (var i = 0; i < questions.length; ++i) { _question = questions[i].children[0].textContent.split("\u3001"); index = _question.shift(); question = _question.join("\u3001").replace(/\s/g, ""); answer = findAnswer(question); var _text, _c, c; var answered = false; if (answer != "") { // console.log(index + "." + answer); for (var choice = 0; choice < questions[i].children[1].childElementCount; ++choice) { var ipt = document.getElementById("ti_" + index + "_" + String(choice)); _text = ipt.parentNode.children[1].textContent.replace(/\s/g, "").replace(/\?/g, ""); if (_text.length == 0) { dislocations[dislocation++] = String(index); questions[i].children[0].setAttribute("style", "color:red"); } else { _c = _text.replace(/\"/g, "\\\"").replace(/\./, "\u3001").replace(/\uff0e/, "\u3001").split("\u3001"); if (_c.length > 1) { _c.shift(); } c = _c.join("\u3001"); if (c == answer) { ipt.click(); answered = true; break; } } } if (!answered) { notfounds[notfound++] = String(index); questions[i].children[0].setAttribute("style", "color:red"); } } else { notfounds[notfound++] = String(index); questions[i].children[0].setAttribute("style", "color:red"); } } if (notfound > 0 || dislocation > 0) { if (notfound > 0) { alert("\u6b64\u9875\u9762\u5171\u6709" + String(notfound) + "\u9053\u9898\u672a\u80fd\u81ea\u52a8\u586b\u5145\uff1a" + notfounds.join("\u3001")); } if (dislocation > 0) { alert("\u6b64\u9875\u9762\u5171\u6709" + String(dislocation) + "\u9053\u9898\u7531\u4e8e\u9009\u9879\u9519\u4f4d\uff0c\u5df2\u9009\u62e9\u6b63\u786e\u4f46\u4e0d\u5f97\u5206\u9009\u9879\uff1a" + dislocations.join("\u3001")); } } else { var next = document.getElementsByClassName("nav")[0].children[0]; if (next && next.value == "\u4e0b\u4e00\u9875") { next.click(); } else { document.getElementsByClassName("nav")[0].children[1].click(); } } })();