ulearning

课程思政网络培训的视频每隔几分钟会暂停播放,这个脚本可以帮你自动(每分钟检测一次)继续播放,还可以跳过非视频的页面(这个功能没有仔细测试)。

Stan na 15-05-2021. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         ulearning
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  课程思政网络培训的视频每隔几分钟会暂停播放,这个脚本可以帮你自动(每分钟检测一次)继续播放,还可以跳过非视频的页面(这个功能没有仔细测试)。
// @author       You
// @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...
})();