// ==UserScript==
// @name 超星网课助手(测试版)
// @namespace wyn665817@163.com
// @version 0.0.16
// @description 自动挂机看尔雅MOOC,支持后台、切换窗口不暂停,视频自动切换,屏蔽视频内的题目,倍速播放、进度条拖动、快进快退
// @author wyn665817
// @match *://*.chaoxing.com/exam/test/reVersionTestStartNew*
// @run-at document-end
// @grant unsafeWindow
// @license MIT
// @downloadURL none
// ==/UserScript==
/**
* 题库:https://freejs19.nanayun.com/(网站暂时关闭,但不影响自动答题功能)
* 注意事项:
* 1.此版本为考试专版,仅具有细化的考试功能,建议在指导下使用
* 2.此版本为测试版,可能与正式版存在冲突,使用时建议关闭正式版
* 3.自动答题功能仅支持单选题、判断题、多选题
* 4.选择默认选项,即单选题、多选题单选A选项,判断题选择正确
* 5.其他注意事项会逐步完善
*/
// 设置修改后,需要刷新或重新打开网课页面才会生效
var setting = {
// 3E3 == 3000,表示毫秒数
time: 3E3 // 默认响应速度为3秒,不建议小于2秒
// 1代表开启,0代表关闭
,test: 1 // 自动搜索题目答案,高准确率,默认开启
// 仅开启test时,修改此处才会生效
,auto: 1 // 自动答题功能,默认开启
,retry: 0 // 服务器异常时进行重试,默认关闭
// 仅开启auto时,修改此处才会生效
,jump: 1 // 答题完成后自动切换,默认开启
,none: 0 // 未找到答案时选择默认选项,默认关闭
// 仅开启jump时,修改此处才会生效
,other: 0 // 对不支持自动答题的题目进行跳转,默认关闭
},
$ = unsafeWindow.$;
if (setting.test) {
$('body').append(
'
' +
'
正在搜索答案...' +
'
' +
'' +
'题目 | ' +
'答案 | ' +
'
' +
'
' +
'
'
);
setTimeout(findTiMu, setting.time);
}
function findTiMu() {
var TiMu = $('.TiMu .Cy_TItle .clearfix').text().trim(),
xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.forestpolice.org/php/get.php');
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.timeout = setting.time * 4;
xhr.onloadend = function() {
if (xhr.status == 200) {
var obj = JSON.parse(xhr.responseText),
data = obj.data.trim();
if (obj.code) {
$('#antable').append('' + TiMu + ' | ' + data + ' |
');
if (setting.auto) {
$('#toNext2').text('答案搜索已完成,正在自动答题...');
checkBox(data);
} else {
$('#toNext2').text('答案搜索已完成,未开启自动答题');
}
} else {
$('#toNext2').text(data);
}
} else if (setting.retry) {
$('#toNext2').text('服务器异常,正在重新搜索答案');
setTimeout(findTiMu, setting.time * 2);
} else {
$('#toNext2').text('服务器异常,未开启自动重试');
}
};
xhr.send('question=' + encodeURIComponent(TiMu) + '&username=test00&password=123456');
}
function checkBox(event) {
var type = $('.current').parent().prev().text();
if (type == '多选题') {
var index = 0,
arr = event.split('#'),
$check = $('#submitTest ul:eq(0) .clearfix'),
timeid = setInterval(function() {
if (index >= $check.length) {
clearInterval(timeid);
checkDef();
} else if ($.inArray($check.eq(index).text().trim(), arr) + 1) {
if (!$('#submitTest :checkbox').eq(index).is(':checked')) {
$check.eq(index).click();
}
} else if ($('#submitTest :checkbox').eq(index).is(':checked')) {
$check.eq(index).click();
}
index++;
}, setting.time);
} else if (type == '判断题') {
var $input = $('#submitTest ul input');
if (event == '正确') {
$input.eq(0).click();
} else if (event == '错误') {
$input.eq(1).click();
}
checkDef();
} else if (type == '单选题') {
$('#submitTest ul:eq(0) .clearfix').each(function() {
if ($(this).text().trim() == event) {
$(this).click();
return false;
}
});
checkDef();
} else if (setting.other) {
jumpTimu(4);
} else {
$('#toNext2').text('该题型不支持自动答题,请手动完成');
}
}
function checkDef() {
var id = 1;
if (!$('#submitTest :checked').length) {
if (setting.none) {
$(':radio, :checkbox', '#submitTest').eq(0).click();
id = 2;
} else if (setting.other) {
id = 3;
} else {
$('#toNext2').text('无正确答案,未开启选择默认选项');
return;
}
}
jumpTimu(id);
}
function jumpTimu(id) {
var $next = $('.leftBottom a:contains("下一题")');
if ($next.hasClass('saveYl01')) {
$('#toNext2').text('考试已完成');
} else {
var text = '未开启自动切换';
if (setting.jump) {
text = '即将切换下一题';
setTimeout(function() {
$next[0].click();
}, setting.time);
}
if (id == 1) {
$('#toNext2').text('自动答题已完成,' + text);
} else if (id == 2) {
$('#toNext2').text('已选择默认选项,' + text);
} else if (id == 3) {
$('#toNext2').text('未找到匹配的答案,' + text);
} else if (id == 4) {
$('#toNext2').text('该题型不支持自动答题,' + text);
}
}
}