说明

随便点击一门课学习即可

已知问题

自动刷新有时会卡住,原因未知(疑似该课程已学习完毕,但页面并未自动跳转),建议偶尔查看一次

解决方案

  • 在看视频页面定时获取主页内容,查找对应ID的课程是否学习完毕,若完毕则关闭本页面,跳转主页自动学习下一门课
  • (偷懒方法)看视频时获取当前视频时长,定时2/3时间后跳转主页(会损失一点观看进度,但胜在稳定)

脚本

// ==UserScript==
// @name 东奥会计人员在线继续教育刷课脚本
// @namespace https://blog.mcraft.cn/s/DongaoStudy.html
// @version 0.1
// @description 东奥会计人员在线继续教育
// @author 7
// @match *://*.dongao.com/*
// @grant none
// ==/UserScript==

(function() {
    var href = location.href;
    var text;
    var i;

    if(href.indexOf("study/u/myCourse")!=-1){
        if(href.indexOf("auto=true")!=-1){
            //我的课程页面
            for(i=0;i<document.getElementsByClassName("operate-a active").length;i++){
                //进入第一门未完成课程
                text = document.getElementsByClassName("operate-a active")[i].innerText;
                if(text=="继续学习" || text=="开始学习"){
                    //自动开始学习
                    document.getElementsByClassName("operate-a active")[i].click();
                    break;
                }
            }
            //关闭页面
            window.close();
        }else{
            setInterval(function(){
                location.reload();
            },300000);

            //GM_setValue("accountId", href.match(/(\d+)/)[1]);
            var tb = document.getElementsByClassName("table all")[0];
            var rows = tb.rows;
            var rowNum = tb.rows.length;

            for (i = (rowNum-1); i >= 1; i--){
                if(rows[i].cells[6].innerText.indexOf("已完成") != -1){
                    tb.deleteRow(i);
                }
            }
        }
    }else if(href.indexOf("lecture/lectureList")!=-1){
        //课程目录页面
        //是否有下一节课
        var findNextCourseID = false;
        var courseID;
        for(i=0;i < document.getElementsByClassName("item-button1").length;i++){
            text=document.getElementsByClassName("item-button1")[i].innerText;
            if(text=="继续学习" || text=="开始学习"){
                var onclickValue = document.getElementsByClassName("item-button1")[i].getAttributeNode("onclick").nodeValue;
                courseID = onclickValue.match(/(\d+),(\d+)/);
                var endhref=href.indexOf("/lecture");
                var prefix=href.substring(endhref);
                findNextCourseID = true;
                break;
                //document.getElementsByClassName("item-button1")[i].click();
                //break;
            }
        }
        //尝试学习下一节课
        if(findNextCourseID == true){
            location.href="http://"+location.host+"/cwweb/videoShow/video/videoPlay?lectureID="+courseID[2]+"&cwID="+courseID[1];
        }else{
            //否则打开主页,并自动学习下一门课
            //location.href = "http://study.dongao.com/study/u/myCourse?accountId=" + GM_getValue("accountId") + "&auto=true";
            jumpToMainPage();
        }
    }else if(href.indexOf("video/videoPlay")!=-1){
        //视频结束后回到主目录
        var currentTime = (new Date()).getTime();
        setInterval(function(){
            //如果90分钟没有
            if((new Date()).getTime() - currentTime > 5400000){
                //checkVideoShow();
                jumpToMainPage();
            }
        },300000);

        document.getElementById('syno-nsc-ext-gen3').click();
        timerReopenMainPage();

        var paused = false;
        //自动点击弹窗
        setInterval(function(){
            var clickSure = document.querySelector(".box-sure");
            if(clickSure != null) clickSure.click();

            //如果视频暂停超过10秒,返回主页/课程目录
            if(isVideoPaused() == true){
                if(paused == true){
                    //checkVideoShow();
                    jumpToMainPage();
                }
                paused = true;
            }else{
                paused = false;
            }
        },10000);
    }
    function checkVideoShow(){
        var endhref=href.indexOf("/videoShow");
        var prefix=href.substring(endhref);
        var cwId=href.substring(href.indexOf("cwID="),href.indexOf("&lectureID"));
        cwId=cwId.substring(5);
        location.href="http://"+location.host+"/cwweb/lecture/lectureList?cwID="+cwId;
    }
    function jumpToMainPage(){
        location.href = "http://study.dongao.com/study/u/myCourse?auto=true";
    }
    function isVideoPaused(){
        return window.video.paused();
    }
    function getVideoTotalTime(){
        return window.video.getTotalTime();
    }
    function timerReopenMainPage(){
        setTimeout(function(){
            if(isVideoPaused()){
                window.video.play();
            }
            setTimeout(function(){
                jumpToMainPage();
            },parseInt(getVideoTotalTime()*1000/2+10000));
        },5000);
    }
})();


- 美国低价服务器,G口带宽,稳定不丢包 -

Last modification:November 23, 2020
If you think my article is useful to you, please feel free to appreciate