张掖市干部在线学习平台刷课脚本分享
# 聊聊这个平台
张掖市的干部在线学习平台,唉,说起来都是泪。前段时间张掖甘州区的老王给我打电话,说这个平台太折磨人了,学起来真费劲。网址是 https://www.zygbxxpt.com/login_toLogin ,张掖的同志们应该都知道这个地方。
说实话这个平台真的挺麻烦的,视频动不动就暂停,有时候出去接杯水回来,视频就停在那里了。还有那种答题弹窗,冷不丁就冒出来,不点击就没法继续看。而且视频播放器有时候也不稳定,进度条时不时就卡一下,得刷新好几次才能好。
那天下午我刚吃完饭,坐在电脑前想,能不能写个脚本解决这些问题呢?毕竟大家都挺忙的,哪有那么多时间一直盯着屏幕看。折腾了好几天,终于搞出了个差不多能用的版本。
这个脚本是用JavaScript写的油猴脚本,专门给张掖市干部在线学习平台用的。功能呢,大概有这么些:自动播放视频,检测到暂停就自动继续,第一次播放失败的话还会试试别的方法;倍速播放,默认1.8倍,但有些课程可能限制只能1.5倍;防闲置检测,每隔12秒模拟一下用户交互,免得平台说你闲置;视频放完了还能自动切换到下一章,省得你手动去点;还有弹窗自动处理,要是碰到答题弹窗或者验证弹窗,会自动点击关闭或者确认按钮;另外还会实时监控视频播放状态,确保学习进度能正常更新。
不过啊,脚本安装地址暂时下架了,大家如果有需要的话...
提示
如需代学,请联系客服,支持闲鱼交易。

微信联系:yizhituziang

QQ联系:2422270452
- img: /img/weixin.jpg
name: 微信联系:yizhituziang
- img: /img/qq.jpg
name: QQ联系:2422270452
# 安装的话
如果有脚本的话,安装步骤其实也不复杂。首先得给浏览器装个脚本猫或者油猴插件,这是必须的。推荐用Edge浏览器,装插件比较省事。
打开 https://docs.scriptcat.org/ 这个网址,用Edge浏览器的话,直接点"添加到Edge浏览器"就可以。

然后点"获取"

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

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

