// ==UserScript== // @name 高校考试网(gaoxiaokaoshi.com)答案储存自动测试 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 我的九尾狐奶奶呀,毛概每次测试都不及格,算了还是用笨办法吧。获取答案通过历史测试的试题解析,或者多做题库里面的无限次数测试来增加答案。 // @author Aisen // @match http://www.gaoxiaokaoshi.com/ExamList/ExamPage/* // @run-at document-end // @grant GM_addStyle // @grant unsafeWindow // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js // @license MIT // @downloadURL none // ==/UserScript== var $ = window.jQuery; var out = {}; pannel(); if (localStorage.getItem('题库')) { out = JSON.parse(localStorage.getItem('题库')); logger('log', '目前题库已收录:' + Object.keys(out).length + '题。') } else { logger('log', '题库为空,请先进行试题分析建立题库。') localStorage.setItem('题库', '{}') } var url = window.location.pathname; console.log(url) if (url == '/ExamList/ExamPage/ExamDo.aspx') { logger('log', '开始答题!') doTest() } else if(url == '/ExamList/ExamPage/viewExam.aspx' || url == '/ExamList/ExamPage/ViewExam.aspx'){ logger('log', '开始更新题库!') saveAnswers() } function doTest() { var questions = $('.exam_list dt'); var num = 0; for (var i = 0; i < questions.length; i++) { var question = $(questions[i]).text(); question = question.match(/\.(\S*)\(/)[1]; if (out[question]) { num++; var answers = out[question]; var choices = $('label[for^=tm_' + (i + 1) + '_'); for (var j = 0; j < choices.length; j++) { if (answers.includes($(choices[j]).text().match(/、(\S*)/)[1])) { $(choices[j]).click(); } } //console.log(choices); } } logger('log', '答题完成,有答案的有:' + num + '道题。'); } function saveAnswers() { var ddtms = $("div[id^=ddTm_]"); var num = 0; for (var i = 0; i < ddtms.length; i++) { var div = $(ddtms[i]); var question = div.children('dt').text().match(/[0-9]\.(\S*)\(/)[1]; //console.log(question) var choices = div.find('.green:last').text(); //console.log(choices) var answers = []; for (var j = 0; j < choices.length; j++) { switch (choices[j]) { case '对': answers.push('对'); break; case '错': answers.push('错'); break; case 'A': answers.push($('label[for=tm_' + (i + 1) + '_0').text().slice(2)) break; case 'B': answers.push($('label[for=tm_' + (i + 1) + '_1').text().slice(2)) break; case 'C': answers.push($('label[for=tm_' + (i + 1) + '_2').text().slice(2)) break; case 'D': answers.push($('label[for=tm_' + (i + 1) + '_3').text().slice(2)) break; case 'E': answers.push($('label[for=tm_' + (i + 1) + '_4').text().slice(2)) break; case 'F': answers.push($('label[for=tm_' + (i + 1) + '_5').text().slice(2)) break; case 'G': answers.push($('label[for=tm_' + (i + 1) + '_6').text().slice(2)) break; case 'H': answers.push($('label[for=tm_' + (i + 1) + '_7').text().slice(2)) break; } } //console.log(answers) if (!out[question]) { num++; out[question] = answers; } } logger('log', '已更新:' + num + '题,目前题库已收录:' + Object.keys(out).length + '题。') localStorage.setItem('题库', JSON.stringify(out)) } // Logger function logger(type, msg) { $(".info").text(msg); msg = "[NsumoocStar] " + msg; switch (type) { case 'warn': console.warn(msg); break; case 'log': console.log(msg); break; case 'info': console.info(msg); break; } } //面板 function pannel() { GM_addStyle('.mypanel {position: fixed;overflow: hidden;top: 100px;right: 10px; width: 300px;height: 200px;background-color: rgba(70, 196, 38, 0.6);z-index: 999999;border-radius: 5%;}'); GM_addStyle('.answers, .askMe, .info {height: 70px;line-height: 70px;flote:left;padding-left: 10px;;border-bottom: rgba(0, 0, 0, .2) dashed 2px;font-size: 14px;color:#fff}'); GM_addStyle('.askMe a {color:pink !important;font-size: 17px}'); var html = '
' html += '
我是可爱的标题。(>‿◠)✌
' html += '
' html += '如果有bug,点这反馈。 (゜-゜)つロ ' html += '
' html += '
info
' html += '
' $("body").append(html); }