Greasy Fork is available in English.

🔥🔥2023年最新贵州省专业技术人员继续教育自动8倍速刷课时脚本|自动8倍速播放|静音播放|覆盖视频后仍然继续播放|目录视频播放完后循环播放|稳定极高

全新的继续教育自动刷课时脚本

// ==UserScript==
// @name        🔥🔥2023年最新贵州省专业技术人员继续教育自动8倍速刷课时脚本|自动8倍速播放|静音播放|覆盖视频后仍然继续播放|目录视频播放完后循环播放|稳定极高
// @namespace   🔥🔥自动静音播放并在播放完成后自动切换到下一个视频,直至刷完课程,减少繁琐的手动操作。
// @match       http://www.gzjxjy.gzsrs.cn/*
// @match       https://www.gzjxjy.gzsrs.cn/*
// @version     3.1
// @description 全新的继续教育自动刷课时脚本
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    let videoIndex = 0;  // current video index

    function playNextVideo() {
        // Find all video title elements on the page
        let videoTitles = document.querySelectorAll('.step-title');
        if (videoTitles.length > 0 && videoIndex < videoTitles.length) {
            // Click the video title to start the video
            videoTitles[videoIndex].click();

            // Timeout is added here to ensure that video has enough time to load
            setTimeout(function() {
                // Find the video element and attach the 'ended' event listener
                let videos = document.getElementsByTagName('video');
                for (let i = 0; i < videos.length; i++) {
                    videos[i].playbackRate = 8; // Play video at 8x speed
                    videos[i].onended = function() {
                        videoIndex += 1;
                        if (videoIndex < videoTitles.length) {
                            playNextVideo();
                        } else {
                            // All videos have been played, reset the index and start again
                            videoIndex = 0;
                            playNextVideo();
                        }
                    }
                    // If video is paused, play it
                    if (videos[i].paused) {
                        videos[i].play();
                    }
                }
            }, 2000); // Wait for 2 seconds
        }
    }

    // Observe for new videos
    let observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
                var videos = document.getElementsByTagName('video');
                for (var i = 0; i < videos.length; i++) {
                    var video = videos[i];
                    video.setAttribute('autoplay', true);
                    video.setAttribute('muted', true); // Mute the video to bypass Chrome's autoplay policy
                    video.muted = true; // Mute the video

                    // Try to prevent the video from being paused when the tab is not active
                    video.addEventListener('visibilitychange', function() {
                        if (document.visibilityState === 'hidden') {
                            video.play();
                        }
                    }, false);
                }
            }
        });
    });

    observer.observe(document, { childList: true, subtree: true });

    // Start playing videos as soon as the page loads
    setTimeout(playNextVideo, 2000); // Delay 2 seconds before playing

})();