Greasy Fork

Greasy Fork is available in English.

超星网课助手(测试版)

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

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

/**
 * 注意事项:
 * 1.此版本为考试专版,仅具有细化的考试功能,建议在指导下使用
 * 2.此版本为测试版,可能与正式版存在冲突,使用时建议关闭正式版
 * 3.自动答题功能仅支持单选题、判断题、多选题
 * 4.选择默认选项,即单选题、多选题单选A选项,判断题选择正确
 * 5.其他注意事项会逐步完善
 */

// 设置修改后,需要刷新或重新打开网课页面才会生效
var setting = {
    // 3E3 == 3000,表示毫秒数
    time: 3E3 // 默认响应速度为3秒,不建议小于2秒

    // 1代表开启,0代表关闭
    ,auto: 1 // 自动答题功能,默认开启
    ,retry: 0 // 服务器异常时进行重试,默认关闭
    ,hide: 0 // 隐藏答案搜索提示框,默认关闭

    // 仅开启auto时,修改此处才会生效
    ,jump: 1 // 答题完成后自动切换,默认开启
    ,none: 0 // 未找到答案时选择默认选项,默认关闭

    // 仅开启jump时,修改此处才会生效
    ,other: 0 // 对不支持自动答题的题目进行跳转,默认关闭
},
$ = unsafeWindow.$,
$div = setting.hide ? $() : $(
    '<div style="border: 2px dashed rgb(0, 85, 68); width: 350px; position: fixed; top: 0; right: 0; background-color: rgba(70, 196, 38, 0.6); overflow: auto;">' +
        '<div style="font-size: medium;">正在搜索答案...</div>' +
        '<button>' + (setting.jump ? '点击停止本次切换' : '点击开启自动切换') + '</button>' +
        '<button style="margin-left: 10px;">重新查询</button>' +
        '<table border="1" style="font-size: 12px;">' +
            '<tr>' +
                '<td width="60%">题目</td>' +
                '<td width="40%">答案</td>' +
            '</tr>' +
        '</table>' +
    '</div>'
).appendTo('body');

$div.children('button').on('click', function() {
    var len = $(this).prevAll('button').length;
    if (len == 0) {
        setting.jump = 1 ^ setting.jump;
        $(this).text(setting.jump ? '点击停止本次切换' : '点击开启自动切换');
    } else if (len == 1) {
        $('.current')[0].click();
    }
});

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/unify.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) {
                $div.children('table').append('<tr><td>' + TiMu + '</td><td>' + data + '</td></tr>');
                if (setting.auto) {
                    $div.children('div').text('答案搜索已完成,正在自动答题...');
                    checkBox(data);
                } else {
                    $div.children('div').text('答案搜索已完成,未开启自动答题');
                }
            } else {
                $div.children('div').text(data);
            }
        } else if (setting.retry) {
            $div.children('div').text('服务器异常,正在重新搜索答案');
            setTimeout(findTiMu, setting.time * 2);
        } else {
            $div.children('div').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 {
				var text = $check.eq(index).text().trim();
	            arr.find(function(currentValue) {
	                var tip = text.includes(currentValue);
	                if (tip && !$('#submitTest :checkbox').eq(index).is(':checked')) {
	                    $check.eq(index).click();
	                } else if (!tip && $('#submitTest :checkbox').eq(index).is(':checked')) {
	                	$check.eq(index).click();
	                }
	                return tip;
	            });
            }
            index++;
        }, setting.time);
    } else if (type == '判断题') {
        var $input = $('#submitTest ul input');
        if (event == '正确' || event == '是') {
            $input.eq(0).click();
        } else if (event == '错误' || event == '否') {
            $input.eq(1).click();
        }
        checkDef();
    } else if (type == '单选题') {
        $('#submitTest ul:eq(0) .clearfix').each(function() {
            if ($(this).text().trim().includes(event)) {
                $(this).click();
                return false;
            }
        });
        checkDef();
    } else if (setting.other) {
        jumpTimu(4);
    } else {
        $div.children('div').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 {
            $div.children('div').text('无正确答案,未开启选择默认选项');
            return;
        }
    }
    jumpTimu(id);
}

function jumpTimu(id) {
    var $next = $('.leftBottom a:contains("下一题")');
    if ($next.hasClass('saveYl01')) {
        $div.children('div').text('考试已完成');
    } else {
        var text = '未开启自动切换';
        if (setting.jump) {
            text = '即将切换下一题';
            setTimeout(function() {
                $next[0].click();
            }, setting.time);
        }
        if (id == 1) {
            $div.children('div').text('自动答题已完成,' + text);
        } else if (id == 2) {
            $div.children('div').text('已选择默认选项,' + text);
        } else if (id == 3) {
            $div.children('div').text('未找到匹配的答案,' + text);
        } else if (id == 4) {
            $div.children('div').text('该题型不支持自动答题,' + text);
        }
    }
}