ulearning

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

Від 15.05.2021. Дивіться остання версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(У мене вже є менеджер скриптів, дайте мені встановити його!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         ulearning
// @namespace    http://tampermonkey.net/
// @version      0.2
// @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('go to do.');
    let tiemOut = 1000*60;  // 检测间隔时间,默认为一分钟一次
    let lists = [];
    let index = 0;

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

    setInterval(function(){
        try{
            let btn_play = document.querySelector('.mejs__overlay-play');
            //let currentTime = document.querySelector('.mejs__currenttime');
            //let duration = document.querySelector('.mejs__duration');
            let playStatus = document.querySelector('div.video-progress  div.text span');

            //let videoWrapper = document.querySelector('.video-wrapper');
            //console.log('videoWrapper: ',videoWrapper);
            if(lists.length<2){
                getPlayList();
            }

            if(!btn_play){
                let nextBtn = document.querySelector('.next-page-btn');
                if(nextBtn){
                    console.log('next page.');
                    nextBtn.click();
                }
                index++;
                if(lists.length){
                    console.log('play lists.');
                    for(index in lists){
                        let iconfont= lists[index].querySelector('.iconfont');
                        if(!iconfont.classList.contains('finish')){
                            console.log('not finish',lists[index]);
                            lists[index].querySelector('.page-name.cursor').click();
                            break;
                        }
                    }
                }
            }

            console.log('btn_play: ',btn_play);
            //console.log('currentTime: ',currentTime.innerText);
            //console.log('playStatus: ',playStatus.innerText);

            if(btn_play){
                //btn_play.setAttribute('aria-pressed','true');
                if(document.querySelector('.mejs__overlay-button').getAttribute('aria-pressed')==='false'){
                    if(playStatus.innerText !='已看完'){
                        btn_play.click();
                        console.log(Date(), ' play continue... ');
                    }else{
                        if(lists.length){
                            console.log('play lists.');
                            for(index in lists){

                                let iconfont= lists[index].querySelector('.iconfont');

                                if(!iconfont.classList.contains('finish')){
                                    console.log('not finish',lists[index]);
                                    lists[index].querySelector('.page-name.cursor').click();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        catch(e){
            if (window.console){
                window.console.log("Error in this userscript");
            }
        }
    }, tiemOut);



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