Greasy Fork

Greasy Fork is available in English.

超星网课助手(测试版)

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

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

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

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

    // 1代表开启,0代表关闭
    ,test: 1 // 自动答题功能(考试),高准确率,默认开启

    // 仅开启test时,修改此处才会生效
    ,none: 1 // 未找到答案时选择默认选项,默认开启
},
$ = unsafeWindow.$;

(function() {
    var url = location.pathname;
    if (url.indexOf('exam/test/reVersionTestStartNew') > 0 && setting.test) {
        addStyle('test');
    }
})();

function addStyle(obj) {
    $('head').append(
        '<style>' +
            '#toNext1, #toNext1 + button, #toNext1 ~ a[target=_blank], .TiMu > a {display: none !important;}' +
            'body > div[style]:not([class]) {height: auto !important;min-height: 0px !important;}' +
            'body > div[style]:not([class]):before {content:"正在查找答案...";}' +
        '</style>'
    );
    addNanayun(obj);
}

function addNanayun(obj) {
/**
 * api | nanayun.com
 * https://freejs19.nanayun.com/
 */
    var href = 'https://freejs19.nanayun.com/allcontroller.min.js?refer=ext.qq.com/tampermonkey&version=1.9&t=',
    date = new Date();
    href += date.getFullYear();
    href += date.getMonth() + 1;
    href += date.getDate();
    href += date.getHours();
    href += date.getMinutes() > 30 ? 1 : 0;

    $.ajax({
        url: href,
        dataType: 'script',
        timeout: setting.time,
        complete: function(xhr) {
            if (obj) {
                if (xhr.status) {
                    setInterval(checkBox, setting.time);
                } else {
                	setTimeout(addNanayun, setting.time);
                }
            }
        }
    });
}

function checkBox() {
	if (!$('#antable td:eq(3)').length) {
		return;
	}
	var type = $('.current').parent().prev().text();
	if (type == '多选题') {
		var index = 0,
		arr = $('#antable td:eq(3)').text().trim().split('#'),
		$check = $('#submitTest ul:eq(0) .clearfix');
		setInterval(function() {
			if (index >= $check.length) {
				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 == '判断题' || type == '单选题') {
		checkDef();
	} else if (setting.none) {
        setTimeout(jumpTimu, setting.time);
    }
}

function checkDef() {
	if (!$('#submitTest :checked').length) {
		if (setting.none) {
			$(':radio, :checkbox', '#submitTest').eq(0).click();
		} else {
			return;
		}
	}
	setTimeout(jumpTimu, setting.time);
}

function jumpTimu() {
    $('.leftBottom a:contains("下一题")')[0].click();
}