郑东新区实验幼儿园教师研修平台刷课脚本分享
郑东新区实验幼儿园
# 脚本介绍
该油猴脚本用于 郑东新区实验幼儿园教师研修平台 的辅助看课,使用JavaScript编写,适配网址:http://zdxqsyyey.zhihuiteacher.com
脚本功能如下:
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('郑东新区实验幼儿园教师研修平台刷课脚本启动');
let scriptConfig = {
playCheckInterval: 1800,
visibilityCheck: true,
autoContinue: true,
debugMode: true,
maxRetryCount: 5
};
let retryCount = 0;
let isScriptRunning = false;
function debugLog(msg) {
if (scriptConfig.debugMode) {
console.log('[郑东幼教研修脚本]', msg);
}
}
function initEventHooks() {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(evtName, handler, opts) {
const blockedEvents = [
'visibilitychange',
'blur',
'focusout',
'mouseleave',
'pagehide'
];
if (blockedEvents.includes(evtName)) {
debugLog('已屏蔽事件: ' + evtName);
return;
}
return originalAddEventListener.call(this, evtName, handler, opts);
};
debugLog('事件钩子初始化完成');
}
function modifyDocumentProperties() {
try {
Object.defineProperty(document, 'hidden', {
get: () => false,
configurable: true,
enumerable: true
});
Object.defineProperty(document, 'visibilityState', {
get: () => 'visible',
configurable: true,
enumerable: true
});
Object.defineProperty(document, 'webkitHidden', {
get: () => false,
configurable: true
});
Object.defineProperty(document, 'webkitVisibilityState', {
get: () => 'visible',
configurable: true
});
debugLog('文档属性已修改');
} catch (e) {
debugLog('属性修改出错: ' + e);
}
}
function protectWindowFocus() {
window.onblur = null;
window.onfocusout = null;
window.addEventListener('blur', function(event) {
event.stopImmediatePropagation();
event.preventDefault();
return false;
}, true);
window.addEventListener('focusout', function(event) {
event.stopImmediatePropagation();
event.preventDefault();
return false;
}, true);
debugLog('窗口焦点保护已启用');
}
function handleVideoElement(video) {
if (!video) return;
video.muted = false;
video.volume = 1;
if (video.paused) {
video.play().then(() => {
debugLog('视频播放成功');
retryCount = 0;
}).catch(err => {
debugLog('视频播放失败: ' + err);
if (retryCount < scriptConfig.maxRetryCount) {
retryCount++;
setTimeout(() => handleVideoElement(video), 1000);
}
});
}
video.addEventListener('pause', () => {
debugLog('检测到视频暂停,尝试恢复');
setTimeout(() => {
if (video.paused) {
video.play();
}
}, 300);
});
video.addEventListener('ended', () => {
debugLog('视频播放结束');
if (scriptConfig.autoContinue) {
findNextLesson();
}
});
video.setAttribute('autoplay', '');
video.setAttribute('controls', '');
}
function scanAndPlayVideos() {
const videoElements = document.querySelectorAll('video');
if (videoElements.length === 0) {
const iframes = document.querySelectorAll('iframe');
iframes.forEach(iframe => {
try {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
const iframeVideos = iframeDoc.querySelectorAll('video');
iframeVideos.forEach(video => handleVideoElement(video));
} catch (e) {
debugLog('无法访问iframe内容: ' + e);
}
});
} else {
videoElements.forEach(video => handleVideoElement(video));
}
}
function findNextLesson() {
const nextButtons = [
'.next-button',
'.next-lesson',
'[class*="next"]',
'button:contains("下一节")',
'button:contains("继续")',
'.continue-btn'
];
for (let selector of nextButtons) {
const btn = document.querySelector(selector);
if (btn && btn.offsetParent !== null) {
debugLog('找到下一课按钮');
btn.click();
break;
}
}
}
function closeNotificationPopups() {
const popupSelectors = [
'.notification',
'.alert-box',
'.modal-overlay',
'.popup-dialog',
'[class*="popup"]',
'[class*="modal"]'
];
popupSelectors.forEach(selector => {
const elements = document.querySelectorAll(selector);
elements.forEach(el => {
const closeBtn = el.querySelector('.close, [class*="close"], button');
if (closeBtn) {
closeBtn.click();
} else {
el.style.display = 'none';
el.remove();
}
});
});
}
function setupDOMObserver() {
const observer = new MutationObserver((mutations) => {
let hasVideoChange = false;
mutations.forEach(mutation => {
if (mutation.addedNodes.length > 0) {
hasVideoChange = Array.from(mutation.addedNodes).some(node =>
node.tagName === 'VIDEO' ||
(node.querySelectorAll && node.querySelectorAll('video').length > 0)
);
}
});
if (hasVideoChange) {
debugLog('检测到视频变化');
scanAndPlayVideos();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
debugLog('DOM观察器已启动');
}
function simulateMouseActivity() {
setInterval(() => {
const x = Math.random() * window.innerWidth;
const y = Math.random() * window.innerHeight;
const mouseEvent = new MouseEvent('mousemove', {
clientX: x,
clientY: y,
bubbles: true
});
document.dispatchEvent(mouseEvent);
}, 45000);
}
function startMainLoop() {
if (isScriptRunning) return;
isScriptRunning = true;
setInterval(() => {
scanAndPlayVideos();
closeNotificationPopups();
}, scriptConfig.playCheckInterval);
debugLog('主循环已启动');
}
function initialize() {
debugLog('开始初始化脚本...');
initEventHooks();
modifyDocumentProperties();
protectWindowFocus();
setupDOMObserver();
simulateMouseActivity();
startMainLoop();
debugLog('脚本初始化完成!');
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initialize);
} else {
initialize();
}
window.addEventListener('load', () => {
setTimeout(initialize, 2000);
});
})();