教师专业发展培训网刷课脚本分享
教师专业发展培训网
# 脚本介绍
该油猴脚本用于 教师专业发展培训网 的辅助看课,使用JavaScript编写,适配网址:https://www.edueva.org/
脚本功能如下:
- 解除视频自动暂停的限制
- 防止页面切换时视频暂停
- 自动播放视频(若无法自动播放,请参考文章:浏览器限制视频无法自动播放)
脚本安装地址:
暂时下架
如果不会安装脚本,请按照下面安装教程来操作。
# 代学服务
提示
如需代学,请联系客服,支持闲鱼交易。

微信联系: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';
const options = {
checkInterval: 1800,
autoPlayDelay: 2500,
debug: false,
autoMute: true,
preventPageLeave: true
};
function log(message) {
if (options.debug) {
console.log('[教师专业发展培训脚本] ' + message);
}
}
function initVisibilityProtection() {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(eventName, listener, captureOrOptions) {
if (eventName === 'visibilitychange' || eventName === 'blur' || eventName === 'focusout') {
log('拦截了 ' + eventName + ' 事件监听器');
return;
}
return originalAddEventListener.call(this, eventName, listener, captureOrOptions);
};
Object.defineProperty(document, 'hidden', {
get: function() {
return false;
},
configurable: true,
enumerable: true
});
Object.defineProperty(document, 'visibilityState', {
get: function() {
return 'visible';
},
configurable: true,
enumerable: true
});
document.addEventListener('visibilitychange', function(event) {
event.stopImmediatePropagation();
event.preventDefault();
log('拦截了 visibilitychange 事件');
}, true);
window.onblur = function() {
log('拦截了 window.onblur');
return false;
};
window.onfocusout = function() {
log('拦截了 window.onfocusout');
return false;
};
}
function findAllVideos() {
const videoElements = document.querySelectorAll('video');
const iframeVideos = [];
const iframes = document.querySelectorAll('iframe');
iframes.forEach(function(iframe) {
try {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
const ivs = iframeDoc.querySelectorAll('video');
ivs.forEach(function(v) {
iframeVideos.push(v);
});
} catch (e) {
}
});
return Array.from(videoElements).concat(iframeVideos);
}
function playAndControlVideos() {
const allVideos = findAllVideos();
allVideos.forEach(function(video, index) {
if (options.autoMute && !video.muted) {
video.muted = true;
video.volume = 0;
log('视频 ' + (index + 1) + ' 已静音');
}
if (video.paused && !video.ended) {
video.play().then(function() {
log('视频 ' + (index + 1) + ' 自动播放成功');
}).catch(function(error) {
log('视频 ' + (index + 1) + ' 自动播放失败: ' + error.message);
simulateUserInteraction(video);
});
}
if (video.ended) {
log('视频 ' + (index + 1) + ' 播放完毕');
navigateToNextLesson();
}
});
}
function simulateUserInteraction(element) {
const mouseEvents = ['mousedown', 'mouseup', 'click'];
mouseEvents.forEach(function(eventType) {
const event = new MouseEvent(eventType, {
bubbles: true,
cancelable: true,
view: window
});
element.dispatchEvent(event);
});
}
function clickPlayButtons() {
const playButtonTexts = ['播放', '开始学习', '继续学习', '开始', '继续'];
const buttons = document.querySelectorAll('button, a, div[role="button"], .play-btn, [class*="play"]');
buttons.forEach(function(btn) {
playButtonTexts.forEach(function(text) {
if (btn.innerText && btn.innerText.indexOf(text) !== -1) {
btn.click();
log('点击了包含 "' + text + '" 的播放按钮');
}
});
});
}
function navigateToNextLesson() {
const nextLessonSelectors = [
'a:contains("下一课")',
'button:contains("下一课")',
'.next-lesson',
'.next-chapter',
'#nextButton',
'[class*="next"]',
'[title*="下一课"]',
'.lesson-item:not(.completed) a'
];
for (let i = 0; i < nextLessonSelectors.length; i++) {
try {
let elements;
if (nextLessonSelectors[i].indexOf(':contains') !== -1) {
const match = nextLessonSelectors[i].match(/:contains\("(.*)"\)/);
if (match) {
const searchText = match[1];
elements = Array.from(document.querySelectorAll('a, button')).filter(function(el) {
return el.innerText && el.innerText.indexOf(searchText) !== -1;
});
}
} else {
elements = document.querySelectorAll(nextLessonSelectors[i]);
}
if (elements && elements.length > 0) {
elements[0].click();
log('成功导航到下一课');
return;
}
} catch (e) {
continue;
}
}
const allLinks = document.querySelectorAll('a');
allLinks.forEach(function(link) {
if (link.innerText && (link.innerText.indexOf('下一课') !== -1 || link.innerText.indexOf('继续') !== -1)) {
link.click();
}
});
}
function preventVideoPauseEvents() {
const allVideos = findAllVideos();
allVideos.forEach(function(video) {
video.addEventListener('pause', function(event) {
if (!video.ended) {
log('检测到视频暂停,尝试恢复播放');
event.preventDefault();
video.play();
}
});
});
}
function simulateUserActivity() {
const mouseMoveEvent = new MouseEvent('mousemove', {
view: window,
bubbles: true,
cancelable: true,
clientX: Math.random() * window.innerWidth,
clientY: Math.random() * window.innerHeight
});
document.body.dispatchEvent(mouseMoveEvent);
const scrollEvent = new Event('scroll', { bubbles: true });
window.dispatchEvent(scrollEvent);
}
function mainLoop() {
playAndControlVideos();
preventVideoPauseEvents();
}
function initializeScript() {
log('脚本初始化中...');
initVisibilityProtection();
setTimeout(function() {
clickPlayButtons();
playAndControlVideos();
}, options.autoPlayDelay);
setInterval(mainLoop, options.checkInterval);
setInterval(simulateUserActivity, 25000);
log('脚本初始化完成');
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
setTimeout(initializeScript, 500);
} else {
document.addEventListener('DOMContentLoaded', function() {
setTimeout(initializeScript, 500);
});
}
})();