装完插件后,打开脚本安装地址,点"安装脚本"按钮,再点"安装"就行。
装好脚本后,得重新进学习站点,之前打开的页面要刷新一下,脚本才会生效哦。
# 核心代码
// 脚本配置对象
const settings = {
enableAutoPlay: true,
enableAutoNext: true,
enableAutoClosePopup: true,
playbackRate: 1.8,
checkInterval: 600,
activityInterval: 12000,
debugMode: false
};
// 获取视频元素的函数
function getVideo() {
const selectors = [
'video',
'.course-video video',
'#videoElement',
'.player-wrapper video',
'.video-content video',
'[class*="video"] video',
'iframe[id*="video"]'
];
for (const selector of selectors) {
const el = document.querySelector(selector);
if (el) {
if (el.tagName === 'IFRAME') {
try {
return el.contentDocument.querySelector('video');
} catch (e) {
continue;
}
}
return el;
}
}
return null;
}
// 设置倍速
function setPlaybackRate() {
const video = getVideo();
if (video && video.playbackRate !== settings.playbackRate) {
video.playbackRate = settings.playbackRate;
if (settings.debugMode) {
console.log('[学习助手] 倍速已设置为 ' + settings.playbackRate);
}
}
}
// 自动播放逻辑
function autoPlay() {
const video = getVideo();
if (!video) return;
if (video.paused && !video.ended) {
video.play().then(() => {
if (settings.debugMode) {
console.log('[学习助手] 视频已恢复播放');
}
}).catch((err) => {
if (settings.debugMode) {
console.log('[学习助手] 播放失败,尝试其他方式:', err);
}
const playButtons = [
'.play-btn',
'.video-play',
'.start-play-btn',
'.vjs-big-play-button',
'.video-start',
'#playButton',
'[class*="play"]'
];
playButtons.forEach(btnSel => {
const btn = document.querySelector(btnSel);
if (btn) {
btn.click();
}
});
});
}
setPlaybackRate();
if (settings.enableAutoNext && video.ended) {
goToNextChapter();
}
}
// 自动切换到下一章节
function goToNextChapter() {
const nextSelectors = [
'.next-chapter',
'.chapter-next',
'.next-lesson',
'.btn-next',
'#nextChapter',
'[title="下一章"]',
'[title="下一节"]',
'.lesson-item.active + .lesson-item a',
'.course-chapter.active + .course-chapter'
];
let nextBtn = null;
for (const sel of nextSelectors) {
const el = document.querySelector(sel);
if (el && el.offsetParent !== null) {
nextBtn = el;
break;
}
}
if (nextBtn) {
if (settings.debugMode) {
console.log('[学习助手] 正在切换到下一章节');
}
setTimeout(() => {
nextBtn.click();
}, 1500);
} else {
if (settings.debugMode) {
console.log('[学习助手] 未找到下一章节按钮');
}
}
}
// 自动处理弹窗
function handlePopups() {
if (!settings.enableAutoClosePopup) return;
const popupSelectors = [
'.modal',
'.dialog',
'.popup',
'.alert-box',
'.verify-modal',
'.question-modal',
'.exam-popup',
'.notice-dialog'
];
popupSelectors.forEach(sel => {
const popup = document.querySelector(sel);
if (popup && popup.offsetParent !== null) {
const closeButtons = [
'.close-btn',
'.btn-close',
'.modal-close',
'.dialog-close',
'.confirm-btn',
'.ok-btn',
'.btn-ok',
'[class*="close"]',
'[class*="confirm"]'
];
closeButtons.forEach(btnSel => {
const btn = popup.querySelector(btnSel);
if (btn) {
btn.click();
if (settings.debugMode) {
console.log('[学习助手] 已处理弹窗');
}
}
});
}
});
}
// 模拟用户活动
function simulateUserActivity() {
const randomX = Math.random() * window.innerWidth;
const randomY = Math.random() * window.innerHeight;
const mousemove = new MouseEvent('mousemove', {
clientX: randomX,
clientY: randomY,
bubbles: true,
cancelable: true
});
document.dispatchEvent(mousemove);
if (Math.random() > 0.6) {
const scrollEvent = new Event('scroll', { bubbles: true });
window.dispatchEvent(scrollEvent);
}
if (Math.random() > 0.8) {
const clickEvent = new MouseEvent('click', {
bubbles: true,
cancelable: true
});
document.body.dispatchEvent(clickEvent);
}
}
// 防检测机制
function setupAntiDetection() {
const originalAddEventListener = EventTarget.prototype.addEventListener;
EventTarget.prototype.addEventListener = function(eventName, ...rest) {
if (eventName === 'visibilitychange' || eventName === 'blur' || eventName === 'focusout') {
if (settings.debugMode) {
console.log('[学习助手] 拦截了 ' + eventName + ' 事件监听');
}
return;
}
return originalAddEventListener.apply(this, [eventName, ...rest]);
};
Object.defineProperty(document, 'hidden', {
get: function() { return false; },
configurable: true,
enumerable: true
});
Object.defineProperty(document, 'visibilityState', {
get: function() { return 'visible'; },
configurable: true,
enumerable: true
});
window.onblur = null;
window.onfocus = null;
}
// 主函数
function main() {
if (settings.debugMode) {
console.log('[学习助手] 脚本已启动');
}
setupAntiDetection();
setInterval(() => {
if (settings.enableAutoPlay) {
autoPlay();
}
handlePopups();
}, settings.checkInterval);
setInterval(simulateUserActivity, settings.activityInterval);
}
if (document.readyState === 'complete' || document.readyState === 'interactive') {
main();
} else {
document.addEventListener('DOMContentLoaded', main);
}