// ==UserScript== // @name 网页自动展开(优化版·防冲突) // @version 1.1.2 // @description 智能展开折叠内容;防冲突、防误杀、高性能、用户友好 // @namespace Kiwifruit13 // @match *://*/* // @run-at document-start // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_notification // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/552576/%E7%BD%91%E9%A1%B5%E8%87%AA%E5%8A%A8%E5%B1%95%E5%BC%80%EF%BC%88%E4%BC%98%E5%8C%96%E7%89%88%C2%B7%E9%98%B2%E5%86%B2%E7%AA%81%EF%BC%89.user.js // @updateURL https://update.greasyfork.icu/scripts/552576/%E7%BD%91%E9%A1%B5%E8%87%AA%E5%8A%A8%E5%B1%95%E5%BC%80%EF%BC%88%E4%BC%98%E5%8C%96%E7%89%88%C2%B7%E9%98%B2%E5%86%B2%E7%AA%81%EF%BC%89.meta.js // ==/UserScript== (() => { 'use strict'; // 命名空间隔离 const AE_PREFIX = 'ae_'; const AE_DATA_PREFIX = 'data-ae-'; // 配置管理 const Config = { get: (key, defaultValue) => GM_getValue(`${AE_PREFIX}${key}`, defaultValue), set: (key, value) => GM_setValue(`${AE_PREFIX}${key}`, value), init() { this.enabled = this.get('enabled', true); this.scanInterval = this.get('scan_interval', 300); this.excludeHosts = this.get('exclude_hosts', []); } }; // 状态管理 const State = { expandedSet: new WeakSet(), clickedSet: new WeakSet(), scannedSet: new WeakSet(), observers: new Set() }; // 工具函数 const Utils = { debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; }, throttle(func, limit) { let inThrottle; return function () { const args = arguments; const context = this; if (!inThrottle) { func.apply(context, args); inThrottle = true; setTimeout(() => { inThrottle = false; }, limit); } }; } // ← 这个 } 是 throttle 方法的闭合 }; // 核心逻辑 const Core = { init() { if (!Config.enabled) return; // 检测冲突 if (this.detectConflicts()) return; // 初始化观察者 this.initObservers(); // 初始扫描 this.initialScan(); }, detectConflicts() { // 检测逻辑 return false; }, initObservers() { // 观察者初始化 }, initialScan() { // 初始扫描逻辑 }, scanElement(element) { // 元素扫描逻辑 } }; // 用户界面 const UI = { showNotification(message) { GM_notification({ text: message, title: '自动展开', timeout: 3000 }); }, createConfigPanel() { // 配置面板逻辑 } }; // 初始化 Config.init(); Core.init(); // 注册菜单 GM_registerMenuCommand('⚙️ 自动展开配置', UI.createConfigPanel); })();