// ==UserScript== // @name [YIT]-刷课助手 // @version 2.0.2 // @author adapted // @license MIT // @description (yit.haiqikeji.com)在线学习平台刷课助手 — 自动播放视频、自动下一节、进度追踪 // @match *://*.haiqikeji.com/* // @run-at document-end // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // ==/UserScript== (function() { 'use strict'; /********************************* 配置 ****************************************/ var CONFIG = { videoRate: 1, autoNext: true, nextDelay: 3, showBox: true, debug: true }; // 从 localStorage 加载 ['videoRate','autoNext','nextDelay','showBox'].forEach(function(k) { var v = localStorage.getItem('yit_' + k); if (v !== null) { if (v === 'true') CONFIG[k] = true; else if (v === 'false') CONFIG[k] = false; else { var n = parseFloat(v); CONFIG[k] = !isNaN(n) ? n : v; } } }); function saveConfig(key, value) { CONFIG[key] = value; localStorage.setItem('yit_' + key, value); } /********************************* 工具 ****************************************/ function formatTime(s) { if (!s || s < 0) return '00:00'; s = Math.floor(s); var h = Math.floor(s/3600), m = Math.floor((s%3600)/60), sec = s%60; var pad = function(n){return n<10?'0'+n:''+n;}; return (h>0?pad(h)+':':'') + pad(m) + ':' + pad(sec); } function dlog(msg, color) { if (!CONFIG.debug && color !== 'red' && color !== 'green') return; var t = new Date().toLocaleTimeString(); console.log('[YIT '+t+']', msg); try { var el = document.getElementById('yit-log'); if (el) { var div = document.createElement('div'); div.innerHTML = '['+t+'] '+msg+''; el.insertBefore(div, el.firstChild); if (el.children.length > 200) el.removeChild(el.lastChild); } } catch(e) {} } /********************************* UI ****************************************/ function buildPanel() { if (!CONFIG.showBox || document.getElementById('yit-box')) return; var html = '\