巴中开放大学-专业技术人员继续教育基地刷课脚本分享
巴中开放大学
# 脚本介绍
该油猴脚本用于 巴中开放大学-专业技术人员继续教育基地 的辅助看课,使用JavaScript编写,适配网址:https://bzys.jjyxt.cn/home
脚本功能如下:
1.自动播放课程视频
2.解除视频播放限制
3.防止页面切换导致学习暂停
4.智能监控视频状态
5.自动处理各种播放障碍
脚本安装地址:
暂时下架
如果不会安装脚本,请按照下面安装教程来操作。
# 代学服务
提示
如需代学,请联系客服,支持闲鱼交易。

微信联系:yizhituziang

QQ联系:2422270452
- img: /img/weixin.jpg
name: 微信联系:yizhituziang
- img: /img/qq.jpg
name: QQ联系:2422270452
# 安装教程
# 1.安装浏览器扩展插件
首先需要给我们的浏览器安装上脚本猫插件,这是运行所有用户脚本的基础,如果浏览器已经安装过了脚本猫或者油猴插件,那么可以跳过这一步。推荐使用edge浏览器,安装插件更方便。
浏览器打开网址:https://docs.scriptcat.org/ (opens new window)
这里用edge浏览器作为示范,点击 "添加到Edge浏览器"

接着点击 "获取"

在右上角弹出的窗口,点击 "添加扩展"

等待几秒钟,会提示已经安装好脚本猫插件了。

# 2.安装刷课脚本
打开脚本安装地址后,在页面点击 "安装脚本" 按钮,接着在弹出的窗口点击 "安装" ,之后就会提示"安装成功"。
# 3.体验脚本功能
安装脚本后,需要重新进入学习站点,如果之前已经打开课程学习页面,那么需要刷新页面后脚本才会生效。
# 核心代码
(function() {
'use strict';
console.log('巴中开放大学继续教育基地刷课脚本已加载');
const settings = {
checkInterval: 2200,
enableDebug: true,
autoPlayEnabled: true,
preventPause: true,
speed: 1.0
};
let initialized = false;
function log(message) {
if (settings.enableDebug) {
console.log('[巴中开放大学脚本]', message);
}
}
function setupEventInterception() {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(eventName, callback, options) {
const restrictedEvents = [
'visibilitychange',
'blur',
'focusout',
'mouseout',
'pagehide'
];
if (restrictedEvents.includes(eventName)) {
log('已拦截受限事件: ' + eventName);
return;
}
return originalAddEventListener.call(this, eventName, callback, options);
};
log('事件拦截系统已设置');
}
function modifyVisibilityProperties() {
try {
Object.defineProperty(document, 'hidden', {
get: function() { return false; },
configurable: true,
enumerable: true
});
Object.defineProperty(document, 'visibilityState', {
get: function() { return 'visible'; },
configurable: true,
enumerable: true
});
if (typeof document.msHidden !== 'undefined') {
Object.defineProperty(document, 'msHidden', {
get: function() { return false; },
configurable: true
});
}
if (typeof document.msVisibilityState !== 'undefined') {
Object.defineProperty(document, 'msVisibilityState', {
get: function() { return 'visible'; },
configurable: true
});
}
log('可见性属性已修改');
} catch (error) {
log('属性修改错误: ' + error.message);
}
}
function setupWindowProtection() {
window.onblur = null;
window.onfocusout = null;
window.onmouseleave = null;
window.addEventListener('blur', function(e) {
e.stopImmediatePropagation();
e.preventDefault();
return false;
}, true);
window.addEventListener('focusout', function(e) {
e.stopImmediatePropagation();
e.preventDefault();
return false;
}, true);
log('窗口失焦防护已激活');
}
function processVideo(videoElement) {
if (!videoElement) return;
videoElement.muted = false;
videoElement.volume = 1;
if (videoElement.paused && settings.autoPlayEnabled) {
videoElement.play().then(() => {
log('视频开始播放');
}).catch(err => {
log('播放失败: ' + err);
setTimeout(() => processVideo(videoElement), 1500);
});
}
if (videoElement.playbackRate !== settings.speed) {
videoElement.playbackRate = settings.speed;
}
if (settings.preventPause) {
videoElement.addEventListener('pause', function() {
log('检测到暂停,尝试恢复');
setTimeout(() => {
if (videoElement.paused) {
videoElement.play();
}
}, 500);
});
}
videoElement.setAttribute('autoplay', 'autoplay');
videoElement.setAttribute('playsinline', '');
}
function scanAllVideos() {
const videos = document.querySelectorAll('video');
if (videos.length > 0) {
videos.forEach((video, index) => {
log('处理视频 #' + (index + 1));
processVideo(video);
});
} else {
const iframes = document.querySelectorAll('iframe');
iframes.forEach(iframe => {
try {
const iframeWindow = iframe.contentWindow;
const iframeDocument = iframeWindow.document;
const iframeVideos = iframeDocument.querySelectorAll('video');
iframeVideos.forEach(video => processVideo(video));
} catch (e) {
log('iframe访问受限: ' + e);
}
});
}
}
function closeAllPopups() {
const popupSelectors = [
'.popup',
'.modal',
'.dialog',
'.alert',
'[class*="popup"]',
'[class*="modal"]',
'[class*="dialog"]'
];
popupSelectors.forEach(selector => {
const elements = document.querySelectorAll(selector);
elements.forEach(el => {
const closeButton = el.querySelector(
'.close, .close-btn, [aria-label*="close"], button'
);
if (closeButton) {
closeButton.click();
log('通过按钮关闭弹窗');
} else {
el.style.display = 'none';
el.style.visibility = 'hidden';
el.style.opacity = '0';
}
});
});
}
function setupMutationObserver() {
const observer = new MutationObserver((mutations) => {
let videoDetected = false;
mutations.forEach(mutation => {
if (mutation.addedNodes.length > 0) {
videoDetected = Array.from(mutation.addedNodes).some(node =>
node.tagName === 'VIDEO' ||
(node.querySelectorAll && node.querySelectorAll('video').length > 0)
);
}
});
if (videoDetected) {
log('检测到新视频元素');
scanAllVideos();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
log('DOM变化观察器已启动');
}
function simulateUserActions() {
const actions = ['mousemove', 'keydown', 'click'];
setInterval(() => {
const action = actions[Math.floor(Math.random() * actions.length)];
const event = new Event(action, { bubbles: true });
document.dispatchEvent(event);
}, 50000);
log('用户行为模拟已启动');
}
function findNextLessonButton() {
const buttonSelectors = [
'.next',
'.next-lesson',
'.continue',
'[class*="next"]',
'button:contains("下一节")',
'button:contains("继续")'
];
for (let selector of buttonSelectors) {
const button = document.querySelector(selector);
if (button && button.offsetParent !== null) {
log('发现下一课按钮');
return button;
}
}
return null;
}
function startMainLoop() {
setInterval(() => {
scanAllVideos();
closeAllPopups();
const nextBtn = findNextLessonButton();
if (nextBtn) {
log('准备点击下一课');
}
}, settings.checkInterval);
log('主循环已启动');
}
function initScript() {
if (initialized) return;
log('开始初始化...');
setupEventInterception();
modifyVisibilityProperties();
setupWindowProtection();
setupMutationObserver();
simulateUserActions();
startMainLoop();
initialized = true;
log('初始化完成!');
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initScript);
} else {
initScript();
}
window.addEventListener('load', function() {
setTimeout(initScript, 1500);
});
})();