Greasy Fork

Greasy Fork is available in English.

湖南公需科目学习助手

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         湖南公需科目学习助手
// @namespace    https://www.ejxjy.com/
// @version      0.7
// @description  无
// @author       囧
// @match        https://www.ejxjy.com/a/sys/portal/myCourseDetail.html?*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    //自动获取所有课程链接
    var links = null;
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "https://www.ejxjy.com/a/sys/portal/person");
    xhr.send();
    xhr.onreadystatechange = function() {
        if (xhr.readyState == 4 && xhr.status == 200) {
            var text = xhr.responseText.replace(/\s/g,""); //去除特殊符号
            text = text.match(/con_a_2.+con_a_3/g); //待学习
            links = text[0].match(/myCourseDetail\.html\?courseId=.{32}/g); //匹配网址
            console.log(links.toString(),links.length);
        }
    }

    //定时执行
    window.setInterval(function() {

        var Video = document.getElementsByTagName("video")[0]; //选择video对象
        //课程完成弹窗,播放时间完成
        if (document.getElementsByClassName("jbox-border").length > 0 || Video.duration <= Video.currentTime) {
            var url = window.location.href.match(/myCourseDetail\.html\?courseId=.{32}/g)[0]; //当前URL去除后缀
            var dl = document.getElementsByTagName("dl"); //视频列表,根据背景颜色,判断列表是否已播放
            if (dl[dl.length - 1].outerHTML.indexOf("background-color:#21c703;") > -1 && links.length > 0) {
                url = links[links.indexOf(url) + 1]; //取当前url在links中的下一个
            }
            //window.location.reload() //刷新页面
            window.location.href ="http://www.ejxjy.com/a/sys/portal/" + url;
        }else {
            console.log(new Date().toTimeString(), Video.currentTime, Video.duration); //打印信息
            document.getElementById("one1").click(); //点击(保持页面活动)
        }

    }, 20000)

})();