// ==UserScript== // @name 宏志助航 - 自动播放当前视频 // @namespace https://bbs.tampermonkey.net.cn/ // @version 1.0.2 // @description 视频加载后自动静音、倍速并播放(适配平台自带的自动跳章) // @author 宿院网管(精简版) // @match https://hzzh.chsi.com.cn/kc/xx/* // @grant none // @run-at document-idle // ==/UserScript== (function () { 'use strict'; const PLAYBACK_RATE = 1.0; // 可改为 1.5、2、3 等 // 自动播放单个视频 function autoPlayVideo(video) { if (!video || video.hasAttribute('data-auto-handled')) return; video.setAttribute('data-auto-handled', 'true'); // 防止重复处理 video.muted = true; video.volume = 0; video.playbackRate = PLAYBACK_RATE; // 尝试播放(静音后通常可自动播放) video.play().catch(err => { console.debug('自动播放失败(可能已被播放):', err.message); }); } // 监听页面中视频元素的出现(包括跳章后动态加载的) const observer = new MutationObserver(() => { const video = document.querySelector('video'); if (video && !video.hasAttribute('data-auto-handled')) { autoPlayVideo(video); } }); observer.observe(document.body, { childList: true, subtree: true }); // 初始检查 const initialVideo = document.querySelector('video'); if (initialVideo) { autoPlayVideo(initialVideo); } })();