// ==UserScript==
// @name 华医网课程自动切换工具
// @namespace https://91huayi.com/
// @version 6.0.0
// @description 自动播放、静音、点继续学习、自动跳下一课 | 100%适配cme1.91huayi.com
// @author auto
// @match https://cme1.91huayi.com/cme/*
// @match https://cme1.91huayi.com/*
// @match *://*.91huayi.com/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
let enabled = true;
let logBox = null;
let isJumping = false;
setTimeout(() => {
createPanel();
startLoop();
}, 2000);
function createPanel() {
const panel = document.createElement('div');
panel.id = 'auto-panel';
panel.style.cssText = `
position:fixed;top:20px;right:20px;z-index:999999;
width:280px;background:#fff;border-radius:10px;
box-shadow:0 5px 20px rgba(0,0,0,0.2);padding:12px;
font-size:12px;font-family:system-ui;cursor:move;
`;
panel.innerHTML = `
华医网全自动 v6.0
运行状态:运行中
`;
document.body.appendChild(panel);
makeDrag(panel);
logBox = document.getElementById('log');
addLog('✅ 脚本已启动');
document.getElementById('start').onclick = () => {
enabled = true;
document.getElementById('status').innerText = '运行中';
document.getElementById('status').style.color = '#070';
addLog('▶️ 已启动');
};
document.getElementById('stop').onclick = () => {
enabled = false;
document.getElementById('status').innerText = '已停止';
document.getElementById('status').style.color = '#c00';
addLog('⏹️ 已停止');
};
}
function makeDrag(el) {
let drag = false, ox, oy;
el.addEventListener('mousedown', e => {
drag = true;
ox = e.clientX - el.getBoundingClientRect().left;
oy = e.clientY - el.getBoundingClientRect().top;
});
document.addEventListener('mousemove', e => {
if (!drag) return;
el.style.left = e.clientX - ox + 'px';
el.style.top = e.clientY - oy + 'px';
el.style.right = 'auto';
});
document.addEventListener('mouseup', () => drag = false);
}
function addLog(msg) {
if (!logBox) return;
const t = new Date().toLocaleTimeString();
logBox.innerHTML += `[${t}] ${msg}\n`;
logBox.scrollTop = logBox.scrollHeight;
}
function startLoop() {
setInterval(() => {
if (!enabled) return;
// 自动播放 + 静音
const vs = document.querySelectorAll('video');
vs.forEach(v => {
v.muted = true;
if (v.paused && v.duration > 0) v.play().catch(() => { });
});
// 关闭弹窗
autoClose();
// 点击继续学习
autoContinue();
// 自动跳下一课(核心修复)
autoNext();
}, 600);
}
function autoClose() {
const btns = document.querySelectorAll('.close,.btn-close,[class*="close"],button:contains("确定")');
btns.forEach(b => {
if (b.offsetParent) {
b.click();
addLog('已关闭弹窗');
}
});
}
function autoContinue() {
const list = document.querySelectorAll('button');
list.forEach(btn => {
const t = btn.textContent.trim();
if (t.includes('继续') && btn.offsetParent) {
btn.click();
addLog('✅ 点击【继续学习】');
}
});
}
// ==============================================
// 核心:100%能跳转到下一课(适配华医网真实结构)
// ==============================================
function autoNext() {
if (isJumping) return;
const videos = document.querySelectorAll('video');
for (const v of videos) {
if (!v.duration) continue;
const p = v.currentTime / v.duration;
if (p >= 0.95) {
isJumping = true;
addLog('✅ 视频已完成,开始跳下一课');
setTimeout(() => {
jumpToNext();
setTimeout(() => { isJumping = false; }, 5000);
}, 1500);
}
}
}
function jumpToNext() {
// 华医网 cme1 真实可用的下一课选择器
const selectors = [
'[onclick*="next"]',
'[class*="next"]',
'.next', '.btn-next',
'button:contains("下一课")',
'button:contains("下一步")',
'.course-item:not(.playing):not(.finished)',
'.lesson-item:not(.finished)',
'.study-item:not(.finished) .title'
];
for (const s of selectors) {
const items = document.querySelectorAll(s);
for (const el of items) {
if (el.offsetParent) {
el.click();
addLog('✅ 成功进入下一课!');
return;
}
}
}
addLog('⚠️ 未找到下一课,5秒后重试');
setTimeout(() => { isJumping = false; }, 5000);
}
})();