// ==UserScript== // @name 百度网盘高清播放(个人版) // @namespace http://tampermonkey.net/ // @version 1.0.4 // @description 仅个人使用:替换播放器,获取更高清晰度 m3u8 流(v1.0.4 内置倍速 + document-start 抢先替换,移除会制造额外音频链路的 AudioContext 逻辑) // @author You // @match https://pan.baidu.com/play/video* // @match https://pan.baidu.com/pfile/video* // @require https://unpkg.com/artplayer@5.4.0/dist/artplayer.js // @require https://unpkg.com/hls.js@1.7.3/dist/hls.min.js // @grant unsafeWindow // @grant GM_getValue // @grant GM_setValue // @run-at document-start // ==/UserScript== /* global Artplayer, Hls */ (function () { 'use strict'; /* ========================================================== * 常量与全局状态 * 说明:GM_getValue / GM_setValue 按规格书保留授权, * 但本版本不做设置持久化(规格第七节),因此暂不使用。 * ========================================================== */ const TAG = '[BDHQ]'; const MAX_WAIT = 30000; // 各类等待的最长时间(毫秒) const INTERVAL = 500; // 轮询间隔(毫秒) const state = { videoInfo: null, // 当前视频信息(来自 Pinia) vipLevel: 0, // 如实读取的会员等级:0 普通 / 1 VIP / 2 SVIP qualities: [], // 当前可用清晰度列表 currentQuality: null, // 当前播放的清晰度项 art: null, // ArtPlayer 实例 hls: null, // 当前 hls.js 实例 observer: null, // MutationObserver(路由 / 原播放器重建监控) lastHref: location.href, initializing: false, // 防止初始化流程重入 networkRetry: 0, // hls 致命网络错误计数(用于升级恢复策略) playbackRate: 1 // [v1.0.4] 当前倍速(内置,不再依赖 Global Speed) }; /* ========================================================== * [v1.0.2 新增] 深度媒体清理模块(修改1) * 背景:百度原播放器可能使用独立