ulearning

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

Από την 15/05/2021. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey 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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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...
})();