Greasy Fork

来自缓存

Greasy Fork is available in English.

超星网课助手(测试版)

自动挂机看尔雅MOOC,支持后台、切换窗口不暂停,视频自动切换,屏蔽视频内的题目,倍速播放、进度条拖动、快进快退

当前为 2018-09-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         超星网课助手(测试版)
// @namespace    [email protected]
// @version      0.0.19
// @description  自动挂机看尔雅MOOC,支持后台、切换窗口不暂停,视频自动切换,屏蔽视频内的题目,倍速播放、进度条拖动、快进快退
// @author       wyn665817
// @match        *://*.chaoxing.com/work/doHomeWorkNew*
// @run-at       document-end
// @grant        unsafeWindow
// @license      MIT
// ==/UserScript==

/**
 * 题库:http://116.196.119.76/yuyec.php
 * 注意事项:
 * 1.此版本为自动答题功能独立版,仅具有自动答题功能,建议在指导下使用
 * 2.此版本为测试版,可能与正式版存在冲突,建议在指导下使用
 * 3.如果需要配合正式版使用,需要在正式版中关闭work功能,并且移除或注释第49行代码(针对正式版V1.5.1)
 */

var $ = unsafeWindow.$,
UE = unsafeWindow.UE;

$('body').append(
    '<div style="border: 2px dashed rgb(0, 85, 68); width: 315px; min-height: 0; font-size: 12px; text-align: left; position: fixed; top:0%; right:0%; z-index: 9999; background-color: rgba(70, 196, 38, 0.6); overflow: auto;">' +
        '<a style="text-decoration: none; font-size: medium; width: 315px; display: block; float: left;" id="toNext2">正在搜索答案...</a>' +
        '<button style="text-decoration: none; font-size: large; width: 115px; display: block; float: left;" onclick="location.reload();">重新查询</button>' +
        '<a style="border:0px; text-decoration: none; font-size: large; width: 100px; display: block; float: right;" href="javascript:void(0)" id="zhedie" onclick="$(\'#antable1\').toggle();">折叠面板</a>' +
        '<table width="100%" id="antable1" border="1">' +
            '<tr>' +
                '<td width="60%">题目</td>' +
                '<td width="40%">答案</td>' +
            '</tr>' +
        '</table>' +
    '</div>'
);

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');
    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('<tr><td>' + question + '</td><td>' + obj.data + '</td></tr>');
                fillAnswer(TiMu, obj.data);
                currentQuestionSize++;
            } else {
                $('#toNext2').text(obj.data);
            }
        } else {
            $('#toNext2').text('服务器异常,正在重试...');
        }
    };
    xhr.send('question=' + encodeURIComponent(question) + '&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);
        }
    }
}