// ==UserScript== // @name 智慧树共享课全自动刷课(100%识别) // @namespace zhihuishu-share-course-fix // @version 9.0.0 // @description 专门适配智慧树共享课,自动识别+勾选+自动刷课25分钟切课 // @author 修复共享课识别 // @match *://*.zhihuishu.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_xmlhttpRequest // @connect tk.enncy.cn // @run-at document-start // ==/UserScript== (function () { 'use strict'; // ===================== 配置 ===================== const DEFAULT_CONFIG = { watchTime: 25, playbackRate: 1.25, autoSwitch: true, autoPlay: true, autoClosePopup: true, autoAnswer: true, reviewCompleted: true, useOnlineBankFirst: true, }; const YANXI_BANK_CONFIG = { url: "https://tk.enncy.cn/query", token: "0abc866e094c4714936e88a84ae3cb93", }; // ===================== 全局变量 ===================== let state = { currentCourseIndex: 0, currentTime: 0, isRunning: false, totalCourses: 0 }; let config = { ...DEFAULT_CONFIG }; let allCourseList = []; let selectedCourseList = []; let localQuestionBank = {}; let timer, popupTimer, answerTimer, panel; // ===================== 【核心修复】共享课识别(专门写给你) ===================== function getAllCourseCards() { let list = []; // ----------------===== 【共享课专用】真正能抓到你的课 =====---------------- const shareCourseSelectors = [ ".course-card-item", ".course-list-item", ".share-course-item", ".item-course", ".courseItem", ".course-wrap", "div[class*='course'][class*='item']", "div[class*='share'][class*='course']" ]; for (let sel of shareCourseSelectors) { let items = document.querySelectorAll(sel); items.forEach(el => { let title = el.innerText.trim().replace(/\s+/g, " ").substring(0, 60); if (!title || title.length < 4) return; if (list.some(x => x.title === title)) return; list.push({ id: btoa(title), title: title, element: el }); }); } // 兜底:抓所有带“课程”字样的卡片 if (list.length === 0) { document.querySelectorAll("div").forEach(el => { let t = el.innerText.trim(); if (t.length > 8 && t.length < 80 && /[\u4e00-\u9fa5]/.test(t) && !/登录|注册|退出|客服|帮助/.test(t)) { if (list.some(x => x.title === t)) return; list.push({ id: btoa(t), title: t, element: el }); } }); } allCourseList = list; return list; } // ===================== 下面全部是自动逻辑,不用改 ===================== function loadAll() { try { config = { ...DEFAULT_CONFIG, ...JSON.parse(GM_getValue("zhs_config")) } } catch (e) { } try { state = { ...state, ...JSON.parse(GM_getValue("zhs_state")) } } catch (e) { } try { selectedCourseList = JSON.parse(GM_getValue("zhs_selected")) } catch (e) { } try { localQuestionBank = JSON.parse(GM_getValue("zhs_local_bank")) } catch (e) { } } function saveAll() { GM_setValue("zhs_config", JSON.stringify(config)); GM_setValue("zhs_state", JSON.stringify(state)); GM_setValue("zhs_selected", JSON.stringify(selectedCourseList)); GM_setValue("zhs_local_bank", JSON.stringify(localQuestionBank)); } function createPanel() { let old = document.getElementById("zhs-panel"); if (old) old.remove(); panel = document.createElement("div"); panel.id = "zhs-panel"; panel.innerHTML = `