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.2.0
// @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(), 'Let me go.');
    let tiemOut = 1000*60;  // 检测间隔时间,默认为一分钟(1000*60)一次
    let lists = [];
    let vFlag = '';
    let speed = 1.50;

    let video_list =[];

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

    function setSpeed(){
        let speed_button = document.querySelector('.mejs__speed-button button');
        console.log(Date(),'speed_button: ',speed_button );
        if(speed_button){
            if(speed_button.innerText==='1.00x'){
                let speed = document.querySelector('li.mejs__speed-selector-list-item > input');
                console.log(Date(),'speed: ',speed );
                if(speed){
                    console.log(Date(), 'set speed 1.50x' );
                    speed.click();
                }
            }
        }

    }

    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'))){
                    let iconFont = lists[index].querySelector('.page-icon i.iconfont');
                    if(iconFont.innerText ===vFlag){
                        console.log(Date(), 'not complete, not active. ',lists[index]);
                        lists[index].click();
                        break;
                    }
                }
            }
        }
    }

    function toContinue(){
        let pause = document.querySelector('div.modal-operation button.btn-submit');
        if(pause){
            console.log(Date(),'it is pause, continue...');
            pause.click();
        }
    }

    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);
            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);
                }
            }

            setSpeed();
            toContinue();
        }
        catch(e){
            console.log(Date(), "Error in this userscript: ",e.message);
        }
    }, tiemOut);



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