// ==UserScript== // @name 华医网一气听完脚本 // @namespace http://tampermonkey.net/ // @version 2.2 // @description 视频播放到100%自动播放下一个,自动关闭弹窗 // @author 脚本喵 // @match *://*.91huayi.com/course_ware/course_ware_polyv.aspx?* // @match *://*.91huayi.com/course_ware/course_ware_cc.aspx?* // @match *://*.91huayi.com/* // @grant none // @icon https://jiaobenmiao.com/img/logo2.jpg // @license MIT // ==/UserScript== (function () { 'use strict'; console.log("========== 华医网一气听完脚本已启动 =========="); // ===================== 调试窗口 ===================== window.debugLog = function (msg) { let box = document.getElementById('debug-box'); if (!box) return; let time = new Date().toLocaleTimeString(); box.value = `[${time}] ${msg}\n` + box.value; }; function createDebugWindow() { let debugUI = document.createElement("div"); debugUI.style.cssText = ` position: fixed; top: 12px; left: 12px; z-index: 9999999; width: 350px; background: #1a1a1a; color: #0f0; padding: 10px; border-radius: 8px; font-size:11px; font-family: monospace; `; debugUI.innerHTML = `
📝 一气听完脚本 关闭


正在自动连续播放...
`; document.body.appendChild(debugUI); document.getElementById("close-debug").onclick = () => debugUI.remove(); } createDebugWindow(); // ===================== 来自5.0脚本的弹窗关闭函数 ===================== function killsendQuestion3() { setInterval(function() { try { if ($('.pv-ask-head').length > 0) { $(".pv-ask-skip").click(); debugLog("🧹 关闭课堂问答"); } } catch(e) {} try { if ($('.signBtn').length > 0) { $(".signBtn").click(); debugLog("🧹 关闭签到"); } } catch(e) {} try { if ($("button[onclick='closeProcessbarTip()']").length > 0) { $("button[onclick='closeBangZhu()']").click(); $("button[onclick='closeProcessbarTip()']").click(); debugLog("🧹 关闭温馨提示"); } } catch(e) {} try { if ($("button[class='btn_sign']").length > 0) { $("button[class='btn_sign']").click(); debugLog("🧹 关闭疲劳提醒"); } } catch(e) {} }, 5000); } // ===================== 获取当前视频索引 ===================== function getCurrentVideoIndex() { var lis = document.querySelectorAll(".lis-inside-content"); for (var i = 0; i < lis.length; i++) { if (lis[i].className.indexOf("cur") >= 0 || lis[i].querySelector(".cur")) { return i; } } return -1; } // ===================== 点击下一个待考试(按顺序找) ===================== function clickNextDaikaoshi() { debugLog("🔍 查找下一个未完成的视频..."); var lis = document.querySelectorAll(".lis-inside-content"); if (lis.length === 0) { debugLog("📌 未找到视频列表"); return false; } var currentIndex = getCurrentVideoIndex(); debugLog("当前视频索引: " + currentIndex); // 打印所有章节状态 for (var i = 0; i < lis.length; i++) { var text = lis[i].innerText; if (text.indexOf("已完成") >= 0) { debugLog("索引" + i + ": 已完成"); } else { debugLog("索引" + i + ": 未完成(待播放)"); } } // 从当前索引后面找第一个未完成的(不是"已完成"的) var startIndex = (currentIndex === -1) ? 0 : currentIndex + 1; for (var i = startIndex; i < lis.length; i++) { var text = lis[i].innerText; if (text.indexOf("已完成") === -1) { var h2 = lis[i].querySelector("h2"); if (h2) { debugLog("🎯 找到下一个视频(索引" + i + "),点击播放"); h2.click(); return true; } } } // 如果后面没有,说明全部完成了 debugLog("📌 没有找到更多视频,全部听完啦!🎉"); return false; } // ===================== 主逻辑 ===================== var url = window.location.href; var isVideo = url.indexOf("course_ware_polyv.aspx") > 0 || url.indexOf("course_ware_cc.aspx") > 0; if (isVideo) { debugLog("📺 进入视频页面"); // 启动弹窗关闭 killsendQuestion3(); // 标记是否已切换 var hasSwitched = false; // 监听视频播放进度 function checkVideoProgress() { var video = document.querySelector("video"); if (video && !hasSwitched && video.duration > 0) { var percent = (video.currentTime / video.duration) * 100; if (percent >= 99) { debugLog(`🎬 视频播放进度: ${percent.toFixed(1)}%,切换下一集`); hasSwitched = true; setTimeout(function() { clickNextDaikaoshi(); }, 1000); } } } // 每1秒检查一次进度 var progressTimer = setInterval(function() { checkVideoProgress(); }, 1000); // 监听视频结束事件 setTimeout(function() { var video = document.querySelector("video"); if (video) { video.addEventListener("ended", function() { if (!hasSwitched) { debugLog("🎬 视频ended事件触发,切换下一集"); hasSwitched = true; setTimeout(function() { clickNextDaikaoshi(); }, 1000); } }); } }, 3000); } console.log("========== 脚本初始化完成 =========="); })();