背景

学习公社平台学习中,需要人工干预才可以连续学习。

安装油猴

自己百度

导入脚本

// ==UserScript==
// home.php?mod=space&uid=170990         学习公社平台
// home.php?mod=space&uid=467642    http://tampermonkey.net/
// home.php?mod=space&uid=1248337      0.3
// @description  try to take over the world!
// home.php?mod=space&uid=686208       You
// home.php?mod=space&uid=195849        https://study.enaea.edu.cn/viewerforccvideo.do?courseId=*&circleId=*
// home.php?mod=space&uid=593100         https://www.google.com/s2/favicons?domain=enaea.edu.cn
// home.php?mod=space&uid=609072        none
// ==/UserScript==

(function() {
    'use strict';

    let isLast = false;
     function gotoNext(){
         let todos = opener.$('table.dataTable tr:contains(%)').filter((i,v)=>{ return $(v).find('td:nth-child(4)').text().indexOf('#') == -1 &&  $(v).find('td:nth-child(5)').text().indexOf('100%') == -1})
         .filter((i,v)=>{ let vurl = $(v).find('a.saveStuCourse').attr('data-vurl'); return location.href.indexOf(vurl) == -1});
            if(todos.length > 0){
                console.log('switch to next.... reload  ');
                let nextCourse =  $(todos[0]);
                nextCourse.find('td').eq(3).text('#')
                let nextVurl = nextCourse.find('a.saveStuCourse').attr('data-vurl');
                location.href = nextVurl;
            }
    }

    function autoSetEvent(){
        setInterval(function(){
            var aud = $("div video").get(0);
            if( $(aud).prop('__ok__') != true){
                aud.addEventListener("ended", video_ended);
                console.log("add ended event listener.")
                $(aud).prop('__ok__',true);

                isLast = $('ul.cvtb-MCK-course-list li.last').text() == $('ul.cvtb-MCK-course-list li.current').text();

                let notStudyList = $('div.cvtb-MCK-CsCt-studyProgress').filter((i,v)=>$(v).text().indexOf('100%') == -1);
                if(notStudyList.length == 0){
                    gotoNext();
                }
                else if(notStudyList.length > 0 && $('ul.cvtb-MCK-course-list li.current').find('div.cvtb-MCK-CsCt-studyProgress').text().indexOf('100%') === 0){
                        notStudyList.eq(0).parent().click();
                }
            }

            $('.dialog-button-container button:contains(继续学习)').click()
        },3000);
    }

    function video_ended() {
        console.log("The audio has ended");

        if(isLast){
            console.log('switch to next.... ');       

           gotoNext();
        }
    }

    setTimeout(function(){
        // debugger;
        $(".continue .user_choise").click()
        autoSetEvent();
    },3000);

    // Your code here...
})();