这是一个针对长江雨课堂的增强脚本,主要功能包括后台播放防暂停和多课程同时播放。脚本通过重写HTMLVideoElement的pause方法和移除visibilitychange监听实现后台持续播放,并支持通过浏览器多开功能同时播放多门课程(建议最多4个浏览器,每个同时播放5节课)。经测试,在办公级电脑配置下运行流畅,但超过6个浏览器或10节课时会出现卡顿。脚本采用Tampermonkey开发,代码开源,用户可自行扩展功能。作者提供了完整的源码实现,包括禁用暂停检测、多课程管理界面等核心功能模块
下边就是源码,有兴趣可以直接复制,有基础可以扩展。如果有问题可以联系我,会更新脚本
可以用链接直接安装 https://scriptcat.org/zh-CN/script-show-page/4200
// ==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);
}
})();