// ==UserScript== // @name 华医网学习助手(合规版) // @namespace https://local.hyw-assist/ // @version 2.3.0 // @description 支持 CC / 百家云 / 保利威 三种播放页:自动关闭课程评价等弹窗;视频正常播放结束后自动进入下一课;辅助自动播放。不读取登录凭据,不上报或伪造学习进度,不自动签到、不自动答题,不绕过人脸识别。 // @match *://*.91huayi.com/* // @run-at document-start // @noframes // @grant none // ==/UserScript== (function () { 'use strict'; var CONFIG = { autoClosePopup: true, // 自动关闭“课程评价/满意度/作业提醒”等非必要弹窗 autoNext: true, // 视频正常播完后自动进入下一课 autoPlay: true, // 辅助自动播放(含被浏览器拦截时的静音兜底) reloadIfNoPlayer: true, // 播放器长时间未初始化时自动刷新一次(自愈) mutePage: true, // 网页静音(默认开启) keepBackgroundAlive: true, // 浏览器最小化/后台时保持视频继续播放 keepSessionAlive: true, // 定期轻量请求维持登录状态 nextDelayMs: 3000, // 播完到跳转下一课的间隔 popupIntervalMs: 800, playerTimeoutMs: 20000, sessionPingMs: 5 * 60 * 1000 // Session 保活间隔:5 分钟 }; // 三种播放页路由(抓包确认:Video_Type_PC 0=CoursePlay(CC) 1=PolyvCoursePlay 2=BJYCoursePlay) var PLAY_PAGE_RE = /\/exercise\/ExerciseCourse\/(CoursePlay|PolyvCoursePlay|BJYCoursePlay)/i; var ACTION_BY_VIDEO_TYPE = { 0: 'CoursePlay', 1: 'PolyvCoursePlay', 2: 'BJYCoursePlay' }; var state = { courseList: [], listFetchTried: false, allCoursesFetched: false, currentCourseId: '', lastEndedAt: 0, nextAttempts: 0, assistedVideos: new WeakSet(), reloadGuardUsed: false, mutedHintShown: false, mutedMediaElements: new WeakSet() }; function log() { var args = Array.prototype.slice.call(arguments); console.log.apply(console, ['[华医网学习助手]'].concat(args)); } // ---------- 网页静音核心 ---------- var _hywOrigPlay = HTMLMediaElement.prototype.play; var _hywMuteObserver = null; function muteOneMedia(media) { if (!media || state.mutedMediaElements.has(media)) return; try { media.muted = true; media.volume = 0; state.mutedMediaElements.add(media); } catch (e) { /* 忽略 */ } } function muteAllMedia() { var els = document.querySelectorAll('video, audio'); for (var i = 0; i < els.length; i++) muteOneMedia(els[i]); } // 拦截 play(),对所有调用 play 的媒体元素强制静音 function installMuteHook() { HTMLMediaElement.prototype.play = function () { if (CONFIG.mutePage) { this.muted = true; this.volume = 0; state.mutedMediaElements.add(this); } return _hywOrigPlay.apply(this, arguments); }; } function startMuteObserver() { if (_hywMuteObserver) return; _hywMuteObserver = new MutationObserver(function (mutations) { if (!CONFIG.mutePage) return; for (var i = 0; i < mutations.length; i++) { var nodes = mutations[i].addedNodes; for (var j = 0; j < nodes.length; j++) { var node = nodes[j]; if (node.nodeType !== 1) continue; if (node.tagName === 'VIDEO' || node.tagName === 'AUDIO') muteOneMedia(node); if (node.querySelectorAll) { var children = node.querySelectorAll('video, audio'); for (var k = 0; k < children.length; k++) muteOneMedia(children[k]); } } } }); var target = document.body || document.documentElement; if (target) _hywMuteObserver.observe(target, { childList: true, subtree: true }); } function stopMuteObserver() { if (_hywMuteObserver) { _hywMuteObserver.disconnect(); _hywMuteObserver = null; } } function applyMuteState() { if (CONFIG.mutePage) { muteAllMedia(); startMuteObserver(); log('网页静音已开启'); } else { stopMuteObserver(); var els = document.querySelectorAll('video, audio'); for (var i = 0; i < els.length; i++) { try { els[i].muted = false; els[i].volume = 1; } catch (e) { /* 忽略 */ } } state.mutedMediaElements = new WeakSet(); log('网页静音已关闭'); } } function isVisible(el) { if (!el) return false; var style = window.getComputedStyle(el); if (!style || style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false; var rect = el.getBoundingClientRect(); return rect.width > 0 && rect.height > 0; } function findVisible(selector, root) { var nodes = (root || document).querySelectorAll(selector); for (var i = 0; i < nodes.length; i++) { if (isVisible(nodes[i])) return nodes[i]; } return null; } function readHidden(id) { var el = document.getElementById(id); return el ? (el.value || '') : ''; } // ---------- 课程列表(来自页面自身的 OtherCourserList 请求,只读不改动) ---------- function normalizeCourseList(data) { if (Array.isArray(data)) return data; if (data && Array.isArray(data.data)) return data.data; if (data && Array.isArray(data.list)) return data.list; return []; } function acceptCourseList(list) { if (!list.length) return; state.courseList = list; log('已读取课程列表:', list.length, '门课'); updatePanelStatus(); } function installNetworkHook() { var origOpen = XMLHttpRequest.prototype.open; var origSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.open = function (method, url) { this.__hywUrl = String(url || ''); return origOpen.apply(this, arguments); }; XMLHttpRequest.prototype.send = function () { this.addEventListener('load', function () { try { var url = this.__hywUrl || ''; if (url.indexOf('/OtherCourserList') === -1) return; var list = normalizeCourseList(JSON.parse(this.responseText)); acceptCourseList(list); } catch (error) { /* 忽略非目标响应 */ } }); return origSend.apply(this, arguments); }; if (window.fetch) { var origFetch = window.fetch; window.fetch = function (input, init) { return origFetch.call(this, input, init).then(function (response) { try { var url = typeof input === 'string' ? input : (input && input.url) || ''; if (url.indexOf('/OtherCourserList') !== -1) { response.clone().text().then(function (text) { try { acceptCourseList(normalizeCourseList(JSON.parse(text))); } catch (error) { /* 忽略 */ } }); } } catch (error) { /* 忽略钩子异常 */ } return response; }); }; } } // 兜底:脚本注入晚于页面请求(如浏览器启动恢复标签页)时收不到列表,主动拉一次 function fetchCourseListIfMissing() { if (state.listFetchTried || state.courseList.length) return; var planId = readHidden('learningplan_id'); var cwId = state.currentCourseId; if (!planId || !cwId) return; state.listFetchTried = true; var url = '/exercise/ExerciseCourse/OtherCourserList?learnPlanId=' + encodeURIComponent(planId) + '&courseware_id=' + encodeURIComponent(cwId) + '&top=10'; fetch(url, { credentials: 'include', headers: { 'X-Requested-With': 'XMLHttpRequest' } }) .then(function (r) { return r.text(); }) .then(function (text) { acceptCourseList(normalizeCourseList(JSON.parse(text))); }) .catch(function () { /* 静默 */ }); } // 获取所有章节的课程(不按 learnPlanId 过滤),用于跨章节跳转 function fetchAllCourses() { if (state.allCoursesFetched) return Promise.resolve(); state.allCoursesFetched = true; var url = '/exercise/ExerciseCourse/OtherCourserList?top=500'; return fetch(url, { credentials: 'include', headers: { 'X-Requested-With': 'XMLHttpRequest' } }) .then(function (r) { return r.text(); }) .then(function (text) { var list = normalizeCourseList(JSON.parse(text)); if (list.length) { // 合并到已有的 courseList,按 LearningPlan_Courseware_Id 去重 var seen = {}; for (var i = 0; i < state.courseList.length; i++) { seen[state.courseList[i].LearningPlan_Courseware_Id] = true; } for (var j = 0; j < list.length; j++) { if (!seen[list[j].LearningPlan_Courseware_Id]) { state.courseList.push(list[j]); } } log('已获取全部课程列表:', state.courseList.length, '门课'); } }) .catch(function () { /* 静默 */ }); } // ---------- Session 保活 ---------- var sessionAliveTimer = null; function startSessionKeepAlive() { if (!CONFIG.keepSessionAlive) return; if (sessionAliveTimer) return; function ping() { // 用已有的课程列表接口做心跳,带 cookie 维持服务端 Session fetch('/exercise/ExerciseCourse/OtherCourserList?top=1', { credentials: 'include', headers: { 'X-Requested-With': 'XMLHttpRequest' } }) .then(function (r) { if (r.redirected && /\/Login|\/login/.test(r.url)) { updatePanelStatus('登录已失效,请重新登录'); log('Session 保活检测到登录已失效'); return; } if (r.status === 401 || r.status === 403) { updatePanelStatus('登录已失效,请重新登录'); log('Session 保活:响应码', r.status, '登录已失效'); return; } log('Session 保活成功'); }) .catch(function (e) { // 网络断开等情况静默跳过,等下一轮 }); } // 先等 2 分钟再做第一次 ping,避免和页面自身的初始化请求挤在一起 sessionAliveTimer = setInterval(ping, CONFIG.sessionPingMs); setTimeout(ping, 2 * 60 * 1000); log('Session 保活已启动(间隔', CONFIG.sessionPingMs / 60000, '分钟)'); } function stopSessionKeepAlive() { if (sessionAliveTimer) { clearInterval(sessionAliveTimer); sessionAliveTimer = null; } } function getCurrentCourseItem() { var key = state.currentCourseId; if (!key) return null; for (var i = 0; i < state.courseList.length; i++) { if (state.courseList[i].LearningPlan_Courseware_Id === key) return state.courseList[i]; } return null; } function getNextCourseItem() { var current = getCurrentCourseItem(); if (!current || !state.courseList.length) return null; var pool = state.courseList.filter(function (item) { return item.LearningPlan_Id === current.LearningPlan_Id; }); var sorted = pool.slice().sort(function (a, b) { return (a.List_Order || 0) - (b.List_Order || 0); }); var index = -1; for (var i = 0; i < sorted.length; i++) { if (sorted[i].LearningPlan_Courseware_Id === current.LearningPlan_Courseware_Id) { index = i; break; } } if (index >= 0 && index + 1 < sorted.length) return sorted[index + 1]; // 当前章节已到最后一课,跨章节查找下一章节的第一课 return getNextPlanFirstCourse(current); } // 在全量课程列表中查找下一个章节的第一门课 function getNextPlanFirstCourse(current) { if (!current) return null; // 收集所有不同的 LearningPlan_Id,按 List_Order 排序 var plans = {}; var planList = []; for (var i = 0; i < state.courseList.length; i++) { var pid = state.courseList[i].LearningPlan_Id; if (!plans[pid]) { plans[pid] = true; planList.push({ LearningPlan_Id: pid, List_Order: state.courseList[i].List_Order || 0 }); } } // 找到当前章节在章节列表中的位置 var currentPlanIndex = -1; for (var k = 0; k < planList.length; k++) { if (planList[k].LearningPlan_Id === current.LearningPlan_Id) { currentPlanIndex = k; break; } } if (currentPlanIndex < 0 || currentPlanIndex + 1 >= planList.length) return null; var nextPlanId = planList[currentPlanIndex + 1].LearningPlan_Id; // 找到下一章节中 List_Order 最小的一门课 var firstCourse = null; for (var m = 0; m < state.courseList.length; m++) { if (state.courseList[m].LearningPlan_Id === nextPlanId) { if (!firstCourse || (state.courseList[m].List_Order || 0) < (firstCourse.List_Order || 0)) { firstCourse = state.courseList[m]; } } } if (firstCourse) log('跨章节跳转:', courseDisplayName(firstCourse)); return firstCourse; } function courseDisplayName(item) { return (item && (item.Courseware_Name || item.LearningPlan_Courseware_Id)) || ''; } function videoTypeOf(item) { if (!item) return 0; if (typeof item.Video_Type_PC === 'number') return item.Video_Type_PC; if (typeof item.Video_Type === 'number') return item.Video_Type; return 0; } // ---------- 弹窗(只处理已知安全的弹窗,不碰签到/问答/人脸识别) ---------- // 平台强制流程是否正在进行(此时禁止自动下一课/自动播放) function blockingGateActive() { // 人脸识别弹窗(开始/中途/结束人脸)——必须由用户扫码完成验证 if (findVisible('.popup_box')) return true; // 播放器内置学习签到弹窗(ccH5 / BPlayer 的 signConfig) var signDialog = findVisible('[class*="signin" i],[class*="sign-box" i],[class*="signBox" i]'); if (signDialog) return true; // 平台提示框(例如“您有其他课程正在播放”) var tip = document.getElementById('login'); if (tip && isVisible(tip)) return true; return false; } function closePopups() { if (!CONFIG.autoClosePopup) return; // 1. 课程评价弹窗:点右上角关闭图标 var review = findVisible('.dialog_box_pj'); if (review) { var closeIcon = review.querySelector('.diaheader_box_pj img'); if (closeIcon) { closeIcon.click(); log('已关闭课程评价弹窗'); return; } } // 2. 满意度打分浮层:点“返回”,绝不代提交 var scoreLayer = findVisible('.hidden_layer_pj'); if (scoreLayer) { var backBtn = scoreLayer.querySelector('.lay_let_pj'); if (backBtn) { backBtn.click(); log('已关闭满意度打分浮层'); return; } } // 3. 作业提醒遮罩:点关闭按钮 var homework = document.getElementById('homework_reminder_mask'); if (homework && isVisible(homework)) { var hwClose = homework.querySelector('.homework_reminder_close'); if (hwClose) { hwClose.click(); log('已关闭作业提醒'); return; } } // 4. 人脸识别弹窗:仅在平台提示“人脸验证通过”后代点一次“进入课程学习” var facePopup = findVisible('.popup_box'); if (facePopup) { var okTip = facePopup.querySelector('#sucessTip'); if (okTip && isVisible(okTip)) { var enterBtn = facePopup.querySelector('.button_box button'); if (enterBtn && !enterBtn.disabled) { enterBtn.click(); log('人脸验证已通过,进入课程学习'); } } // 未通过时绝不隐藏、绝不代点,交由用户扫码 return; } // 5. 孤儿遮罩清理:仅当没有任何弹窗/提示可见时 if (!blockingGateActive()) { var mask = findVisible('.mask'); if (mask) mask.style.display = 'none'; } } // ---------- 自动下一课 ---------- function clickNextFromDom() { var nodes = document.querySelectorAll('.listGroup [onclick*="VideoPlay"]'); if (!nodes.length || !state.currentCourseId) return false; var index = -1; for (var i = 0; i < nodes.length; i++) { if ((nodes[i].getAttribute('onclick') || '').indexOf(state.currentCourseId) !== -1) { index = i; break; } } if (index < 0 || index + 1 >= nodes.length) return false; nodes[index + 1].click(); return true; } function navigateToCourse(item) { var id = item.LearningPlan_Courseware_Id || item.Courseware_Id; // 按课程类型选择正确的播放页路由(旧版硬编码 CoursePlay,是百家云课打不开的原因) var action = ACTION_BY_VIDEO_TYPE[videoTypeOf(item)] || 'CoursePlay'; log('跳转下一课(' + action + '):', courseDisplayName(item)); location.href = '/exercise/ExerciseCourse/' + action + '?courseware_id=' + encodeURIComponent(id); } function goToNextCourseOnce() { if (!CONFIG.autoNext) return; if (blockingGateActive()) { // 人脸/签到/平台提示未处理完,等待下一轮重试 if (state.nextAttempts < 150) { state.nextAttempts++; setTimeout(goToNextCourseOnce, 2000); } else { log('等待平台流程超时,停止自动下一课'); } return; } var next = getNextCourseItem(); // 优先用页面侧边栏节点(站点自身 onclick,路由永远正确) if (next && clickNextFromDom()) { log('已点击下一课:', courseDisplayName(next)); return; } // 其次调用页面自身的换课函数 VideoPlay(id, courseType, state, videoType) if (next && typeof window.VideoPlay === 'function') { try { window.VideoPlay(next.LearningPlan_Courseware_Id || next.Courseware_Id, next.courseware_type || 1, next.Learning_state || 0, videoTypeOf(next)); log('已调用页面换课:', courseDisplayName(next)); return; } catch (error) { /* 继续兜底 */ } } if (next) { navigateToCourse(next); return; } // 列表数据缺失时,仅依赖 DOM 顺序 if (clickNextFromDom()) { log('已点击下一课(DOM 顺序)'); return; } // 本章节最后一课且 courseList 没有跨章节数据,尝试获取全量列表后重试 if (!state.allCoursesFetched) { fetchAllCourses().then(function () { var crossNext = getNextCourseItem(); if (crossNext) { navigateToCourse(crossNext); } else { log('未找到下一课(可能已是最后一个章节)'); } }); return; } log('未找到下一课(可能已是最后一个章节或列表未加载)'); } function handleVideoEnded(reason) { var now = Date.now(); if (now - state.lastEndedAt < 8000) return; state.lastEndedAt = now; log('当前视频已正常播放结束(' + reason + '),' + CONFIG.nextDelayMs + 'ms 后进入下一课'); updatePanelStatus('已播完,准备下一课'); state.nextAttempts = 0; setTimeout(goToNextCourseOnce, CONFIG.nextDelayMs); } // ---------- 播放器辅助(只辅助起播,不改倍速、不拖进度) ---------- function tryPlay(video) { if (!video || !video.paused || video.ended) return; var promise = video.play(); if (promise && promise.catch) { promise.catch(function () { // 浏览器拦截了带声音的自动播放:按 CC 播放器 realAutoPlay 的同类策略改静音起播 if (!video.muted) { video.muted = true; var p2 = video.play(); if (p2 && p2.catch) p2.catch(function () {}); if (!state.mutedHintShown) { state.mutedHintShown = true; updatePanelStatus('浏览器拦截了自动播放,已静音播放(点播放器喇叭恢复声音)'); log('自动播放被拦截,已改为静音起播'); } } }); } } function assistStartup(video) { if (!CONFIG.autoPlay) return; if (state.assistedVideos.has(video)) return; if (video.readyState < 2 || !(video.duration > 0)) return; if (blockingGateActive()) return; if (video.played.length > 0) { // 已经播过(例如用户手动暂停),不再代播 state.assistedVideos.add(video); return; } state.assistedVideos.add(video); if (video.paused && !video.ended) { log('辅助自动播放'); tryPlay(video); } } function watchVideoPlayer() { var currentVideo = null; var lastPauseAt = 0; // 后台保活:用 Web Audio 静音振荡器维持页面活跃,防止浏览器降频/休眠 function startBackgroundKeepAlive() { if (!CONFIG.keepBackgroundAlive) return; try { var ctx = new (window.AudioContext || window.webkitAudioContext)(); var osc = ctx.createOscillator(); var gain = ctx.createGain(); gain.gain.value = 0; // 静音,只保持时钟活跃 osc.frequency.value = 1; // 1Hz 次声波,人耳不可闻 osc.connect(gain); gain.connect(ctx.destination); osc.start(); // Safari 需要用户手势才能启动 AudioContext,失败时静默忽略 if (ctx.state === 'suspended') { document.addEventListener('click', function () { ctx.resume(); }, { once: true }); } log('后台保活心跳已启动'); } catch (e) { /* AudioContext 不可用时跳过 */ } } // 视频被意外暂停时自动恢复(不覆盖用户主动暂停) function autoResumeIfPaused() { if (!currentVideo || !CONFIG.keepBackgroundAlive) return; if (currentVideo.ended || currentVideo.readyState < 2) return; if (blockingGateActive()) return; if (currentVideo.paused && Date.now() - lastPauseAt > 1000) { // 如果刚暂停不到 1 秒,可能是用户点击,先跳过这一轮 tryPlay(currentVideo); } } function bindVideo(video) { video.addEventListener('ended', function () { handleVideoEnded('ended'); }); video.addEventListener('pause', function () { lastPauseAt = Date.now(); }); video.addEventListener('timeupdate', function () { if (video.duration && video.currentTime >= video.duration - 1.2 && video.readyState >= 3) { handleVideoEnded('临近结尾'); } }); } function scan() { var playerBox = document.getElementById('ccVideo-box') || document; var video = playerBox.querySelector('video'); if (video && video !== currentVideo) { currentVideo = video; bindVideo(video); log('已找到播放器 video 元素'); updatePanelStatus(); } if (currentVideo) assistStartup(currentVideo); } scan(); // 切换标签页 / 最小化 / 获得焦点时自动恢复 document.addEventListener('visibilitychange', function () { if (document.hidden) { // 刚进入后台时立即尝试续播 setTimeout(autoResumeIfPaused, 500); } else { // 回到前台时恢复 setTimeout(autoResumeIfPaused, 200); } }); window.addEventListener('blur', function () { setTimeout(autoResumeIfPaused, 500); }); window.addEventListener('focus', function () { setTimeout(autoResumeIfPaused, 200); }); // 定期检查,覆盖所有平台暂停场景 setInterval(autoResumeIfPaused, 3000); startBackgroundKeepAlive(); function startObserver() { new MutationObserver(scan).observe(document.body, { childList: true, subtree: true }); } if (document.body) startObserver(); else document.addEventListener('DOMContentLoaded', startObserver, { once: true }); // 自愈:播放器脚本(bokecc / 百家云)加载失败时页面一直没有 video,刷新一次 setTimeout(function () { if (!CONFIG.reloadIfNoPlayer) return; if (document.querySelector('#ccVideo-box video')) return; if (blockingGateActive()) return; var key = 'hyw_reload_' + state.currentCourseId; try { if (sessionStorage.getItem(key)) { updatePanelStatus('播放器未能初始化,已尝试刷新仍失败'); return; } sessionStorage.setItem(key, '1'); } catch (error) { /* 隐私模式等 */ } log('播放器未初始化,自动刷新一次以恢复'); location.reload(); }, CONFIG.playerTimeoutMs); } // ---------- 面板 ---------- var panelStatusEl = null; function updatePanelStatus(text) { if (!panelStatusEl) return; var msg = text; if (!msg) { var video = document.querySelector('#ccVideo-box video'); if (!video) msg = '等待播放器初始化…'; else if (video.ended) msg = '已播完'; else if (video.paused) msg = '已暂停'; else msg = '播放中'; } var next = getNextCourseItem(); panelStatusEl.textContent = '状态:' + msg + ' | 下一课:' + (next ? courseDisplayName(next) : '(无)'); } function loadToggles() { try { var raw = sessionStorage.getItem('hyw_assist_cfg'); if (raw) { var saved = JSON.parse(raw); CONFIG.autoClosePopup = saved.autoClosePopup !== false; CONFIG.autoNext = saved.autoNext !== false; CONFIG.autoPlay = saved.autoPlay !== false; CONFIG.mutePage = saved.mutePage === true; } } catch (error) { /* 忽略 */ } } function saveToggles() { try { sessionStorage.setItem('hyw_assist_cfg', JSON.stringify({ autoClosePopup: CONFIG.autoClosePopup, autoNext: CONFIG.autoNext, autoPlay: CONFIG.autoPlay, mutePage: CONFIG.mutePage })); } catch (error) { /* 忽略 */ } } function createUI() { // --- 样式 --- var style = document.createElement('style'); style.textContent = '#hyw-course-assist{position:fixed;top:80px;right:10px;z-index:2147483646;' + 'width:216px;font:13px/1.5 "Microsoft YaHei","PingFang SC",sans-serif;' + 'color:#e8eaed;user-select:none;' + 'background:rgba(28,28,32,.82);backdrop-filter:blur(14px) saturate(1.4);-webkit-backdrop-filter:blur(14px) saturate(1.4);' + 'border:1px solid rgba(255,255,255,.08);border-radius:12px;' + 'box-shadow:0 6px 24px rgba(0,0,0,.35),0 0 0 1px rgba(0,0,0,.12);' + 'overflow:hidden;transition:box-shadow .2s;}' + '#hyw-course-assist:hover{box-shadow:0 8px 32px rgba(0,0,0,.45),0 0 0 1px rgba(0,0,0,.15);}' + '#hyw-course-assist .hyw-header{display:flex;align-items:center;justify-content:space-between;' + 'padding:10px 14px 8px;cursor:pointer;}' + '#hyw-course-assist .hyw-header-left{display:flex;align-items:center;gap:7px;}' + '#hyw-course-assist .hyw-header svg{width:16px;height:16px;flex-shrink:0;color:#34d058;}' + '#hyw-course-assist .hyw-header-text{font-size:13px;font-weight:600;color:#fff;letter-spacing:.3px;}' + '#hyw-course-assist .hyw-chevron{width:14px;height:14px;color:rgba(255,255,255,.4);transition:transform .25s ease;}' + '#hyw-course-assist.hyw-collapsed .hyw-chevron{transform:rotate(-90deg);}' + '#hyw-course-assist .hyw-sep{height:1px;background:rgba(255,255,255,.07);margin:0 12px;}' + '#hyw-course-assist .hyw-body{padding:4px 14px 8px;display:flex;flex-direction:column;}' + '#hyw-course-assist .hyw-row{display:flex;align-items:center;justify-content:space-between;' + 'padding:6px 0;border-bottom:1px solid rgba(255,255,255,.05);}' + '#hyw-course-assist .hyw-row:last-child{border-bottom:none;}' + '#hyw-course-assist .hyw-label{font-size:12.5px;color:#c8cace;display:flex;align-items:center;gap:5px;white-space:nowrap;}' + '#hyw-course-assist .hyw-label svg{width:14px;height:14px;opacity:.55;flex-shrink:0;}' + '#hyw-course-assist .hyw-toggle{position:relative;width:34px;height:18px;flex-shrink:0;cursor:pointer;}' + '#hyw-course-assist .hyw-toggle input{opacity:0;width:0;height:0;position:absolute;}' + '#hyw-course-assist .hyw-track{position:absolute;inset:0;border-radius:9px;' + 'background:rgba(255,255,255,.12);transition:background .2s;}' + '#hyw-course-assist .hyw-toggle input:checked+.hyw-track{background:#34d058;}' + '#hyw-course-assist .hyw-knob{position:absolute;top:2px;left:2px;width:14px;height:14px;' + 'border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .2s ease;}' + '#hyw-course-assist .hyw-toggle input:checked~.hyw-knob{transform:translateX(16px);}' + '#hyw-course-assist .hyw-status-box{padding:6px 14px 10px;border-top:1px solid rgba(255,255,255,.05);}' + '#hyw-course-assist .hyw-assist-status{font-size:11.5px;color:rgba(255,255,255,.4);white-space:normal;line-height:1.5;}' + '#hyw-course-assist.hyw-collapsed .hyw-body,'+ '#hyw-course-assist.hyw-collapsed .hyw-sep,'+ '#hyw-course-assist.hyw-collapsed .hyw-status-box{display:none;}'; document.head.appendChild(style); // --- HTML --- var box = document.createElement('div'); box.id = 'hyw-course-assist'; var iconPlay = ''; var iconChevron = ''; var rows = [ { id: 'hyw-close-popup', key: 'autoClosePopup', label: '自动关弹窗', icon: '' }, { id: 'hyw-auto-next', key: 'autoNext', label: '自动下一课', icon: '' }, { id: 'hyw-auto-play', key: 'autoPlay', label: '自动播放', icon: '' }, { id: 'hyw-mute-page', key: 'mutePage', label: '网页静音', icon: '' } ]; var rowsHtml = ''; for (var i = 0; i < rows.length; i++) { var r = rows[i]; rowsHtml += '