// ==UserScript== // @name 智慧树共享课刷课(你的页面专属适配) // @namespace zhihuishu-your-page-fit // @version 11.0.0 // @description 针对你的智慧树页面专属适配,100%识别共享课+可拖动+自动刷课 // @author 专属适配 // @match *://onlineweb.zhihuishu.com/onlinestuh5* // @match *://studyvideoh5.zhihuishu.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @connect tk.enncy.cn // @run-at document-end // ==/UserScript== (function () { 'use strict'; // ===================== 核心配置 ===================== const CONFIG = { watchMinutes: 25, // 单课刷课时长 playbackRate: 1.25, // 倍速 autoSwitch: true, // 自动切课 }; // 言溪题库 const BANK_API = "https://tk.enncy.cn/query"; const BANK_TOKEN = "0abc866e094c4714936e88a84ae3cb93"; // 全局变量 let state = { running: false, currentIndex: 0, currentTime: 0, totalCourses: 0, timer: null, }; let courseList = []; let selectedCourses = []; let panel = null; let isDragging = false; // ===================== 【核心】精准获取你的共享课 ===================== function getCourses() { let list = []; // ----------------===== 你的页面专属精准选择器 =====---------------- // 完全匹配你截图里的DOM:#sharingClassed 里的 .datalist 下的 dl 课程卡片 const courseElements = document.querySelectorAll("#sharingClassed .datalist dl"); courseElements.forEach((el, index) => { // 提取课程标题(精准过滤) const titleEl = el.querySelector("dt h3, dt .course-title, dt"); let title = ""; if (titleEl) { title = titleEl.textContent.trim().replace(/\s+/g, " "); } else { // 兜底提取标题 title = el.innerText.trim().split("在学:")[0].split("进度:")[0].trim(); } // 过滤无效内容 if (!title || title.length < 4) return; if (list.some(item => item.title === title)) return; list.push({ id: `course_${index}`, index: index, title: title, element: el }); }); courseList = list; console.log("【脚本调试】找到课程:", list); // 控制台可以看到找到的课程 return list; } // ===================== 监听DOM变化,自动刷新课程 ===================== function watchDomChange() { const observer = new MutationObserver(() => { // 课程列表有变化,自动刷新 if (document.querySelector("#sharingClassed .datalist")) { refreshCourseList(); } }); observer.observe(document.body, { childList: true, subtree: true }); } // ===================== 可拖动面板 ===================== function createPanel() { const oldPanel = document.getElementById("zhs-panel"); if (oldPanel) oldPanel.remove(); panel = document.createElement("div"); panel.id = "zhs-panel"; panel.style.cssText = ` position: fixed; top: 20px; right: 20px; width: 320px; background: #161d30; border-radius: 12px; box-shadow: 0 0 20px rgba(0,0,0,0.6); z-index: 999999; font-family: system-ui; color: #fff; overflow: hidden; `; panel.innerHTML = `