// ==UserScript== // @name 智能目录(优化版) // @namespace https://greasyfork.org/users/1171320 // @version 1.0 // @description 智能提取网页标题生成目录,支持拖拽记忆位置、双击收起、重置位置等。自动排除验证码和无目录页面。 // @author yzcjd // @author2 ChatGPT4 辅助 // @match *://*/* // @grant GM_addStyle // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/534123/%E6%99%BA%E8%83%BD%E7%9B%AE%E5%BD%95%EF%BC%88%E4%BC%98%E5%8C%96%E7%89%88%EF%BC%89.user.js // @updateURL https://update.greasyfork.icu/scripts/534123/%E6%99%BA%E8%83%BD%E7%9B%AE%E5%BD%95%EF%BC%88%E4%BC%98%E5%8C%96%E7%89%88%EF%BC%89.meta.js // ==/UserScript== (function() { 'use strict'; const excludePatterns = [ 'cloudflare', 'challenge', 'captcha', 'recaptcha', 'accounts.google.com', 'facebook.com/login', 'twitter.com/login', 'auth', 'verify', 'login', 'signin', 'logon' ]; const hostname = location.hostname; if (excludePatterns.some(pattern => hostname.includes(pattern))) { console.log('智能目录:已跳过本页面(检测到可能是验证码/登录页)'); return; } function $(selector, parent = document) { return parent.querySelector(selector); } function $all(selector, parent = document) { return [...parent.querySelectorAll(selector)]; } function savePosition(x, y) { const key = 'SmartTOC:position:' + hostname; localStorage.setItem(key, JSON.stringify({ x, y })); } function loadPosition() { const key = 'SmartTOC:position:' + hostname; const pos = localStorage.getItem(key); if (pos) { try { return JSON.parse(pos); } catch (e) {} } return null; } function resetPosition() { const key = 'SmartTOC:position:' + hostname; localStorage.removeItem(key); location.reload(); } const toc = document.createElement('div'); toc.id = 'smart-toc'; toc.style.cssText = ` position: fixed; top: 50px; right: 50px; width: 250px; max-height: 80vh; overflow: auto; background: #fff; color: #333; font-size: 14px; font-family: sans-serif; border: 1px solid #ccc; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 99999; transition: max-height 0.3s, width 0.3s; `; toc.innerHTML = '