ulearning

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

目前為 2021-05-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         ulearning
// @namespace    http://tampermonkey.net/
// @version      0.2
// @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...
})();