// ==UserScript==
// @name 超星网课助手(测试版)
// @namespace wyn665817@163.com
// @version 0.0.18
// @description 自动挂机看尔雅MOOC,支持后台、切换窗口不暂停,视频自动切换,屏蔽视频内的题目,倍速播放、进度条拖动、快进快退
// @author wyn665817
// @match *://*.chaoxing.com/work/doHomeWorkNew*
// @run-at document-end
// @grant unsafeWindow
// @license MIT
// @downloadURL none
// ==/UserScript==
/**
* 题库:http://116.196.119.76/yuyec.php
* 注意事项:
* 1.此版本为自动答题功能独立版,仅具有自动答题功能,建议在指导下使用
* 2.此版本为测试版,可能与正式版存在冲突,建议在指导下使用
* 3.如果需要配合正式版使用,需要在正式版中关闭work功能,并且移除或注释第49行代码(针对正式版V1.5.1)
*/
var $ = unsafeWindow.$,
UE = unsafeWindow.UE;
$('body').append(
'
' +
'
正在搜索答案...' +
'
' +
'
折叠面板' +
'
' +
'' +
'题目 | ' +
'答案 | ' +
'
' +
'
' +
'
'
);
var currentQuestionSize = 1,
questionSize = $('.TiMu').length,
timeId = setInterval(function() {
if (currentQuestionSize > questionSize) {
clearInterval(timeId);
$('#toNext2').text('已完成搜索,5秒后开始提交');
setInterval(submitThis, 5E3);
return;
}
var TiMu = $('.TiMu').eq(currentQuestionSize - 1),
question = TiMu.find('.Zy_TItle:eq(0) > .clearfix').text().trim(),
xhr = new XMLHttpRequest();
xhr.open('POST', 'https://www.forestpolice.org/php/get2.php?question=' + encodeURIComponent(question));
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.timeout = 5E3;
xhr.onloadend = function() {
if (xhr.status == 200) {
var obj = JSON.parse(xhr.responseText);
if (obj.code) {
$('#antable1').append('' + question + ' | ' + obj.data + ' |
');
fillAnswer(TiMu, obj.data);
currentQuestionSize++;
} else {
$('#toNext2').text(obj.data);
}
} else {
$('#toNext2').text('服务器异常,正在重试...');
}
};
xhr.send('username=test00&password=123456');
}, 5E3);
function fillAnswer(a, b) {
var c = !1,
d = b.split('#');
$(a).find('ul:eq(0) li').each(function(e, f) {
if (b) {
for (f = 0; f < d.length; f++) - 1 != $(this).find('a').text().trim().indexOf(d[f]) && d[f] && ($(this).find('input').attr('checked', !0), $(this).click(), c = !0);
'正确' == b || '是' == b ? 'true' == $(this).find('input').val() && ($(this).find('input').attr('checked', !0), c = !0) : '错误' != b && '否' != b || 'false' != $(this).find('input').val() || ($(this).find('input').attr('checked', !0), c = !0)
}
e + 1 == $(a).find('ul:eq(0) li').length && 0 == $(a).find('ul:eq(0) input:checked').length && ($(a).find('input').eq(0).attr('checked', !0), c = !1)
});
1 == $(a).find('ul:eq(0) li').length && (UE.getEditor($(a).find('ul:eq(0) li textarea').attr('name')).setContent(b), c = '未找到' != b ? !0 : !1);
return c;
}
function submitThis() {
if ($('#validate', top.document).is(':hidden')) {
if ($('#confirmSubWin').is(':hidden')) {
$('.Btn_blue_1')[0].click();
} else {
var $btn = $('#tipContent').next().children(':first'),
position = $btn.offset(),
mouse = document.createEvent('MouseEvents');
mouse.initMouseEvent('click', true, true, document.defaultView, 0, 0, 0, position.left + Math.floor(46 * Math.random() + 1), position.top + Math.floor(26 * Math.random() + 1));
$btn[0].dispatchEvent(mouse);
}
}
}