Greasy Fork is available in English.

超星尔雅助手

后台静音播放(自动),可以5秒内一节

您查看的为 2018-09-19 提交的版本。查看 最新版本

// ==UserScript==
// @name			超星尔雅助手
// @namespace       http://tampermonkey.net/
// @version			1.0.3
// @description		后台静音播放(自动),可以5秒内一节
// @author			centi_meter
// @match			*://*.chaoxing.com/mycourse/*
// @grant			none
// ==/UserScript==


var player, $;
var setting = {
    cycle : null,
	auto_change : false,     //自动切换课程,仅部分课程可用,可选(即将上线,敬请期待)
    proxy : false,           //自动答题(即将上线,敬请期待)
    drag : false,            //5秒真男人,默认关闭;如若开启把false改为true
};
$ = top.$;


$(document).ready(function(){
    if(new RegExp("study").test(location.href)) add_button();
});

function check()
{
    if(typeof(player) === 'undefined')
    {
        player = $("iframe").contents().find("iframe").contents().find('video#video_html5_api')[0];
        setTimeout(check, 500);
    }
    else
        start();
}

function start()
{
    if(typeof(player) === 'undefined') check();
    else
    {
        if(player.paused){player.play();}
        if(!player.muted){player.muted = true;}
        if((player.duration - player.currentTime) <= 0.35)
        {
            clearTimeout(setting.cycle);
            alert("答题了!");
			player.pause();
        }
        if(setting.drag)
        {
            let time = player.currentTime + player.duration/8;
            if(time >= (player.duration - 2))
            {player.currentTime = player.duration - 1.02;}
            player.currentTime = time;
        }
        setting.cycle = setTimeout(start, 300);
    }
}

function stop()
{
	player.pause();
    clearTimeout(setting.cycle);
}

function re_check()
{
    player = undefined;
    check();
}

function add_button()
{
    let div_block, stop_btn, start_btn;
        // li, check_box;
    div_block = document.createElement("div");
    start_btn = document.createElement("button");
    stop_btn = document.createElement("button");
    // li = document.createElement("li");
    // check_box = document.createElement("input");
    div_block.setAttribute("class", "div_block");
    div_block.setAttribute("style", "position:fixed;left:10%;top:10%");
    // check_box.setAttribute("id", "check_box");
    // check_box.setAttribute("type", "checkbox");
    start_btn.innerHTML = "开始";
    stop_btn.innerHTML = "暂停";
    start_btn.addEventListener('click', re_check);
    stop_btn.addEventListener('click', stop);
    // li.appendChild(check_box);
    // li.appendChild(document.createTextNode("开启自动切换"));
    div_block.appendChild(start_btn);
    div_block.appendChild(stop_btn);
    // div_block.appendChild(li);
    $("body")[0].appendChild(div_block);
}