ulearning

课程思政网络培训的视频每隔几分钟会暂停播放,这个脚本可以帮你自动(每分钟检测一次)继续播放,还可以跳过非视频的页面(这个功能没有仔细测试)。只支持在同一个课程内自动播放,播放结束后跳到下一章节,所以请选择一个学分数很大的课程来挂课。

Verze ze dne 16. 05. 2021. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         ulearning
// @namespace    http://tampermonkey.net/
// @version      1.0.5
// @description  课程思政网络培训的视频每隔几分钟会暂停播放,这个脚本可以帮你自动(每分钟检测一次)继续播放,还可以跳过非视频的页面(这个功能没有仔细测试)。只支持在同一个课程内自动播放,播放结束后跳到下一章节,所以请选择一个学分数很大的课程来挂课。
// @author       laohoo
// @match        https://ua.ulearning.cn/learnCourse/learnCourse.html*
// @icon         https://www.google.com/s2/favicons?domain=ulearning.cn
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    console.log(Date(), 'go to do.');
    let tiemOut = 1000*60;  // 检测间隔时间,默认为一分钟(1000*60)一次
    let lists = [];

    function getPlayList(){
        lists = document.querySelectorAll('.page-item div.page-name.cursor');
        console.log(lists);
    }

    function nextPage(){
        let nextBtn = document.querySelector('.next-page-btn');
        let step = 2;
        console.log(Date(), 'next page.');

        let btn_hollow = document.querySelector('button.btn-hollow');
        if(btn_hollow){
            console.log(Date(), 'button.btn-hollow is click.');
            btn_hollow.click();
        }else if(nextBtn){
            console.log(Date(), '.next-page-btn is click.');
            nextBtn.click();
        }
    }

    function nextActivePage(){
        if(lists.length){
            console.log(Date(), 'play lists.');
            for(var index in lists){
                if(!(lists[index].classList.contains('complete')|| lists[index].classList.contains('active'))){
                    console.log(Date(), 'not finish',lists[index]);
                    lists[index].click();
                    break;
                }
            }
        }
    }

    setInterval(function(){
        try{
            let btn_play = document.querySelector('.mejs__overlay-play');
            let playStatus = document.querySelector('div.video-progress  div.text span');
            console.log(Date(), 'btn_play: ',btn_play);
            //let videoWrapper = document.querySelector('.video-wrapper');
            //console.log('videoWrapper: ',videoWrapper);
            if(lists.length<2){
                getPlayList();
            }

            if(!btn_play){
                nextPage();
            }else{
                if(btn_play.style.display!=='none'){
                    if(playStatus.innerText !='已看完'){
                        btn_play.click();
                        console.log(Date(), 'play continue... ');
                    }else{
                        nextActivePage();
                    }
                }else{
                    console.log(Date(), playStatus.innerText);
                }
            }
        }
        catch(e){
            console.log(Date(), "Error in this userscript: ",e.message);
        }
    }, tiemOut);



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