// ==UserScript== // @name 煤炭行业现代远程教育培训网自动播放下一节视频(2026年7月改版后可用) // @namespace http://tampermonkey.net/ // @version 0.5 // @description 自动播放课程 + 自动切下一节 + 防卡死 + 自动恢复播放(增强稳定版) // @author yhr + ChatGPT // @match https://www.coaledu.net/*/coursePlay.html* // @run-at document-end // @require https://code.jquery.com/jquery-1.12.4.min.js // @grant GM_notification // ==/UserScript== this.$ = this.jQuery = jQuery.noConflict(true); (function () { 'use strict'; let lastClickTime = 0; /** ====================== * 1. 关闭“继续学习”弹窗 * ====================== */ setInterval(function () { $("span:contains('继续')").each(function () { const btn = $(this).parent("button"); if (btn.is(":visible")) { btn.click(); } }); }, 1000); /** ====================== * 2. 主循环:自动播放 + 自动切课 * ====================== */ setInterval(function () { const current = $("a.nowrap.on.subset-class"); if (!current.length) return; autoPlay(current); }, 4000); function autoPlay(current) { const now = Date.now(); if (now - lastClickTime < 1000) return; const li = current.closest("li"); const percentText = li.find(".finish-percent").text().trim(); const percent = parseFloat(percentText) || 0; // ====================== // 未完成:继续播放当前 // ====================== if (percent < 100) { current[0].click(); lastClickTime = now; setTimeout(() => { const playBtn = $(".ccH5PlayBtn"); if (playBtn.is(":visible")) { playBtn.click(); } }, 1500); return; } // ====================== // 已完成:自动下一节 // ====================== const next = li.nextAll("li").first().find("a.nowrap.subset-class"); if (next.length) { next[0].click(); lastClickTime = now; setTimeout(() => { const playBtn = $(".ccH5PlayBtn"); if (playBtn.is(":visible")) { playBtn.click(); } }, 1500); } else { GM_notification({ text: "全部课程已完成", title: "学习结束" }); } } /** ====================== * 3. 卡死检测(20分钟温和版) * ====================== */ let lastProgress = -1; let stuckCount = 0; setInterval(function () { const p = $(".finish-percent").closest("li").find(".finish-percent").text().trim(); const currentProgress = parseFloat(p) || 0; if (currentProgress === lastProgress) { stuckCount++; } else { stuckCount = 0; lastProgress = currentProgress; } // 20分钟 = 120次(每10秒一次) if (stuckCount > 120) { console.log("20分钟无进度变化,执行刷新..."); stuckCount = 0; location.reload(); } }, 10000); /** ====================== * 4. 播放结束兜底按钮 * ====================== */ setInterval(function () { const replayBtn = $("div.adrPlayBtn"); if (replayBtn.is(":visible")) { replayBtn.click(); } }, 5000); })();