Greasy Fork

来自缓存

Greasy Fork is available in English.

河北省专业技术人员继续教育

实现网课视频16倍速播放(未实现自动连播)

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         河北省专业技术人员继续教育
// @namespace    http://tampermonkey.net/
// @version      2.2.1
// @description  实现网课视频16倍速播放(未实现自动连播)
// @author       [email protected]
// @match        https://contentzyjs.heb12333.cn/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    function setVideoSpeed() {
        document.querySelectorAll('video').forEach(v => v.playbackRate = 16);
    }

    setVideoSpeed();

    new MutationObserver(mutations =>
        mutations.forEach(({ addedNodes }) =>
            addedNodes.forEach(node => node.tagName === 'VIDEO' && (node.playbackRate = 16))
        )
    ).observe(document.body, { childList: true, subtree: true });

    // 定期检测是否出现限制弹窗
    setInterval(function() {
        // 使用更精确的选择器定位弹窗
        const popupElement = document.querySelector('.layui-layer-dialog[times="2"] .layui-layer-content');
        if (popupElement && popupElement.textContent.includes('不允许倍速观看')) {
            console.log('Popup detected, attempting to close');

            // 自动关闭弹窗
            const closeButton = document.querySelector('.layui-layer-dialog[times="2"] .layui-layer-close1');
            if (closeButton) {
                closeButton.click();
                console.log('Popup closed');
            } else {
                // 如果无法自动关闭,提示用户手动关闭
                alert('请手动关闭弹窗以继续观看');
            }

            // 再次设置播放速率为16倍
            const videoElement = document.querySelector('video');
            if (videoElement) {
                videoElement.playbackRate = 16;
                console.log('Playback rate reset to 16x');
            }

            // 查找跳过按钮并模拟点击
            const skipButton = document.querySelector('.skip-button');
            if (skipButton) {
                skipButton.click();
                console.log('Skip button clicked');
            }
        }
    }, 500);
})();