Greasy Fork

继续教育刷网课

网课视频自动播放下一级

目前为 2021-11-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         继续教育刷网课
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  网课视频自动播放下一级
// @author       JllLp
// @include      http://cqlg.360xkw.com/gxplatform/gxlearningcenter/learning.html*
// @include      http://cqlg.360xkw.com/gxplatform/gxlearningcenter/rebackVideo.html*
// @icon         https://img1.baidu.com/it/u=2298832174,71113162&fm=26&fmt=auto
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    // 获取视频播放元素
    window.onload = function () {
        var video = document.getElementById("live_video");
        // 监听播放完成时间
        video.addEventListener('ended', function(){
            // 获取播放列表元素
            var list = document.getElementsByClassName("layui-colla-content layui-show")[0].children[0].children;
            // 是否触发点击事件
            var isClick = false;
            // 遍历元素,获取正在播放的视频
            for (let i = 0; i < list.length; i++) {
                let li = list[i];
                let temp = li.children[0];
                // 获取到正在播放的视频
                if ('isVideo onLive' === temp.className) {
                    // 设置点击下一个视频
                    isClick = true;
                    continue;
                }
                // 点击下一个视频
                if (isClick) {
                    isClick = false;
                    temp.click();
                    return;
                }
            }
        });
    }

})();