hlstudy.scbaixin.net自动跳转下一个视频

hlstudy.scbaixin.net自动跳转下一个视频,在视频播放完成后自动跳转到下一个lesson

目前為 2024-12-08 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         hlstudy.scbaixin.net自动跳转下一个视频
// @version      1.0
// @description  hlstudy.scbaixin.net自动跳转下一个视频,在视频播放完成后自动跳转到下一个lesson
// @author       Your Name
// @match        http://hlstudy.scbaixin.net/study/lesson/content/*
// @grant        none
// @namespace https://greasyfork.org/users/1402509
// ==/UserScript==
(function() {
    'use strict';

    // 检查当前域名是否为 hlstudy.scbaixin.net
    if (window.location.hostname === 'hlstudy.scbaixin.net') {
        // 等待视频元素加载完成
        const observer = new MutationObserver((mutationsList, observer) => {
            for (let mutation of mutationsList) {
                if (mutation.type === 'childList') {
                    const video = document.getElementById('studyvideo');
                    if (video) {
                        // 视频元素加载完成后自动播放
                        video.play();

                        // 监听视频播放完成事件
                        video.addEventListener('ended', function() {
                            // 获取当前lesson的值
                            const currentLesson = parseInt(new URLSearchParams(window.location.search).get('lesson'));

                            // 计算下一个lesson的值
                            const nextLesson = currentLesson + 1;

                            // 构建新的URL
                            const newUrl = window.location.origin + window.location.pathname +
                                           '?course=' + new URLSearchParams(window.location.search).get('course') +
                                           '&lesson=' + nextLesson +
                                           '&status=' + new URLSearchParams(window.location.search).get('status');

                            // 跳转到新的URL
                            window.location.href = newUrl;
                        });

                        // 停止观察
                        observer.disconnect();
                        break;
                    }
                }
            }
        });

        // 配置观察选项
        const config = { childList: true, subtree: true };

        // 开始观察document.body
        observer.observe(document.body, config);
    }
})();