// ==UserScript== // @name 学习通视频加速器-强制开倍数,快速通过视频 // @namespace qinghy-10 // @version 1.2 // @description 为“学习通”视频播放器新增多档倍速播放功能,支持 0.5x、1x、1.25x、1.5x、2.0x、4.0x 等多种播放速度,让用户灵活掌控学习节奏,高效完成课程内容。该功能采用先进的音频时间拉伸技术,在加速或减速播放时仍能保持音调自然清晰,显著提升网课学习效率与观看体验。(支持视频:超星学习通 | 智慧树 | MOOC | 继续教育类 | 优课学堂 | 青书学堂 | 优学院 | 中国大学mooc | 智慧职教 | 青书学堂 )学习通交流群:74028813 欢迎大家一起学习 // @author 学习助手 // @license MIT // @icon https://pan-yz.chaoxing.com/favicon.ico // @match https://*.chaoxing.com/* // @match https://*passport.zhihuishu.com/* // @match https://*iam.pt.ouchn.cn/* // @match https://chaoxing.com/* // @match https://mooc*.chaoxing.com/* // @match https://*.www.icourse163.org/ // @match https://i.mooc.chaoxing.com/* // @match https://dushu.chaoxing.com/* // @grant none // @run-at document-idle // ==/UserScript== (function () { 'use strict'; // 防止重复注入 if (document.getElementById('speedControlPanel')) return; // 检查当前页面是否有 video 元素(适用于顶层或 iframe) function hasVideo() { return document.querySelector('video') !== null; } function addSpeedControlPanel() { const panel = document.createElement('div'); panel.id = 'speedControlPanel'; panel.innerHTML = `
▶ 播放速度
当前: 1.0x
`; document.body.appendChild(panel); const style = document.createElement('style'); style.textContent = ` .speed-btn { background: #1e88e5; border: none; color: white; padding: 4px 8px; margin: 2px; cursor: pointer; border-radius: 4px; font-size: 12px; transition: background 0.2s; } .speed-btn:hover { background: #1976d2; } .speed-btn:active { transform: scale(0.95); } `; document.head.appendChild(style); const buttons = panel.querySelectorAll('.speed-btn'); buttons.forEach(btn => { btn.addEventListener('click', function () { const speed = parseFloat(this.dataset.speed); setPlaybackRate(speed); }); }); // 初始化显示 const video = document.querySelector('video'); if (video) { updateCurrentSpeed(video.playbackRate); } } function setPlaybackRate(rate) { const videos = document.querySelectorAll('video'); videos.forEach(v => { try { v.playbackRate = rate; updateCurrentSpeed(rate); } catch (e) { console.warn('无法设置播放速度:', e); } }); } function updateCurrentSpeed(rate) { const el = document.getElementById('currentSpeed'); if (el) { el.textContent = rate + 'x'; } } // 尝试初始化 function tryInit() { if (hasVideo() && !document.getElementById('speedControlPanel')) { // 确保 body 已存在 if (document.body) { addSpeedControlPanel(); } } } // 立即尝试 if (document.readyState === 'loading') { window.addEventListener('DOMContentLoaded', tryInit); } else { tryInit(); } // 轮询 + MutationObserver 双保险 const observer = new MutationObserver(() => { if (hasVideo() && !document.getElementById('speedControlPanel')) { tryInit(); } }); observer.observe(document.documentElement || document.body, { childList: true, subtree: true }); // 每3秒兜底检查 setInterval(tryInit, 3000); })();