网页版学习通后台自动刷课(可跳过练习版本)【edge】
二编:目前测试依旧可用,之后会添加使用chrome的版本
---------------------------------------------------------------------------------------------------------------------------------
核心问题
- 解决视频跳转后暂停问题- 添加实时视频状态监控,自动恢复暂停的视频
- 增强重试机制- 智能错误处理。
- 实时状态监控- 每秒检查视频状态,自动恢复意外暂停
- 可自动跳过训练- 检测下一节的位置自动点击
使用方法
- 打开edge浏览器,进入网页版学习通的科目页面
- 按键盘上的
F12键打开开发者工具 - 点击
Console(控制台)选项卡 - 选择要继续学习的那一节
- 复制全部代码,粘贴到控制台中
- 按回车键执行
注意事项
- 播放倍速:建议使用2倍速,学习通目前最高支持2倍速(适用于后台不查播放时长的老师)
- 浏览器性能:如果电脑配置较低,建议降低倍速或关闭其他标签页
- 网络环境:确保网络连接稳定,避免频繁断线重连
- 页面状态:尽量避免将浏览器最小化或切换到其他标签页(有时会出问题
(function () { // 补全全局变量,防止超星底层代码报错 const bypass = () => { window.checked_chapter_param = "1"; window.isCheckConfirm = false; window.confirm = () => true; window.alert = () => {}; }; bypass(); // 加载 jQuery 环境 if (typeof window.jQuery === 'undefined') { const script = document.createElement('script'); script.src = 'https://code.jquery.com/jquery-3.6.0.min.js'; script.onload = () => initializePlayer(); document.head.appendChild(script); } else { initializePlayer(); } function initializePlayer() { window.app = { configs: { playbackRate: 1, // 播放倍速 checkInterval: 2500, // 监控频率(毫秒) jumpDelay: 5000 // 跳转后等待加载的时间 }, _isJumping: false, run() { console.log("%c=== 目录驱动+智能跳过练习版 启动 ===", "color:white; background:#2196F3; padding:5px; font-weight:bold;"); this.startMonitoring(); }, // 核心监控逻辑 startMonitoring() { setInterval(() => { bypass(); const video = this._getVideo(); if (video) { // 情况 A: 视频存在 if (video.ended && !this._isJumping) { console.log("检测到视频结束,准备切换目录..."); this.toNextValidUnit(); } else if (video.paused && !video.ended) { video.play().catch(() => {}); video.playbackRate = this.configs.playbackRate; } } else { // 情况 B: 没找到视频(可能是练习题页面或加载中) // 检查是否处于练习页面,若是则直接跳过 const titleText = $(".prev_title").attr("title") || ""; if (titleText.includes("练习") || titleText.includes("测验") || titleText.includes("作业")) { if (!this._isJumping) { console.log(`%c[跳过] 当前是练习页: ${titleText},正在寻找下一个视频...`, "color:#FF9800"); this.toNextValidUnit(); } } } }, this.configs.checkInterval); }, // 【核心思路】直接从目录树寻找并点击 toNextValidUnit() { this._isJumping = true; const $courseTree = $('#coursetree'); // 选取所有小节节点(排除第一级章节标题) const allNodes = $courseTree.find('.posCatalog_select:not(.firstLayer)'); const activeNode = $courseTree.find('.posCatalog_active'); const activeIndex = allNodes.index(activeNode); if (activeIndex === -1) { console.warn("未能定位当前节点,尝试从第一个节点开始"); this._safeClick(allNodes.eq(0)); return; } // 寻找下一个有效节点(排除标题中含有过滤词的节点) let nextIndex = activeIndex + 1; let targetFound = false; while (nextIndex < allNodes.length) { const $nextNode = allNodes.eq(nextIndex); const title = $nextNode.find('.posCatalog_name').attr('title') || ""; const isExercise = /练习|测验|作业|习题|考试/.test(title); if (isExercise) { console.log(`%c[过滤] 发现练习节点: "${title}",自动跳过`, "color:#999"); nextIndex++; } else { console.log(`%c[成功] 找到目标视频: "${title}",执行跳转`, "color:#4CAF50; font-weight:bold"); this._safeClick($nextNode); targetFound = true; break; } } if (!targetFound) { console.log("%c课程似乎已全部完成或后续无可识别视频", "color:green; font-weight:bold"); } // 跳转锁定,防止 5 秒内重复点击 setTimeout(() => { this._isJumping = false; }, this.configs.jumpDelay); }, // 安全点击并处理弹窗 _safeClick($node) { try { $node.find('.posCatalog_name').click(); // 处理可能出现的“未完成确认”弹窗 setTimeout(() => { $(".bluebtn, a:contains('确定'), .pop_confirm .btn_ok").click(); }, 1000); } catch (e) { console.error("点击目录节点失败:", e); } }, // 穿透式查找视频元素 _getVideo() { try { // 深度优先查找 let v = $("iframe").contents().find("iframe").contents().find("video#video_html5_api"); if (v.length > 0) return v[0]; v = $("iframe").contents().find("video#video_html5_api"); if (v.length > 0) return v[0]; v = $("video#video_html5_api"); if (v.length > 0) return v[0]; } catch (e) { return null; } return null; } }; window.app.run(); // 后台保活逻辑:防止由于失去焦点导致的各种限制 window.addEventListener("blur", () => { const v = window.app._getVideo(); if (v && !v.ended) v.play().catch(() => {}); }); } })();