// ==UserScript== // @name 深圳研修课堂助手 // @namespace study // @version 1.0.0 // @description 深圳研修课堂https://szjsyx.yanxiu.com/,自动播放列表,基础功能有限,更新办法请查看官网。 // @author zys // @match *://szjsyx.yanxiu.com/* // @match *://ipx.yanxiu.com/* // @grant unsafeWindow // @grant GM_getValue // @grant GM_setValue // @grant GM_info // @grant GM_addStyle // @run-at document-start // ==/UserScript== const APP = { appTag: 'szjsyx_深圳教师研修网', // 网站名(日志/弹窗用) // —— 【必改】网站唯一 ID,用于官网文档跳转,换站换新值 —— siteTag: '74bfdaa792809392392e46cb', // —— 【必改】BroadcastChannel 频道名,换站换新值(防多站点串台)—— msgBus: 'szjsyx-bus', // 深圳站当前主推项目 id(门户 /cms/project/index?projectId=, // 由 szjsyx.yanxiu.com 首页 302 落地页取得,2026-11-17;脚本逻辑不依赖) projectId: '6289627417674089421', // 脚本启动时弹窗提示文字 launchNotice: '请在课程学习页使用脚本,点击控制台"开始运行"按钮后,自动以常速学习当前视频(不拖动、不倍速)。', // 控制面板顶部提示文字(基础版状态) freeNotice: '建议下载软件使用!全自动学习所有未完成视频', // 控制面板顶部提示文字(VIP/已验证状态) proNotice: '全自动建议下载客户端使用!', // VIP 高级功能按钮文字 proLabel: '高级功能-全自动挂机', // 【升级弹窗】当前脚本功能列表(左栏) localFeatures: [ '常速自动学习课程视频', '防暂停', '自动静音播放', '不拖动不倍速,规避风控', ], // 【升级弹窗】客户端软件功能列表(右栏) clientFeatures: [ '输入账号密码即可全自动', '全自动完成所有未完成课程 + 考试', '支持批量多账号同时学习', ], // —— 【下载/购买链接配置】换站时按需替换 —— // 阿里云盘下载链接 panUrl: 'https://www.alipan.com/s/wViqbLvgSF8', // 直链下载地址(备用) directUrl: 'https://zzzzzzys.lanzouu.com/b00zxor42h', // 授权码购买链接(显示在控制台 + 购买弹窗里;需要多个链接时往数组里追加) gateList: [ 'https://68n.cn/IJ8QB', ], // 备用网址列表(官网打不开时使用,升级弹窗底部展示) mirrorList: [ { 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/' }, ], // 官网文档链接(自动拼接 siteTag,一般不用改) guideUrl: null, // 下方自动赋值 // 控制台只在顶层窗口创建(避免 iframe 页面重复弹出多个面板) mainFrameOnly: true, }; APP.guideUrl = APP.mirrorList[0].url + '?siteTag=' + APP.siteTag; /* ============================================================ * ② StudyEngine 功能区【每个新网站必改】 * ------------------------------------------------------------ * 对应原 Course 类的框架接线部分(init/readVipState/vipFlow/completeStudy/broadcastMsg) * + 功能入口 run()。run() 里的站点逻辑是唯一需要大改的地方。 * 启动方式:手动点击控制台"开始运行-自动化挂机"按钮(无自动开始)。 * 框架能力: * this.panel —— 控制台(setBanner/setErrBox/doVerify) * LightPop.fire —— 弹窗(用法同 Swal.fire,返回 {okPressed,closedBy,dismiss}, * 关闭原因用 LightPop.CloseWay) * Toolkit.openPromoDialog() —— 广告升级弹窗 * this.msgBus / broadcastMsg(msg) —— BroadcastChannel 多标签广播 * this.VIP —— 是否已验证授权 * ============================================================ */ /* —— 【功能配置】深圳基础教育教师研修网(yanxiu) 站点选择器 —— * 实测体系(三仁科技 spring 微服务全家桶,均为 webpack + Vue2 SPA): * 门户 szjsyx.yanxiu.com ← spring-cms-web,路由 /cms/:type/index 等 * 首页 302 → /cms/project/index?projectId=6289627417674089421(项目落地页) * 登录后头部按钮文案为「去学习」/「学习入口」(solutionStyle===2 时"去学习") * 学员端 ipx.yanxiu.com ← spring-train,路由 /train/home、/train/workspace 等 * 「去学习」点击 → /train-project-center/project/link/check 接口下发 link → 同页跳转学习地址 * 播放器 xgplayer 2.28(封装组件容器 .combine-video,video.xgplayer-video, * 默认 autoplay:false,组件监听 ended/pause/error;未检出 seek 风控文案,仍按常速最稳) * 注意:学习地址是服务端按项目下发的,若落在第三个域名,需在头部 @match 追加对应域名。 * 页面结构如有出入,只改这里。 */ const MAPPING = { // 课程列表条目选择器:实测值优先,首个命中即用(深圳站入口 DOM 待真机校准,先留通用候选) entrySelectors: [ '.course-list .course-item', '.classroom-list li', '.kpoint-list li', ], // 条目内启动按钮:站点条目自身绑 onClick,无需内部按钮(留空则直接点条目) entryButtonSel: '', // 选择器全部落空时,按按钮文案匹配入口(门户/学员端的「去学习」「学习入口」均无固定 class) entryTextKeywords: [ '去学习', '学习入口', '进入学习', '开始学习', ], // 点击列表项后等待播放页 video 出现的超时(毫秒) mediaWaitMs: 25000, }; /* —— 【通用框架】日志工具 —— * 功能区直接调用 Tracer.log('...') / warn / error,输出带 [HH:MM:SS] 时间戳。 */ class Tracer { static stamp() { const d = new Date(); const p = n => String(n).padStart(2, '0'); return `[${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}]`; } static log(...args) { console.log(this.stamp(), ...args); } static warn(...args) { console.warn(this.stamp(), ...args); } static error(...args) { console.error(this.stamp(), ...args); } } class StudyEngine { constructor(panel) { this.panel = panel; this.msgBus = new BroadcastChannel(APP.msgBus); this.VIP = false; this.running = false; this.url = null; this.boot(); } boot() { // 授权码验证回调(纯本地):verifyLicense 只弹升级广告,url 恒为空 this.panel.onKeyCheck(async (data) => { this.url = await Toolkit.verifyLicense(data); if (this.url) { this.panel.setBanner(APP.proNotice); this.VIP = true; return true; } }); // 控制台"开始运行"按钮回调 this.panel.onLaunch(() => { if (!this.running) { this.running = true; console.log('运行时:', this.VIP); this.run().then(r => { this.running = false; // 提前返回(未找到列表/未检测到视频)时 run() 内部已调用 exitRunning; // 正常播放中保持"运行中"状态,ended→completeStudy() 时再恢复按钮 }).catch(e => { this.running = false; console.error('运行异常:', e); this.panel.exitRunning(); }); } }); // VIP 高级功能按钮回调 this.panel.onVipAction(async () => { if (!this.url) { await this.panel.doVerify(); } await this.vipFlow(); }); this.readVipState(); // 启动提示弹窗:仅作提示,不自动开始;手动点击控制台"开始运行"按钮才启动 try { LightPop.popup({ title: '提示', text: APP.launchNotice, icon: 'info', autoCloseMs: 5000, okLabel: '确定', progressBar: true, }); } catch (e) { console.error(e); } } readVipState() { if (Toolkit.readVipFlag()) { this.panel.setBanner(APP.proNotice); this.VIP = true; } else { this.panel.setBanner(APP.freeNotice); this.VIP = false; } console.log('VIP:', this.VIP); } async vipFlow() { try { Toolkit.openPromoDialog(); } catch (error) { console.error(error); LightPop.popup({ title: '高级功能执行失败!', text: '若一直失败,请联系进行售后处理!', icon: 'error', okLabel: '确定', clickAway: false, onDismiss: () => { console.log(' 用户确认错误,脚本已停止'); } }); } } completeStudy() { // 学习完成:统一提示文案(对所有用户一致,不区分版本、不含任何数量/权限相关字样) this.broadcastMsg('study-done'); this.panel.exitRunning(); // 播放终态:恢复"开始运行"按钮与计时器 LightPop.popup({ title: '学习完成!', text: '本节内容学习完成。', icon: 'success', okLabel: '确定', autoCloseMs: 5000, progressBar: true, }); } broadcastMsg(msg) { // 复用构造函数里创建的 msgBus 实例广播(原版每次 new 会有频道名转换问题,已修正) this.msgBus.postMessage(msg); } async run() { // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ // ★【功能区代码写在这里】★ 换网站时只改本方法 // // 学习策略(szjsyx·深圳基础教育教师研修网): // 1. 用户登录后在项目页/学习页手动点击"开始运行" // 2. 当前页已有视频直接播放;无视频则依次尝试: // 课程列表选择器 → 「去学习/学习入口」文案按钮(入口地址服务端下发、无固定 class) // 3. 常速播放(playbackRate 强制 1)+ 静音 + 防暂停 // 4. 绝不 seek、绝不倍速——站点播放器为 xgplayer 封装组件,保守常速最稳 // 5. 播完本节即结束(单节模式),完成提示对所有用户一致 // 6. 入口为同页跳转,新页面重新注入脚本后再点"开始运行"即可续跑 // 页面结构如有出入:改上方 MAPPING.entrySelectors / entryTextKeywords 即可。 // ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ // 第一步:当前页面已有视频 → 直接进入播放流程(已在播放页) let video = document.querySelector('video'); // 第二步:无视频 → 视为在列表页,点击列表第一项进入播放页 if (!video) { Tracer.log('当前页无视频,尝试从课程列表进入第一项...'); const firstItem = this.pickFirstEntry(); if (!firstItem) { LightPop.popup({ title: '提示', text: '未找到课程列表,请进入课程学习页后重新点击开始运行。', icon: 'info', okLabel: '确定', }); this.panel.exitRunning(); // 失败终态:恢复按钮,允许用户切页后重试 return; } Tracer.log('进入列表第一项:', (firstItem.textContent || '').trim().replace(/\s+/g, ' ').slice(0, 40)); // 站点条目自身绑 onClick 时直接点条目; // 若站点有内部启动按钮(entryButtonSel 非空)则优先点按钮,空选择器安全兜底 const launchEl = (MAPPING.entryButtonSel && firstItem.querySelector(MAPPING.entryButtonSel)) || firstItem; launchEl.click(); video = await Toolkit.pollForNode('video', 'node', MAPPING.mediaWaitMs); if (!video) { LightPop.popup({ title: '提示', text: '已进入课程但未检测到视频,请确认课程内容后重新点击开始运行。', icon: 'info', okLabel: '确定', }); this.panel.exitRunning(); // 失败终态:恢复按钮(20 秒等不到视频多为新标签打开/页面未跳转) return; } } // 常速:强制 1 倍速(站点风控针对拖动与快进,倍速易触发异常学习判定) video.playbackRate = 1; video.volume = 0; video.muted = true; if (this._resumeGuard) { video.removeEventListener('pause', this._resumeGuard); } // 防暂停:检测到 pause 事件后 500ms 自动恢复播放 let pauseTimeout = null; this._resumeGuard = async () => { if (video.ended) return; if (pauseTimeout) clearTimeout(pauseTimeout); pauseTimeout = setTimeout(async () => { console.log('检测到视频暂停,自动恢复播放...'); video.playbackRate = 1; // 恢复时保持常速 video.volume = 0; video.muted = true; try { await video.play(); } catch (e) { console.error('恢复播放失败:', e); } }, 500); }; video.addEventListener('pause', this._resumeGuard); // 播完本节即结束:单节模式,不查找/不连播下一项 video.addEventListener('ended', () => { Tracer.log('本节学习完成,脚本结束'); this.completeStudy(); }, { once: true }); try { await video.play(); Tracer.log('视频开始自动播放'); } catch (e) { console.error('自动播放失败:', e); // 浏览器拦截自动播放时引导一次手动点击,之后由防暂停逻辑接管 LightPop.popup({ title: '提示', text: '浏览器拦截了自动播放,请点击一次视频播放按钮,脚本会自动接管后续过程。', icon: 'info', okLabel: '确定', }); } } /** * 在候选选择器中查找第一个可见的课程列表条目 * (排除导航/页头/页脚里的链接,避免误点菜单) */ pickFirstEntry() { for (const sel of MAPPING.entrySelectors) { let nodes; try { nodes = document.querySelectorAll(sel); } catch (e) { continue; } for (const n of nodes) { if (n.closest('header, nav, footer, .nav, .menu, .header, .footer, .top, .sidebar')) continue; const rect = n.getBoundingClientRect(); if (rect.width > 0 && rect.height > 0) return n; } } // 选择器全部落空:按控制文案匹配入口按钮 // (深圳站「去学习/学习入口」由服务端下发地址、无固定 class,只能按文案找; // 文案精准命中不会误点菜单,故此处不做 header/nav 排除) const keywords = MAPPING.entryTextKeywords || []; if (keywords.length) { const candidates = document.querySelectorAll('a, button, [role="button"], [class*="btn"], [class*="button"]'); for (const el of candidates) { const label = (el.textContent || '').trim(); if (!label || label.length > 12) continue; // 长文本块不是按钮,跳过 if (!keywords.some(k => label.includes(k))) continue; const rect = el.getBoundingClientRect(); if (rect.width > 0 && rect.height > 0) return el; } } return null; } } /* ============================================================ * ③ 通用框架区【无需改动】 * ============================================================ */ // 样式注入:优先 GM_addStyle,没有则手动插