// ==UserScript==
// @name 华医网自动播放下一课
// @namespace https://91huayi.com/
// @version 3.1.1
// @description 适配华医网 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';
setTimeout(() => {
createPanel();
runAuto();
}, 1500);
let enabled = true;
function createPanel() {
if (document.getElementById('auto-panel')) return;
const panel = document.createElement('div');
panel.id = 'auto-panel';
panel.style.cssText = 'position:fixed;top:20px;right:20px;z-index:999999;width:240px;background:#fff;border-radius:10px;box-shadow:0 5px 15px rgba(0,0,0,0.1);padding:12px;font-size:12px;font-family:sans-serif;';
panel.innerHTML = `
华医网自动播放 v3.1
状态: 运行中
`;
document.body.appendChild(panel);
drag(panel);
document.getElementById('start').onclick = () => {
enabled = true;
document.getElementById('status').textContent = '运行中';
document.getElementById('status').style.color = '#095';
};
document.getElementById('stop').onclick = () => {
enabled = false;
document.getElementById('status').textContent = '已停止';
document.getElementById('status').style.color = '#c00';
};
}
function drag(el) {
let dragging = false, x, y;
el.addEventListener('mousedown', e => {
dragging = true;
x = e.clientX - el.getBoundingClientRect().left;
y = e.clientY - el.getBoundingClientRect().top;
});
document.addEventListener('mousemove', e => {
if (!dragging) return;
el.style.left = e.clientX - x + 'px';
el.style.top = e.clientY - y + 'px';
el.style.right = 'auto';
});
document.addEventListener('mouseup', () => dragging = false);
}
function runAuto() {
setInterval(() => {
if (!enabled) return;
// 自动静音 & 自动播放
const videos = document.querySelectorAll('video');
videos.forEach(v => {
v.muted = true;
if (v.paused && v.duration > 0) v.play().catch(() => {});
});
// 自动关闭弹窗
document.querySelectorAll('.close,.btn-close,[class*="close"]').forEach(b => {
if (b.offsetParent) b.click();
});
// 视频完成 → 自动下一课
videos.forEach(v => {
if (v.duration > 0 && v.currentTime / v.duration > 0.98) {
setTimeout(clickNext, 1200);
}
});
}, 800);
}
function clickNext() {
const selectors = [
'.course-item:not(.finished) .course-title',
'.lesson-item:not(.played)',
'button:contains("下一课")',
'button:contains("继续")',
'button:contains("下一步")',
'[class*="next"]', '.next', '.btn-next'
];
for (const s of selectors) {
const els = document.querySelectorAll(s);
for (const el of els) {
if (el.offsetParent) {
el.click();
return;
}
}
}
}
})();