天津市执业药师协会刷课脚本分享
# 说点实在的
嗯... 天津的执业药师继续教育平台,说实话,用起来真的有点费劲。前阵子天津和平区的小李还找我吐槽,说这个平台的视频老是暂停,一不留神切换个网页,回来就发现视频停了,进度条一动不动。而且视频播放器也挺奇怪的,有时候进度条会卡半天,刷新一下才能好,浪费时间不说,心情也搞的很烦躁。
对了,这个平台的网址是 http://tj.mtnet.com.cn/login2022 ,天津的药师朋友们应该都很熟悉这个地址吧。
那天早上我刚喝完豆浆,就想着能不能写个脚本解决这个问题,毕竟每天要花好几个小时在上面,手动盯着太熬人了。经过几天的折腾,终于弄出了个能用的版本。
这个脚本主要是用JavaScript写的油猴脚本,专门适配天津市执业药师协会的这个学习平台。功能嘛,大概有这么几个:自动播放视频,检测到暂停就自动继续播放;倍速播放,默认1.5倍,但有些课程可能限制只能1.25倍;还有防闲置的功能,每隔8秒模拟一下鼠标移动,免得平台检测到你不在就给暂停了;视频放完了还能自动切换到下一节课,省得你手动去点。另外还加了点防检测的东西,通过模拟用户行为和修改浏览器属性,尽量不让平台看出来是脚本在运行。
不过啊,脚本安装地址暂时下架了,大家如果有需要的话...
提示
如需代学,请联系客服,支持闲鱼交易。

微信联系:yizhituziang

QQ联系:2422270452
- img: /img/weixin.jpg
name: 微信联系:yizhituziang
- img: /img/qq.jpg
name: QQ联系:2422270452
# 怎么用呢?
如果有脚本的话,安装其实也不难。首先得给浏览器装个脚本猫或者油猴插件,这是基础。推荐用Edge浏览器,装插件比较方便。
打开 https://docs.scriptcat.org/ 这个网址,用Edge浏览器的话,直接点"添加到Edge浏览器"就行。

然后点"获取"

右上角会弹个窗口,点"添加扩展"

等个几秒钟,就提示安装好了。

装完插件后,打开脚本安装地址,点"安装脚本"按钮,再点"安装"就行。
装好脚本后,得重新进学习站点,之前打开的页面要刷新一下,脚本才会生效。
# 核心代码
// 配置对象,可根据需要修改参数
const scriptConfig = {
autoPlayEnabled: true,
autoNextLessonEnabled: true,
autoAnswerEnabled: false,
playbackSpeed: 1.5,
checkIntervalMs: 800,
mouseMoveIntervalMs: 8000,
maxRetries: 5
};
let retryCount = 0;
// 获取视频元素
function findVideoElement() {
return document.querySelector('video') ||
document.querySelector('.video-container video') ||
document.querySelector('#videoPlayer') ||
document.querySelector('.video-wrapper video');
}
// 设置视频播放速度
function applyPlaybackSpeed() {
const video = findVideoElement();
if (video && video.playbackRate !== scriptConfig.playbackSpeed) {
video.playbackRate = scriptConfig.playbackSpeed;
console.log('[刷课助手] 播放速度已设置为 ' + scriptConfig.playbackSpeed + '倍');
retryCount = 0;
}
}
// 自动播放视频
function handleAutoPlay() {
const video = findVideoElement();
if (!video) {
if (retryCount < scriptConfig.maxRetries) {
retryCount++;
console.log('[刷课助手] 未找到视频元素,重试第' + retryCount + '次');
}
return;
}
retryCount = 0;
if (video.paused && !video.ended) {
video.play().then(() => {
console.log('[刷课助手] 视频已自动播放');
}).catch(error => {
console.log('[刷课助手] 自动播放失败,尝试点击播放按钮:', error);
const possiblePlayButtons = [
'.play-button', '.vjs-play-control', '.start-video',
'.video-play', '.btn-play', '#playBtn', '.play-icon'
];
possiblePlayButtons.forEach(selector => {
const btn = document.querySelector(selector);
if (btn) {
btn.click();
console.log('[刷课助手] 已点击播放按钮:', selector);
}
});
});
}
applyPlaybackSpeed();
if (scriptConfig.autoNextLessonEnabled && video.ended) {
navigateToNextLesson();
}
}
// 自动切换到下一课
function navigateToNextLesson() {
const nextButtonSelectors = [
'.next-chapter', '.next-lesson-btn', '.btn-next',
'.chapter-next', '.next-course', '[aria-label="下一课"]',
'.lesson-list .active + li a', '.next-unit', '.go-next'
];
let nextButton = null;
for (const selector of nextButtonSelectors) {
const element = document.querySelector(selector);
if (element && element.offsetParent !== null) {
nextButton = element;
break;
}
}
if (nextButton) {
console.log('[刷课助手] 视频播放完毕,正在切换到下一课');
setTimeout(() => {
nextButton.click();
}, 1000);
} else {
console.log('[刷课助手] 未找到下一课按钮,请手动切换');
}
}
// 模拟鼠标移动,防止被检测为闲置
function simulateMouseActivity() {
const x = Math.floor(Math.random() * window.innerWidth);
const y = Math.floor(Math.random() * window.innerHeight);
const mouseEvent = new MouseEvent('mousemove', {
view: window,
bubbles: true,
cancelable: true,
clientX: x,
clientY: y,
screenX: x,
screenY: y
});
document.dispatchEvent(mouseEvent);
if (Math.random() > 0.7) {
const scrollEvent = new Event('scroll', { bubbles: true });
window.dispatchEvent(scrollEvent);
}
}
// 防检测:修改浏览器API
function setupAntiDetection() {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(...args) {
if (args.length > 0 && (args[0] === 'visibilitychange' || args[0] === 'blur')) {
console.log('[刷课助手] 已拦截' + args[0] + '事件监听');
return;
}
return originalAddEventListener.apply(this, args);
};
Object.defineProperty(document, 'hidden', {
get: () => false,
configurable: false,
enumerable: true
});
Object.defineProperty(document, 'visibilityState', {
get: () => 'visible',
configurable: false,
enumerable: true
});
window.onblur = null;
window.onfocus = null;
}
// 初始化脚本
function initScript() {
console.log('[刷课助手] 脚本已加载');
setupAntiDetection();
setInterval(() => {
if (scriptConfig.autoPlayEnabled) {
handleAutoPlay();
}
}, scriptConfig.checkIntervalMs);
setInterval(simulateMouseActivity, scriptConfig.mouseMoveIntervalMs);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initScript);
} else {
initScript();
}