// ==UserScript== // @name 长江雨课堂增强脚本 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 实现长江雨课堂后台播放不暂停,支持多课程同时播放 // @author YourName // @match *://*.yuketang.cn/* // @grant none // ==/UserScript== (function() { 'use strict'; // 1. 禁用后台暂停检测 const disableBackgroundPause = () => { // 方法一:重写pause方法 HTMLVideoElement.prototype.pause = function() { console.log('[拦截] 阻止了视频暂停操作'); return false; }; // 方法二:移除visibilitychange监听 document.removeEventListener('visibilitychange', () => {}); window.addEventListener('visibilitychange', (e) => e.stopImmediatePropagation(), true); }; // 2. 多课程管理功能 const initMultiCourse = () => { // 创建课程容器 const container = document.createElement('div'); container.id = 'multi-course-container'; container.style.position = 'fixed'; container.style.bottom = '20px'; container.style.right = '20px'; container.style.zIndex = '9999'; // 添加控制按钮 const btn = document.createElement('button'); btn.textContent = '新建课程窗口'; btn.style.padding = '8px 16px'; btn.style.background = '#4CAF50'; btn.style.color = 'white'; btn.style.border = 'none'; btn.style.borderRadius = '4px'; btn.style.cursor = 'pointer'; btn.onclick = () => { const courseUrl = window.location.href; window.open(courseUrl, '_blank', 'width=600,height=400'); }; container.appendChild(btn); document.body.appendChild(container); }; // 3. 自动执行初始化 const init = () => { disableBackgroundPause(); initMultiCourse(); console.log('[脚本加载] 长江雨课堂增强功能已启用'); }; // 延迟执行确保DOM加载完成 if (document.readyState === 'complete') { init(); } else { window.addEventListener('load', init); } })();