// ==UserScript==
// @name 河南专技学习网-课程助手
// @namespace http://tampermonkey.net/zzzzzzys_河南专技学习网-课程助手
// @version 1.0.2
// @copyright zzzzzzys.All Rights Reserved.
// @description 河南专技学习网-课程助手(https://hnzj.59iedu.com/),脚本功能有限,可自动静音播放视频,防暂停。更全自动方法,请查看文档介绍!客户端支持全自动学习继续教育学习内的未完成课程
// @author zzzzzzys
// @match https://hnzj.59iedu.com/*
// @require https://fastly.jsdelivr.net/npm/crypto-js@4.2.0/crypto-js.min.js
// @resource https://cdn.staticfile.org/limonte-sweetalert2/11.7.1/sweetalert2.min.css
// @require https://fastly.jsdelivr.net/npm/sweetalert2@11.12.2/dist/sweetalert2.all.min.js
// @require https://scriptcat.org/lib/637/1.4.5/ajaxHooker.js#sha256=EGhGTDeet8zLCPnx8+72H15QYRfpTX4MbhyJ4lJZmyg=
// @connect fc-mp-8ba0e2a3-d9c9-45a0-a902-d3bde09f5afd.next.bspapp.com
// @connect mp-8ba0e2a3-d9c9-45a0-a902-d3bde09f5afd.cdn.bspapp.com
// @grant unsafeWindow
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_xmlhttpRequest
// @grant GM_info
// @grant GM_addStyle
// @run-at document-start
// @antifeature ads 有弹窗广告,介绍完全自动化软件
// @antifeature payment 脚本基础功能使用免费,但需要使用完全自动化软件时,可能收费
// ==/UserScript==
(function() {
'use strict';
const delay = ms => new Promise(r => setTimeout(r, ms));
class EntryPoint {
constructor() {
this.executor = null;
this._initInterceptor();
this._awaitReady();
}
_initInterceptor() {
ajaxHooker.hook(req => {
const uri = req.url;
if (uri.includes('vedioValidQuestions/getQuestions')) {
req.response = res => {
try {
const data = JSON.parse(res.responseText);
unsafeWindow.QuestionInfo = data.data;
console.log("QuestionInfo:", unsafeWindow.QuestionInfo);
} catch(e) {}
};
} else if (uri.indexOf('p/play/config') !== -1) {
req.response = res => {
try {
const cfg = JSON.parse(res.responseText);
console.log("play/config:");
console.log(cfg);
unsafeWindow.playConfig = cfg.data;
} catch(e) {}
};
} else if (uri.indexOf('learning/learnVerify/checkCode') !== -1) {
req.abort = true;
req.response = res => {
res.responseText = '{"code":0,"msg":null,"data":{"data":"请勿频繁请求","status":9999}}';
};
} else if (uri.indexOf('learning/learnVerify') !== -1) {
req.abort = true;
}
});
console.log("Interceptor ready:", ajaxHooker);
}
_awaitReady() {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => this._kickoff());
} else {
this._kickoff();
}
}
_kickoff() {
this.executor = new CourseEngine("channel-hunau");
}
}
class CourseEngine {
constructor(commChannel) {
this.commChannel = commChannel;
this.broadcast = new BroadcastChannel(commChannel);
this.isPremium = false;
this.isBusy = false;
this.premiumUrl = null;
this.pauseGuard = null;
this.interface = new UserPanel({
VIPBtnText: "高级功能-已弃用,请前往软件学习"
});
this._setup();
}
_setup() {
this.interface.setOnVerifyCallback(async (data) => {
const url = await ToolBox.validateCode(data);
if (url) {
this.premiumUrl = url;
this.isPremium = true;
this.interface.setTip(ToolBox.vipText);
return true;
}
return false;
});
this.interface.setOnBegin(() => {
if (this.isBusy) return;
this.isBusy = true;
console.log("Executing:", this.isPremium);
this._process().finally(() => {
this.isBusy = false;
});
});
this.interface.setOnVIP(async () => {
if (!this.premiumUrl) {
await this.interface.handleVerify();
}
await this._execPremium();
});
this._checkPremium();
try {
Swal.fire({
title: "提示",
text: ToolBox.swFireText,
icon: 'info',
timer: 10000, // 关键修改:从5000改为10000(10秒)
confirmButtonText: '确定',
timerProgressBar: true,
willClose: () => {
this.interface.startAutomation();
}
});
} catch (e) {
console.error(e);
this.interface.startAutomation();
}
}
_checkPremium() {
if (ToolBox.loadStatus()) {
this.interface.setTip(ToolBox.vipText);
this.isPremium = true;
} else {
this.interface.setTip(ToolBox.baseText);
this.isPremium = false;
}
console.log("Premium:", this.isPremium);
}
async _execPremium() {
try {
ToolBox.showUpgradeAlert();
} catch (error) {
console.error(error);
Swal.fire({
title: "高级功能执行失败!",
text: "若一直失败,请联系进行售后处理!",
icon: 'error',
confirmButtonText: '确定',
allowOutsideClick: false
});
}
}
async _process() {
try {
await this._ensurePlayback();
} catch (e) {
console.error(e);
Swal.fire({
title: "失败!",
text: `视频基础播放失败!`,
icon: 'error',
confirmButtonColor: "#FF4DAFFF",
confirmButtonText: "确定",
timer: 5000,
timerProgressBar: true
});
}
}
async _ensurePlayback() {
const media = document.querySelector('video');
if (!media) return;
media.volume = 0;
media.muted = true;
if (this.pauseGuard) {
media.removeEventListener('pause', this.pauseGuard);
}
let timer = null;
this.pauseGuard = async () => {
if (media.ended) return;
if (timer) clearTimeout(timer);
timer = setTimeout(async () => {
console.log("检测到视频暂停,自动恢复播放...");
media.volume = 0;
media.muted = true;
try {
await media.play();
} catch (e) {
console.error("恢复播放失败:", e);
}
}, 500);
};
media.addEventListener('pause', this.pauseGuard);
media.addEventListener('ended', () => {
this._advance();
}, { once: true });
await media.play();
}
_advance() {
const chapters = Array.from(document.querySelectorAll('ul.lis-content li.lis-inside-content'));
if (!chapters.length) {
console.log("未找到目录列表");
return;
}
const current = chapters.findIndex(li => li.querySelector('#top_play'));
console.log("当前目录索引:", current);
const start = current + 1;
for (let i = start; i < chapters.length; i++) {
const item = chapters[i];
const btn = item.querySelector('button');
const h2 = item.querySelector('h2');
if (!h2) continue;
const status = btn ? btn.textContent.trim() : '';
console.log(`目录[${i}] 状态: ${status}`);
const onclick = h2.getAttribute('onclick') || '';
const match = onclick.match(/window\.location\.href='([^']+)'/);
if (match) {
const nextUrl = match[1];
const title = h2.textContent.trim().replace(/\s+/g, ' ');
console.log("跳转下一节:", nextUrl);
Swal.fire({
title: "视频已播放完毕",
html: `即将跳转到下一节:
${title}`,
icon: 'success',
timer: 5000,
timerProgressBar: true,
confirmButtonText: '立即跳转',
showCancelButton: true,
cancelButtonText: '取消',
}).then((result) => {
if (result.isConfirmed || result.dismiss === Swal.DismissReason.timer) {
window.location.href = nextUrl;
}
});
return;
}
}
console.log("已是最后一节,无下一个目录");
this._finalize();
}
_finalize() {
if (!this.isPremium) {
Swal.fire({
title: "请升级高级版!",
text: `脚本已停止!基础版只能连播几个视频!`,
icon: 'info',
confirmButtonColor: "#FF4DAFFF",
confirmButtonText: "确定",
timer: 0
});
return;
}
this.broadcast.postMessage('finish');
Swal.fire({
title: "学习完成!",
text: `学习完成,5s后页面自动关闭!`,
icon: 'success',
confirmButtonColor: "#FF4DAFFF",
confirmButtonText: "确定",
timer: 5000,
willClose: () => {
history.back();
setTimeout(() => location.reload(), 1000);
}
});
}
captchaHandler() {
const selector = ".layui-layer1";
const self = this;
const check = setInterval(async () => {
const layer = document.querySelector(selector);
if (layer) {
console.log("检查到验证码窗口");
clearInterval(check);
const inputSel = "#captchaInput";
const btnSel = ".layui-layer-btn0";
for (let i = 0; i < 20; i++) {
try {
const input = layer.querySelector(inputSel);
const btn = layer.querySelector(btnSel);
if (!input || !btn) break;
input.value = i;
await delay(100);
btn.click();
await delay(100);
} catch(err) {
console.error(err);
break;
}
}
self.captchaHandler();
}
}, 5000);
}
}
class ToolBox {
static flag = 'hnedu123_VIP'
static js_Flag = 'hnedu123_jsCode'
static vipSign = 'hnedu123_vipSign'
static webId = '687f7fc37ad52db7e748dbd8'
static swFireText = "请在视频播放页面使用脚本,脚本检测到视频会自动开始,脚本功能有限,也可能页面有所更新,导致脚本不能正常使用,建议下载软件使用!全自动学习所有未完成视频"
static baseText = '建议下载软件使用!全自动学习所有未完成视频'
static vipText = '全自动建议下载客户端使用!河南专技学习网-课程助手'
static vipBtnText = "前往软件使用课程助手,全自动学习所有未完成视频!"
static scriptFeatures = [
"辅助当前页面视频播放",
"防暂停",
"自动静音播放",
"视频播放完成自动切换",
"仅限单页面使用",
]
static softwareFeatures = [
"输入账号密码即可全自动",
"全自动完成所有未完成课程",
"支持批量多账号同时学习",
]
static aliLink = "https://www.alipan.com/s/wViqbLvgSF8"
static directLink = 'http://112.124.58.51/static/课程助手.exe'
static link = [
"https://68n.cn/IJ8QB",
"https://68n.cn/RM9ob",
]
static web_list = [
{ name: "备用地址0", url: "https://www.zzzzzzys.com/" },
{ name: "备用地址1", url: "https://zzzzzzys.lovestoblog.com/" },
{ name: "备用地址2", url: "https://zzzzzzys.us.kg/" },
{ name: "备用地址3", url: "https://zzysdocs.dpdns.org/" },
{ name: "备用地址4", url: "https://zzzzzzys.dpdns.org/" },
{ name: "备用地址5", url: "https://zzzzzzys.kesug.com/" },
{ name: "备用地址6", url: "https://zzysdocs.great-site.net/" },
]
static docLink = `${ToolBox.web_list[0].url}?webId=` + ToolBox.webId
static loadStatus() {
return false
}
static async validateCode(data) {
try {
ToolBox.showUpgradeAlert();
return;
} catch (e) {
console.error(e);
Swal.fire({
title: "验证失败!",
text: e.toString(),
icon: 'error',
confirmButtonText: '确定',
});
}
}
static async fetchScript(url) {
try {
let cached = GM_getValue(ToolBox.js_Flag);
if (cached) return cached;
const code = await new Promise((resolve, reject) => {
GM_xmlhttpRequest({
url: url,
method: 'GET',
onload: res => {
if (res.status === 200) resolve(res.responseText);
else reject('Server error');
},
onerror: err => reject(err)
});
});
const escaped = code
.replace(/\\/g, '\\\\')
.replace(/'/g, '\'')
.replace(/"/g, '\"');
GM_setValue(ToolBox.js_Flag, escaped);
return escaped;
} catch (error) {
console.error('Remote load failed:', error);
throw new Error("远程加载失败");
}
}
static showPurchaseModal() {
const links = ToolBox.link;
Swal.fire({
title: ' 高级功能解锁',
html: `
⚠️ 网页脚本有局限性
浏览器脚本运行在沙盒中,无法跨页面、无法自动登录、无法批量管理账号。
若需要 输入账号密码后全自动完成所有视频,推荐使用本地客户端。
📄 当前脚本