某自学网站课后习题自动答题提交的油猴脚本
发布时间:2023-07-25 10:46:47
栏目:我的自考
阅读量:2029
作者:南方姑娘
某自学网站课后习题自动答题提交的油猴脚本,需要先在浏览器安装油猴
// ==UserScript==
// @name [当前使用]-[单选+判断]做题脚本
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://cqlg.360xkw.com/gxplatform/gxlearningcenter/questionBank.html?paperId=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
// 单选题
var single_index=1;
var isSingle = false;
// 判断题
var judge_index=1;
var isJudge = false;
var time = setInterval(start, 5000);
function start(){
if(isSingle && isJudge){
clearInterval(time);
if($('#DXsubmitPaper').css('display') != 'none'){
$('#DXsubmitPaper').click();
setTimeout(function(){
$('a.layui-layer-btn0').click();
}, 2000);
}
if($('#submitPaper').css('display') != 'none'){
$('#submitPaper').click();
}
}
if(!isSingle){
singleCode();
}
if(isSingle){
judgeCode();
}
}
// 单选题
function singleCode(){
var singleNumber = $('.single_list div.tm').length;
if(single_index > singleNumber){
isSingle = true;
return;
}
var singleEle = $('#t'+single_index+'').find('.Parsing').find('.parsingInfo:first');
var answerText = $.trim(singleEle.text());
console.log('答案是:', $.trim(answerText));
var ele = $('#t'+single_index+' .redio li');
select(answerText, ele);
single_index++;
}
// 判断题
function judgeCode(){
var judgeNumber = $('.judge_list div.tm').length;
if(judge_index > judgeNumber || judgeNumber == 0){
isJudge = true;
return;
}
var singleEle = $('#p'+judge_index+'').find('.Parsing').find('.parsingInfo:first');
var answerText = $.trim(singleEle.text());
console.log('答案是:', $.trim(answerText));
var ele = $('#p'+judge_index+' .redio li');
select(answerText, ele);
judge_index++;
}
// 执行做题
function select(answerText,ele){
switch(answerText){
case 'A':
ele.eq(0).css('color', 'red');
ele.eq(0).click();
break;
case 'B':
ele.eq(1).css('color', 'red');
ele.eq(1).click();
break;
case 'C':
ele.eq(2).css('color', 'red');
ele.eq(2).click();
break;
case 'D':
ele.eq(3).css('color', 'red');
ele.eq(3).click();
break;
default:
console.log('没有答案');
}
}
})();
标签: 答题脚本,脚本,网课脚本
下一篇:02326 操作系统 小题
评论: