2048-预览

为2048核基地论坛帖子添加图片、链接预览

// ==UserScript==
// @name         2048-预览
// @version      1.1.2
// @namespace    https://sleazyfork.org/zh-CN/users/1461640-%E6%98%9F%E5%AE%BF%E8%80%81%E9%AD%94
// @author       星宿老魔
// @description  为2048核基地论坛帖子添加图片、链接预览
// @match        https://hjd2048.com/2048/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=hjd2048.com
// @license      MIT
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-start
// ==/UserScript==

(function(){"use strict";const o={name:"2048-预览",version:"1.1.0",currentDomain:"hjd2048.com",defaults:{MAX_PREVIEW_IMAGES:3,CONCURRENT_LIMIT:9,EXCLUDED_FORUMS:["56","102"]},get(l){try{return GM_getValue(l,this.defaults[l])}catch(e){return console.warn(`[${this.name}] 获取配置失败:`,e),this.defaults[l]}},set(l,e){try{GM_setValue(l,e)}catch(t){console.warn(`[${this.name}] 保存配置失败:`,t)}},getAll(){const l={};for(const e in this.defaults)l[e]=this.get(e);return l.EXCLUDED_FORUMS=this.get("EXCLUDED_FORUMS"),l},selectors:{threadRows:"tr.tr3.t_one",threadLinks:'a[target="_self"], a[target="_blank"]',contentSelectors:["#read_tpc",".tpc_content",".f14.cc",'div[id="read_tpc"]',".t_f"],searchLink:'#nav-pc a[href="/search.php"]',navSearch:"#nav-s",searchResultTable:".t table",searchResultRows:'tr[id^="search_"]',searchResultHeader:".t table .h",previewRows:"tr.imagePreviewTr",imgSelectors:["#read_tpc img",".tpc_content img",".f14.cc img",'div[id="read_tpc"] img'],magnetTextarea:"textarea[readonly], textarea#copytext",magnetLink:'a[href^="magnet:?xt=urn:btih:"]',ed2kLink:'a[href^="ed2k://"]',btLink:'a[href*="bt.ivcbt.com/list.php?name="], a[href*="bt.bxmho.cn/list.php?name="]'},regex:{threadUrl:/read\.php\?tid=/,searchUrl:/search\.php/,searchRowId:/^search_(\d+)_(\d+)$/,magnetHash:/([A-F0-9]{40})/i,fileSize:/【影片容量】:([^<]+)<br|【影片大小】:([^<]+)/i,thunder:/thunder:\/\/[A-Za-z0-9+\/=]+/i,ed2k:/ed2k:\/\/\|file\|[^|]+\|\d+\|[A-F0-9]{32}\|\//i,magnetLink:/magnet:\?xt=urn:btih:[a-zA-Z0-9]+/,copyText:/magnet:\?xt=urn:btih:/},filters:{badImagePatterns:[/^(none|empty|blank|default)\./,/^(icon|logo|banner|ad)_/,/\.(ico|cur)$/,/^(loading|wait|spinner)/],badImageClasses:["icon","emoji","smiley"],minImageSize:{width:100,height:100}}},m={copyToClipboard(l,e){navigator.clipboard.writeText(l).then(()=>{this.showClickTip("已复制",e)}).catch(()=>{console.warn("复制失败,使用fallback方法"),this.fallbackCopyTextToClipboard(l,e)})},fallbackCopyTextToClipboard(l,e){const t=document.createElement("textarea");t.value=l,t.style.position="fixed",t.style.top="-1000px",t.style.left="-1000px",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy"),this.showClickTip("已复制",e)}catch(n){console.error("复制失败:",n),this.showClickTip("复制失败",e)}document.body.removeChild(t)},showClickTip(l,e){const t=e;let n=document.querySelector(".click-tip");n&&n.remove(),n=document.createElement("div"),n.className="click-tip",n.textContent=l,document.body.appendChild(n),n.style.left=`${t.clientX}px`,n.style.top=`${t.clientY}px`,setTimeout(()=>{n.style.opacity="1"},10),setTimeout(()=>{n.style.opacity="0",setTimeout(()=>{n.parentElement&&n.remove()},200)},1e3)},removeRules(){try{const l=document.querySelector(".collapse-header");if(l){const e=l.closest("div, section, .rule-container, .collapse-container");e&&e.remove()}}catch(l){console.error("移除版规时出错:",l)}},isContentPage(){return o.regex.threadUrl.test(window.location.href)},async asyncPool(l,e,t){const n=[],i=[];for(const a of e){const s=Promise.resolve().then(()=>t(a,e));if(n.push(s),l<=e.length){const r=s.then(()=>{const c=i.indexOf(r);c!==-1&&i.splice(c,1)});i.push(r),i.length>=l&&await Promise.race(i)}}return Promise.all(n)},debounce(l,e,t){let n=null;return function(...i){const a=()=>{n=null,t||l.apply(this,i)},s=t&&!n;n&&clearTimeout(n),n=setTimeout(a,e),s&&l.apply(this,i)}},waitForElement(l,e=5e3){return new Promise(t=>{const n=document.querySelector(l);if(n){t(n);return}const i=new MutationObserver(()=>{const a=document.querySelector(l);a&&(i.disconnect(),t(a))});i.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>{i.disconnect(),t(null)},e)})},safeQuerySelector(l,e=document){try{return e.querySelector(l)}catch(t){return console.warn(`[${o.name}] 选择器查询失败:`,l,t),null}},safeQuerySelectorAll(l,e=document){try{return Array.from(e.querySelectorAll(l))}catch(t){return console.warn(`[${o.name}] 选择器查询失败:`,l,t),[]}}},E=class E{static getForumById(e){return this.FORUM_SECTIONS.find(t=>t.id===e)}static getForumsByLevel(e){return this.FORUM_SECTIONS.filter(t=>t.level===e)}static getChildForums(e){return this.FORUM_SECTIONS.filter(t=>t.parent===e)}static getMainCategories(){return this.FORUM_SECTIONS.filter(e=>e.level===2&&e.parent==="1")}static getSexInfoForumIds(){return this.FORUM_SECTIONS.filter(e=>e.name.includes("性息")||e.parent==="218").map(e=>e.id)}static getDisplayName(e){return`${" ".repeat(Math.max(0,e.level-2))}${e.name}`}static getForumTree(){const e=[];return this.getMainCategories().forEach(n=>{e.push(n),this.getChildForums(n.id).forEach(a=>{e.push(a);const s=this.getChildForums(a.id);e.push(...s)})}),e}};E.FORUM_SECTIONS=[{id:"all",name:"全部版块分类",level:0},{id:"1",name:"总板块",level:1},{id:"2",name:"新片速递",level:2,parent:"1"},{id:"3",name:"最新合集",level:3,parent:"2"},{id:"4",name:"亞洲無碼",level:3,parent:"2"},{id:"5",name:"日本騎兵",level:3,parent:"2"},{id:"13",name:"歐美新片",level:3,parent:"2"},{id:"15",name:"國內原創",level:3,parent:"2"},{id:"16",name:"中字原創",level:3,parent:"2"},{id:"18",name:"三級寫真",level:3,parent:"2"},{id:"343",name:"实时BT",level:3,parent:"2"},{id:"326",name:"本站高清影院",level:3,parent:"2"},{id:"7",name:"图片专区",level:2,parent:"1"},{id:"23",name:"網友自拍",level:3,parent:"7"},{id:"24",name:"亞洲激情",level:3,parent:"7"},{id:"25",name:"歐美激情",level:3,parent:"7"},{id:"26",name:"熟女专图",level:3,parent:"7"},{id:"27",name:"高跟絲襪",level:3,parent:"7"},{id:"28",name:"卡通漫畫",level:3,parent:"7"},{id:"345",name:"图你所图",level:3,parent:"7"},{id:"135",name:"原創达人",level:3,parent:"7"},{id:"273",name:"美图秀秀",level:2,parent:"1"},{id:"21",name:"唯美清純",level:3,parent:"273"},{id:"275",name:"亞洲正妹",level:3,parent:"273"},{id:"276",name:"素人正妹",level:3,parent:"273"},{id:"277",name:"角色扮演",level:3,parent:"273"},{id:"278",name:"A I 智能",level:3,parent:"273"},{id:"320",name:"优质图片",level:3,parent:"273"},{id:"333",name:"明星合成",level:3,parent:"273"},{id:"29",name:"动态图片",level:3,parent:"273"},{id:"92",name:"精品收录",level:2,parent:"1"},{id:"295",name:"原创首发",level:3,parent:"92"},{id:"94",name:"稀有首發",level:3,parent:"92"},{id:"329",name:"藏精阁 — 2017-2024",level:4,parent:"94"},{id:"283",name:"网络见闻",level:3,parent:"92"},{id:"111",name:"主播實錄",level:3,parent:"92"},{id:"99",name:"國產主播",level:4,parent:"111"},{id:"324",name:"自购主播区",level:4,parent:"111"},{id:"323",name:"国产主播2区",level:4,parent:"111"},{id:"322",name:"国产主播3区",level:4,parent:"111"},{id:"131",name:"名站同步",level:3,parent:"92"},{id:"314",name:"真实街拍",level:3,parent:"92"},{id:"341",name:"原档115",level:3,parent:"92"},{id:"213",name:"国产主播同步",level:4,parent:"341"},{id:"342",name:"VR視頻2023-2025",level:4,parent:"341"},{id:"290",name:"日本4K超清",level:4,parent:"341"},{id:"303",name:"高清有碼",level:4,parent:"341"},{id:"302",name:"AI視界",level:4,parent:"341"},{id:"304",name:"外掛字幕",level:4,parent:"341"},{id:"306",name:"FC2視頻",level:4,parent:"341"},{id:"307",name:"S-cute / Mywife",level:4,parent:"341"},{id:"305",name:"亞洲SM",level:4,parent:"341"},{id:"321",name:"补档申请",level:3,parent:"92"},{id:"75",name:"免空網盤",level:2,parent:"1"},{id:"72",name:"网盘二区",level:3,parent:"75"},{id:"272",name:"网盘三区",level:3,parent:"75"},{id:"195",name:"优质 B T",level:3,parent:"75"},{id:"280",name:"国产精选",level:3,parent:"75"},{id:"76",name:"多挂原创",level:3,parent:"75"},{id:"55",name:"有声小说",level:3,parent:"75"},{id:"180",name:"实用漫画",level:3,parent:"75"},{id:"113",name:"原档收藏",level:3,parent:"75"},{id:"116",name:"有碼.HD",level:4,parent:"113"},{id:"114",name:"亞洲SM.HD",level:4,parent:"113"},{id:"96",name:"日韓VR/3D",level:4,parent:"113"},{id:"119",name:"S-cute / Mywife / G-area",level:4,parent:"113"},{id:"41",name:"綜合資源",level:2,parent:"1"},{id:"43",name:"E D 2 K",level:3,parent:"41"},{id:"315",name:"原档字幕",level:3,parent:"41"},{id:"318",name:"磁链迅雷",level:3,parent:"41"},{id:"316",name:"包罗万象",level:3,parent:"41"},{id:"271",name:"聚合1区",level:4,parent:"316"},{id:"281",name:"聚合2区",level:4,parent:"316"},{id:"284",name:"聚合3区",level:4,parent:"316"},{id:"313",name:"远古资源",level:4,parent:"316"},{id:"319",name:"聚合5区",level:4,parent:"316"},{id:"325",name:"聚合6区 WK",level:4,parent:"316"},{id:"327",name:"聚合7区",level:4,parent:"316"},{id:"332",name:"司机社",level:4,parent:"316"},{id:"335",name:"套图学院",level:4,parent:"316"},{id:"334",name:"游戏下载",level:4,parent:"316"},{id:"340",name:"韩国主播",level:4,parent:"316"},{id:"344",name:"美足踩踏",level:4,parent:"316"},{id:"346",name:"套图百晓生",level:4,parent:"316"},{id:"348",name:"街拍精品",level:4,parent:"316"},{id:"67",name:"正片大片",level:3,parent:"41"},{id:"66",name:"H-GAME",level:3,parent:"41"},{id:"291",name:"快播影院",level:3,parent:"41"},{id:"293",name:"快播1号",level:4,parent:"291"},{id:"294",name:"快播2号",level:4,parent:"291"},{id:"296",name:"快播3号",level:4,parent:"291"},{id:"299",name:"快播4号",level:4,parent:"291"},{id:"300",name:"快播5号",level:4,parent:"291"},{id:"301",name:"快播6号",level:4,parent:"291"},{id:"308",name:"快播7号",level:4,parent:"291"},{id:"309",name:"快播频道",level:4,parent:"291"},{id:"311",name:"快播10号",level:4,parent:"291"},{id:"312",name:"快播11号",level:4,parent:"291"},{id:"331",name:"本站破解资源",level:3,parent:"41"},{id:"102",name:"文学欣赏",level:2,parent:"1"},{id:"328",name:"在线速听",level:3,parent:"102"},{id:"48",name:"综合小说",level:3,parent:"102"},{id:"49",name:"激情都市",level:4,parent:"48"},{id:"51",name:"青春校园",level:4,parent:"48"},{id:"52",name:"武侠虚幻",level:4,parent:"48"},{id:"105",name:"另类其他",level:4,parent:"48"},{id:"103",name:"人妻意淫",level:3,parent:"102"},{id:"50",name:"乱伦迷情",level:3,parent:"102"},{id:"54",name:"长篇连载",level:3,parent:"102"},{id:"100",name:"文学作者",level:3,parent:"102"},{id:"109",name:"TXT小说打包",level:3,parent:"102"},{id:"297",name:"2008-2024大集合",level:4,parent:"109"},{id:"110",name:"TXT小说綜合一区",level:4,parent:"109"},{id:"189",name:"TXT小说綜合二区",level:4,parent:"109"},{id:"193",name:"同人小说",level:4,parent:"109"},{id:"336",name:"耽美小说",level:4,parent:"109"},{id:"192",name:"言情小说",level:4,parent:"109"},{id:"338",name:"常规小说",level:4,parent:"109"},{id:"190",name:"都市校园",level:4,parent:"109"},{id:"191",name:"武侠小说",level:4,parent:"109"},{id:"93",name:"TXT小说網盤區",level:4,parent:"109"},{id:"56",name:"网友互动",level:2,parent:"1"},{id:"57",name:"聚友客栈",level:3,parent:"56"},{id:"61",name:"求片专版",level:3,parent:"56"},{id:"206",name:"重金求片区(米粒悬赏)限侠客以上",level:4,parent:"61"},{id:"218",name:"成人信息",level:3,parent:"56"},{id:"220",name:"北京性息",level:4,parent:"218"},{id:"237",name:"上海性息",level:4,parent:"218"},{id:"238",name:"广州性息",level:4,parent:"218"},{id:"239",name:"深圳性息",level:4,parent:"218"},{id:"287",name:"赚米专区",level:3,parent:"56"},{id:"136",name:"坛友自售",level:3,parent:"56"},{id:"289",name:"破解软件",level:3,parent:"56"},{id:"339",name:"包养情报",level:3,parent:"56"},{id:"128",name:"问题建议/举报申诉",level:3,parent:"56"},{id:"292",name:"解禁忏悔区/丢失找回",level:4,parent:"128"}];let d=E;const u=class u{static init(){this.initialized||this.isSearchResultPage()&&(console.log(`[${o.name}] 检测到搜索结果页面,启用过滤功能`),this.filterSearchResults(),this.updateResultStats(),this.initialized=!0)}static isSearchResultPage(){if(!window.location.href.includes("search.php"))return!1;const e=document.querySelector(".t table"),t=document.querySelectorAll('tr[id^="search_"]');return!!(e&&t.length>0)}static extractForumId(e){const t=e.getAttribute("id");if(t&&t.startsWith("search_")){const n=t.split("_");if(n.length>=2)return n[1]}return null}static getExcludedForums(){return o.get("EXCLUDED_FORUMS")||[]}static filterSearchResults(){const e=this.getExcludedForums();if(e.length===0){console.log(`[${o.name}] 未设置排除板块,跳过过滤`);return}console.log(`[${o.name}] 排除板块列表:`,e.map(i=>{const a=d.getForumById(i);return a?`${a.name}(${i})`:i}));const t=document.querySelectorAll('tr[id^="search_"]');this.totalCount=t.length;let n=0;t.forEach(i=>{const a=this.extractForumId(i);if(a&&e.includes(a)){i.style.display="none";const s=i.nextElementSibling;s&&s.classList.contains("imagePreviewTr")&&(s.style.display="none"),n++;const r=d.getForumById(a);console.log(`[${o.name}] 已隐藏: ${r?.name||a} - ${i.querySelector("a")?.textContent?.trim()}`)}}),this.filteredCount=n,console.log(`[${o.name}] 过滤完成: 总数${this.totalCount}, 隐藏${n}, 显示${this.totalCount-n}`)}static updateResultStats(){if(this.filteredCount===0)return;const e=document.querySelector(".t table .h");if(e){const t=e.textContent||"主题列表",n=this.totalCount-this.filteredCount;e.textContent=`${t} (显示 ${n}/${this.totalCount} 条结果,已过滤 ${this.filteredCount} 条)`,e.setAttribute("title",`已根据设置隐藏${this.filteredCount}条不相关结果`)}}static reapplyFilter(){if(!this.isSearchResultPage())return;document.querySelectorAll('tr[id^="search_"], tr.imagePreviewTr').forEach(t=>{t.style.display=""}),this.filteredCount=0,this.filterSearchResults(),this.updateResultStats(),console.log(`[${o.name}] 已重新应用搜索过滤器`)}static getFilterStats(){return{total:this.totalCount,filtered:this.filteredCount,visible:this.totalCount-this.filteredCount}}static clearAllFilters(){o.set("EXCLUDED_FORUMS",[]),this.reapplyFilter()}static applyPresetExcludeSexInfo(){const e=d.getSexInfoForumIds(),t=this.getExcludedForums(),n=[...new Set([...t,...e])];o.set("EXCLUDED_FORUMS",n),this.reapplyFilter(),console.log(`[${o.name}] 已应用预设:排除性息板块`)}static addExcludedForum(e){const t=this.getExcludedForums();t.includes(e)||(t.push(e),o.set("EXCLUDED_FORUMS",t),this.reapplyFilter())}static removeExcludedForum(e){const n=this.getExcludedForums().filter(i=>i!==e);o.set("EXCLUDED_FORUMS",n),this.reapplyFilter()}static toggleForumExclusion(e){this.getExcludedForums().includes(e)?this.removeExcludedForum(e):this.addExcludedForum(e)}};u.initialized=!1,u.filteredCount=0,u.totalCount=0;let g=u;const C=class C{static init(){this.initialized||(this.addSettingsButton(),this.initialized=!0)}static addSettingsButton(){const e=document.querySelector(o.selectors.searchLink),t=e?e.parentElement:null;if(t){const n=document.createElement("li"),i=document.createElement("a");i.href="javascript:;",i.textContent="脚本配置",n.appendChild(i),t.parentElement.insertBefore(n,t.nextSibling);const a=this.createSettingsPanel();i.addEventListener("click",s=>{s.preventDefault(),a.show()})}else this.addFallbackSettingsButton()}static addFallbackSettingsButton(){const e=document.getElementById("nav-s");if(e){const t=document.createElement("a");t.href="javascript:;",t.textContent="脚本配置",t.style.color="#fff",t.style.marginRight="15px",t.className="fr",e.insertBefore(t,e.firstChild);const n=this.createSettingsPanel();t.addEventListener("click",i=>{i.preventDefault(),n.show()})}}static createSettingsPanel(){document.body.insertAdjacentHTML("beforeend",`
      <div id="preview-settings-panel" style="display:none; position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); z-index:10001;">
        <h3>脚本设置</h3>
        
        <div class="settings-tabs">
          <button class="tab-button" data-tab="preview">预览设置</button>
          <button class="tab-button" data-tab="search">搜索过滤</button>
        </div>
        
        <div id="tab-preview" class="tab-content">
          <div class="settings-group">
            <div class="settings-group-title">预览图数量</div>
            <div class="settings-options">
              <label class="option-item">
              <input type="radio" name="MAX_PREVIEW_IMAGES" value="3" checked>
                <span class="option-text">少量 (3张)</span>
            </label>
              <label class="option-item">
              <input type="radio" name="MAX_PREVIEW_IMAGES" value="4">
                <span class="option-text">适中 (4张)</span>
            </label>
              <label class="option-item">
              <input type="radio" name="MAX_PREVIEW_IMAGES" value="5">
                <span class="option-text">较多 (5张)</span>
            </label>
            </div>
          </div>

          <div class="settings-group">
            <div class="settings-group-title">加载速度</div>
            <div class="settings-options">
              <label class="option-item">
              <input type="radio" name="CONCURRENT_LIMIT" value="6">
                <span class="option-text">稳定 (6个并发)</span>
            </label>
              <label class="option-item">
              <input type="radio" name="CONCURRENT_LIMIT" value="9" checked>
                <span class="option-text">平衡 (9个并发)</span>
            </label>
              <label class="option-item">
              <input type="radio" name="CONCURRENT_LIMIT" value="12">
                <span class="option-text">快速 (12个并发)</span>
            </label>
            </div>
          </div>
        </div>
        
        <div id="tab-search" class="tab-content">
          <div id="forum-list" class="forum-list"></div>
        </div>
        
        <div class="panel-buttons">
          <div class="filter-controls">
            <div class="filter-actions">
              <button id="clear-all-filters" class="action-btn">清除所有</button>
              <button id="select-all-forums" class="action-btn">全选</button>
            </div>
            <div class="filter-description">
              勾选上方板块,在搜索结果中隐藏这些板块的内容
            </div>
          </div>
          <div class="main-buttons">
            <button id="close-settings-btn" class="btn btn-secondary">关闭</button>
            <button id="save-settings-btn" class="btn btn-primary">保存设置</button>
          </div>
        </div>
      </div>
      <div id="preview-settings-overlay" style="display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:10000;"></div>
    `);const t=document.getElementById("preview-settings-panel"),n=document.getElementById("preview-settings-overlay");return this.initTabsNavigation(),this.generateForumList(),this.loadCurrentSettings(),setTimeout(()=>{this.setupEventListeners(t,n)},50),{show:()=>{t.style.display="block",n.style.display="block"}}}static initTabsNavigation(){const e=document.querySelectorAll(".tab-button");document.querySelectorAll(".tab-content");const t=GM_getValue("LAST_ACTIVE_TAB","preview");e.forEach(n=>{n.addEventListener("click",()=>{const i=n.dataset.tab;GM_setValue("LAST_ACTIVE_TAB",i),this.activateTab(i)})}),this.activateTab(t)}static activateTab(e){const t=document.querySelectorAll(".tab-button"),n=document.querySelectorAll(".tab-content"),i=document.getElementById("preview-settings-panel");t.forEach(r=>r.classList.remove("active")),n.forEach(r=>r.classList.remove("active"));const a=document.querySelector(`[data-tab="${e}"]`),s=document.getElementById(`tab-${e}`);a&&s&&(a.classList.add("active"),s.classList.add("active")),i&&(e==="search"?i.classList.add("search-active"):i.classList.remove("search-active"))}static generateForumList(){const e=document.getElementById("forum-list");d.getForumTree().forEach(n=>{if(n.level<=1)return;const i=document.createElement("div");i.className="forum-item";const a=document.createElement("input");a.type="checkbox",a.id=`forum-${n.id}`,a.value=n.id,a.className="forum-checkbox";const s=document.createElement("label");s.htmlFor=a.id,s.className=`forum-name level-${n.level}`,s.textContent=d.getDisplayName(n),i.appendChild(a),i.appendChild(s),e.appendChild(i),n.level===2&&a.addEventListener("change",()=>{this.handleParentForumToggle(n.id,a.checked)}),n.level>2&&a.addEventListener("change",()=>{this.updateParentForumState(n)})}),this.initializeParentChildStates()}static loadCurrentSettings(){const e=o.getAll();for(const n in e){if(n==="EXCLUDED_FORUMS")continue;const i=document.querySelector(`[name="${n}"][value="${e[n]}"]`);i&&(i.checked=!0)}(e.EXCLUDED_FORUMS||[]).forEach(n=>{const i=document.getElementById(`forum-${n}`);i&&(i.checked=!0)}),setTimeout(()=>{this.initializeParentChildStates()},100)}static setupEventListeners(e,t){const n=document.getElementById("save-settings-btn");n?n.addEventListener("click",c=>{c.preventDefault(),c.stopPropagation(),console.log("[SettingsPanel] 保存设置按钮被点击"),this.saveSettings()}):console.error("[SettingsPanel] 找不到保存设置按钮");const i=()=>{e.style.display="none",t.style.display="none"},a=document.getElementById("close-settings-btn");a&&a.addEventListener("click",i),t.addEventListener("click",i);const s=document.getElementById("clear-all-filters");s&&s.addEventListener("click",()=>{this.clearAllFilters()});const r=document.getElementById("select-all-forums");r&&r.addEventListener("click",()=>{this.selectAllForums()})}static saveSettings(){console.log("[SettingsPanel] 开始保存设置");try{const e=document.querySelectorAll('input[type="radio"]:checked');console.log(`[SettingsPanel] 找到 ${e.length} 个选中的radio按钮`),e.forEach(n=>{const i=n,a=parseInt(i.value,10);console.log(`[SettingsPanel] 保存预览设置: ${i.name} = ${a}`),o.set(i.name,a)});const t=Array.from(document.querySelectorAll(".forum-checkbox:checked")).map(n=>n.value);console.log(`[SettingsPanel] 保存排除板块: ${t.length} 个板块`,t),o.set("EXCLUDED_FORUMS",t),this.showSaveSuccessAndClose(t.length),console.log("[SettingsPanel] 设置保存完成")}catch(e){console.error("[SettingsPanel] 保存设置时出错:",e),this.showMessage("保存失败,请重试!","error")}}static clearAllFilters(){document.querySelectorAll(".forum-checkbox").forEach(t=>t.checked=!1)}static selectAllForums(){document.querySelectorAll(".forum-checkbox").forEach(t=>t.checked=!0)}static handleParentForumToggle(e,t){d.getChildForums(e).forEach(i=>{const a=document.getElementById(`forum-${i.id}`);a&&(a.checked=t,d.getChildForums(i.id).length>0&&this.handleParentForumToggle(i.id,t))})}static updateParentForumState(e){const t=e.parent;if(!t)return;const n=document.getElementById(`forum-${t}`);if(!n)return;const i=d.getChildForums(t),a=i.filter(r=>{const c=document.getElementById(`forum-${r.id}`);return c&&c.checked});n.checked=a.length===i.length&&i.length>0;const s=d.getForumById(t);s&&s.parent&&this.updateParentForumState(s)}static initializeParentChildStates(){d.getForumsByLevel(2).forEach(t=>{this.updateParentForumStateById(t.id)})}static updateParentForumStateById(e){const t=document.getElementById(`forum-${e}`);if(!t)return;const n=d.getChildForums(e);if(n.length===0)return;const i=n.filter(a=>{const s=document.getElementById(`forum-${a.id}`);return s&&s.checked});t.checked=i.length===n.length}static showSaveSuccessAndClose(e){const t=window.location.href.includes("search.php");this.closePanel();let n="";e===0?n="已清空过滤设置":t?(g.reapplyFilter(),n=`过滤生效,已排除 ${e} 个板块`):n=`已保存,排除 ${e} 个板块`,this.showQuickMessage(n)}static showMessage(e,t="info"){const n=document.getElementById("settings-message");n&&n.remove();const i=document.createElement("div");i.id="settings-message",i.className=`settings-message settings-message-${t}`,i.textContent=e;const a=document.getElementById("preview-settings-panel");a&&(a.appendChild(i),setTimeout(()=>{i.classList.add("show")},10))}static closePanel(){const e=document.getElementById("preview-settings-panel"),t=document.getElementById("preview-settings-overlay");e&&t&&(e.style.display="none",t.style.display="none")}static showQuickMessage(e){const t=document.getElementById("quick-message");t&&t.remove();const n=document.createElement("div");n.id="quick-message",n.className="quick-message",n.textContent=e,document.body.appendChild(n),setTimeout(()=>{n.classList.add("show")},10),setTimeout(()=>{n.classList.remove("show"),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n)},300)},2e3)}};C.initialized=!1;let y=C;const p=class p{static init(){this.createLightbox(),this.setupEventListeners()}static createLightbox(){if(this.lightbox)return;this.lightbox=document.createElement("div"),this.lightbox.className="lightbox",this.lightboxContent=document.createElement("div"),this.lightboxContent.className="lightbox-content",this.lightboxImg=document.createElement("img"),this.lightboxImg.className="lightbox-image";const e=document.createElement("div");e.className="lightbox-close",e.innerHTML="×";const t=document.createElement("div");t.className="lightbox-prev",t.innerHTML="‹";const n=document.createElement("div");n.className="lightbox-next",n.innerHTML="›",this.loadingText=document.createElement("div"),this.loadingText.className="lightbox-loading",this.loadingText.textContent="加载中...",this.lightboxContent.appendChild(this.loadingText),this.lightboxContent.appendChild(this.lightboxImg),this.lightbox.appendChild(this.lightboxContent),this.lightbox.appendChild(e),this.lightbox.appendChild(t),this.lightbox.appendChild(n),document.body.appendChild(this.lightbox),this.closeBtn=e,this.prevBtn=t,this.nextBtn=n}static setupEventListeners(){!this.closeBtn||!this.prevBtn||!this.nextBtn||!this.lightbox||(this.closeBtn.addEventListener("click",()=>this.closeLightbox()),this.prevBtn.addEventListener("click",e=>{e.stopPropagation(),this.currentIndex=(this.currentIndex-1+this.currentImages.length)%this.currentImages.length,this.updateLightboxImage()}),this.nextBtn.addEventListener("click",e=>{e.stopPropagation(),this.currentIndex=(this.currentIndex+1)%this.currentImages.length,this.updateLightboxImage()}),this.lightbox.addEventListener("click",e=>{e.target===this.lightbox&&this.closeLightbox()}),document.addEventListener("keydown",e=>{this.lightbox?.classList.contains("active")&&(e.key==="Escape"?this.closeLightbox():e.key==="ArrowLeft"?this.prevBtn?.click():e.key==="ArrowRight"&&this.nextBtn?.click())}))}static updateLightboxImage(){if(!this.lightboxImg||!this.loadingText||!this.lightboxContent)return;const e=this.currentImages[this.currentIndex];this.loadingText.textContent="加载中...",this.loadingText.style.display="block",this.lightboxImg.style.display="none",this.lightboxImg.style.width="",this.lightboxImg.style.height="",this.lightboxContent.classList.remove("landscape","portrait"),this.lightboxImg.src=e,this.lightboxImg.onload=()=>{!this.lightboxImg||!this.loadingText||!this.lightboxContent||(this.loadingText.style.display="none",this.lightboxImg.style.display="block",this.lightboxImg.naturalWidth<300&&this.lightboxImg.naturalHeight<300?this.lightboxImg.style.width=this.lightboxImg.naturalWidth*2+"px":this.lightboxImg.naturalWidth>this.lightboxImg.naturalHeight?this.lightboxContent.classList.add("landscape"):this.lightboxContent.classList.add("portrait"))},this.lightboxImg.onerror=()=>{this.loadingText&&(this.loadingText.textContent="图片加载失败")}}static showLightbox(e,t){this.lightbox&&(this.currentImages=e,this.currentIndex=t,this.updateLightboxImage(),this.lightbox.classList.add("active"))}static closeLightbox(){this.lightbox&&this.lightbox.classList.remove("active")}};p.lightbox=null,p.lightboxImg=null,p.lightboxContent=null,p.loadingText=null,p.currentImages=[],p.currentIndex=0,p.closeBtn=null,p.prevBtn=null,p.nextBtn=null;let f=p;const k=class k{static injectStyles(){if(this.styleInjected||document.getElementById("preview-styles"))return;const e=document.createElement("style");e.id="preview-styles",e.textContent=`
      /* 脚本核心样式 - 仿网站原生风格 */
      .thread-title-highlighted { 
        background-color: #e8f4fd !important; 
        border-radius: 4px 4px 0 0;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      }
      
      .click-tip { 
        position: fixed; 
        background: rgba(0,0,0,0.8); 
        color: white; 
        padding: 6px 12px; 
        border-radius: 6px; 
        font-size: 13px; 
        z-index: 10000; 
        opacity: 0; 
        transition: opacity 0.3s ease; 
        transform: translate(15px, -15px);
        backdrop-filter: blur(4px);
      }
      
      /* 预览容器 */
      .preview-container { 
        margin: 0 0 10px 0; 
        border: 1px solid #e1e8ed; 
        border-top: none; 
        border-radius: 0 0 4px 4px; 
        padding: 16px; 
        background: #fafbfc;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
      }
      
      .preview-section { 
        margin-bottom: 14px; 
        animation: slideIn 0.3s ease-out; 
      }
      
      .preview-section-title { 
        font-size: 14px; 
        color: #374151; 
        margin-bottom: 8px; 
        font-weight: 600;
        display: flex;
        align-items: center;
      }
      
      .preview-section-title:before {
        content: '';
        width: 3px;
        height: 16px;
        background: #3b82f6;
        margin-right: 8px;
        border-radius: 2px;
      }
      
      @keyframes slideIn { 
        from { opacity: 0; transform: translateY(-8px); } 
        to { opacity: 1; transform: translateY(0); } 
      }
      
      /* 预览图片 */
      .preview-images { 
        display: grid; 
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
        gap: 12px; 
        margin-bottom: 16px; 
      }
      
      .preview-image { 
        width: 100%; 
        height: 200px; 
        object-fit: contain; 
        border-radius: 6px;
        transition: all 0.2s ease; 
        cursor: pointer;
        background: #f8f9fa;
        border: 1px solid #e9ecef;
      }
      
      .preview-image:hover { 
        transform: translateY(-2px); 
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border-color: #3b82f6;
      }
      
      .preview-filesize { 
        color: #dc2626; 
        font-weight: 600; 
        font-size: 13px;
        background: #fef2f2;
        padding: 2px 6px;
        border-radius: 4px;
        display: inline-block;
      }
      
      .preview-magnet { 
        font-size: 13px; 
        word-break: break-all; 
        cursor: pointer; 
        padding: 10px 12px; 
        background: #f0f9ff; 
        border: 1px solid #e0f2fe;
        border-radius: 6px; 
        margin-bottom: 10px;
        transition: all 0.2s ease;
        position: relative;
      }
      
      .preview-magnet:hover {
        background: #e0f2fe;
        border-color: #0ea5e9;
        transform: translateX(2px);
      }
      
      /* Lightbox */
      .lightbox { 
        position: fixed; 
        top: 0; left: 0; 
        width: 100%; height: 100%; 
        background: rgba(0,0,0,0.9); 
        display: flex; 
        align-items: center; 
        justify-content: center; 
        z-index: 9999; 
        opacity: 0; 
        visibility: hidden; 
        transition: all 0.3s ease;
        backdrop-filter: blur(8px);
      }
      
      .lightbox.active { opacity: 1; visibility: visible; }
      
      .lightbox-content { 
        position: relative; 
        display: flex; 
        justify-content: center; 
        align-items: center; 
        max-width: 95%; 
        max-height: 95%; 
      }
      
      .lightbox-content.landscape { max-width: 85vw; max-height: 90vh; }
      .lightbox-content.portrait { max-width: 65vw; max-height: 90vh; }
      
      .lightbox-image { 
        display: block; 
        max-width: 100%; 
        max-height: 100%; 
        width: auto; 
        height: auto; 
        object-fit: contain; 
        border-radius: 8px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.3);
      }
      
      .lightbox-prev, .lightbox-next { 
        position: absolute; 
        top: 50%; 
        transform: translateY(-50%); 
        font-size: 36px; 
        color: #fff; 
        cursor: pointer; 
        z-index: 10000; 
        padding: 16px 20px; 
        user-select: none; 
        transition: all 0.2s ease;
        background: rgba(0,0,0,0.3);
        border-radius: 50%;
        width: 60px;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
      }
      
      .lightbox-prev:hover, .lightbox-next:hover { 
        background: rgba(0,0,0,0.6); 
        transform: translateY(-50%) scale(1.1);
      }
      
      .lightbox-prev { left: 20px; } 
      .lightbox-next { right: 20px; }
      
      .lightbox-close { 
        position: absolute; 
        top: 20px; 
        right: 20px; 
        color: #fff; 
        font-size: 24px; 
        cursor: pointer;
        background: rgba(0,0,0,0.3);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
      }
      
      .lightbox-close:hover {
        background: rgba(0,0,0,0.6);
        transform: scale(1.1);
      }
      
      .lightbox-loading { 
        color: white; 
        font-size: 16px;
        background: rgba(0,0,0,0.8);
        padding: 16px 24px;
        border-radius: 8px;
        backdrop-filter: blur(4px);
      }

      /* 设置面板 - 原生现代风格 */
      #preview-settings-panel { 
        width: 680px; 
        max-height: 80vh; 
        overflow-y: auto;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        background: white;
        box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
        transition: width 0.3s ease;
      }
      
      /* 搜索过滤选项卡激活时增加宽度 */
      #preview-settings-panel.search-active {
        width: 900px;
      }
      
      #preview-settings-panel h3 {
        margin: 0;
        padding: 20px 24px 16px;
        font-size: 18px;
        font-weight: 600;
        color: #111827;
        border-bottom: 1px solid #f3f4f6;
        background: #fafbfc;
        border-radius: 12px 12px 0 0;
      }
      
      .settings-tabs { 
        display: flex; 
        margin: 0;
        border-bottom: 1px solid #e5e7eb;
        background: #f9fafb;
      }
      
      .tab-button { 
        flex: 1;
        padding: 14px 20px; 
        border: none; 
        background: transparent; 
        color: #6b7280; 
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        transition: all 0.2s ease; 
        border-bottom: 2px solid transparent;
        position: relative;
      }
      
      .tab-button:hover { 
        color: #3b82f6;
        background: rgba(59, 130, 246, 0.05);
      }
      
      .tab-button.active { 
        color: #3b82f6; 
        border-bottom-color: #3b82f6;
        background: white;
      }
      
      .tab-content { 
        display: none; 
        padding: 24px;
      }
      
      .tab-content.active { 
        display: block; 
      }
      
      /* 搜索过滤选项卡使用flex布局 */
      #tab-search.tab-content {
        display: none;
        flex-direction: column;
        padding: 24px;
        height: calc(100% - 48px);
      }
      
      #tab-search.tab-content.active {
        display: flex;
      }
      
      /* 设置选项组 */
      .settings-group {
        margin-bottom: 28px;
      }
      
      .settings-group:last-child {
        margin-bottom: 0;
      }
      
      .settings-group-title {
        font-size: 15px;
        font-weight: 600;
        color: #374151;
        margin-bottom: 12px;
        display: flex;
        align-items: center;
      }
      
      .settings-options {
        display: flex;
        flex-direction: column;
        gap: 10px;
      }
      
      .option-item {
        display: flex;
        align-items: center;
        padding: 12px 16px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        background: #fafbfc;
      }
      
      .option-item:hover {
        border-color: #3b82f6;
        background: #f0f9ff;
      }
      
      .option-item input[type="radio"] {
        margin: 0 12px 0 0;
        width: 16px;
        height: 16px;
        accent-color: #3b82f6;
      }
      
      .option-item.selected {
        border-color: #3b82f6;
        background: #eff6ff;
        box-shadow: 0 0 0 1px #3b82f6;
      }
      
      .option-text {
        font-size: 14px;
        color: #374151;
        font-weight: 500;
      }
      
      /* 搜索过滤样式 */
      .filter-actions {
        display: flex;
        gap: 6px; /* 减小间距 */
        flex-wrap: wrap;
        align-items: center;
      }
      
      .filter-description {
        color: #6b7280;
        font-size: 12px;
        line-height: 1.3;
        text-align: center;
        flex: 1;
        padding: 0 8px; /* 减小内边距 */
        min-width: 80px; /* 最小宽度 */
      }
      
      .action-btn {
        padding: 4px 8px; /* 减小按钮内边距 */
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        color: #475569;
        cursor: pointer;
        font-size: 11px; /* 减小字体 */
        font-weight: 500;
        transition: all 0.2s ease;
        white-space: nowrap; /* 防止文字换行 */
        flex-shrink: 0; /* 防止按钮被压缩 */
      }
      
      .action-btn:hover {
        background: #e2e8f0;
        border-color: #94a3b8;
      }
      
      .action-btn:active {
        transform: translateY(1px);
      }
      
      /* 板块列表 - 多列网格布局 */
      .forum-list {
        max-height: 400px;
        overflow-y: auto;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: white;
        min-height: 400px;
        padding: 12px; /* 恢复合适的内边距 */
        display: grid;
        grid-template-columns: repeat(auto-fill, max-content);
        gap: 5px 8px; /* 适当增加网格间距,给主板块更多空间 */
        align-content: start;
        flex: 1;
        justify-content: start;
      }
      
      /* 搜索过滤激活时的网格优化 */
      #preview-settings-panel.search-active .forum-list {
        grid-template-columns: repeat(auto-fill, max-content);
        gap: 4px 6px; /* 保持适当间距 */
      }
      
      .forum-item {
        display: flex;
        align-items: center;
        padding: 6px 8px; /* 减小内边距 */
        border: 1px solid #f1f5f9;
        border-radius: 6px;
        transition: all 0.2s ease;
        background: #fafbfc;
        min-height: 30px; /* 减小最小高度 */
        width: max-content;
        max-width: 140px; /* 限制子板块按钮最大宽度 */
        justify-content: flex-start;
      }
      
      .forum-item:hover {
        background: #f0f9ff;
        border-color: #bae6fd;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
      }
      
      .forum-checkbox {
        margin-right: 8px;
        width: 16px;
        height: 16px;
        accent-color: #3b82f6;
        flex-shrink: 0;
      }
      
      .forum-name {
        cursor: pointer;
        font-size: 11px; /* 减小字体 */
        color: #374151;
        user-select: none;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px; /* 限制文本宽度 */
      }
      
      /* 主板块样式 - 扁而宽的设计 */
      .forum-item:has(.forum-name.level-2) {
        background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
        border-color: #bfdbfe;
        font-weight: 600;
        grid-column: 1 / -1; /* 主板块占满一整行 */
        min-height: 26px; /* 扁平设计,降低高度 */
        padding: 4px 20px; /* 减小垂直内边距,增加水平内边距 */
        border-radius: 4px; /* 减小圆角,更扁平 */
        justify-content: flex-start;
        overflow: hidden; /* 防止内容溢出 */
        min-width: 180px; /* 设置最小宽度,确保足够宽 */
        max-width: 250px; /* 增加最大宽度,更宽 */
        margin-bottom: 2px; /* 增加与下方子板块的间距 */
      }
      
      .forum-name.level-2 {
        font-weight: 600;
        color: #1e40af;
        font-size: 13px;
        max-width: 200px; /* 增加文本宽度,配合扁宽设计 */
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1; /* 让文本占据可用空间 */
      }
      
      /* 子板块样式 - 紧凑显示 */
      .forum-name.level-3 {
        color: #4b5563;
        padding-left: 12px;
        position: relative;
        font-size: 12px;
      }
      
      .forum-name.level-3:before {
        content: '•';
        position: absolute;
        left: 0;
        color: #3b82f6;
        font-weight: bold;
      }
      
      .forum-name.level-4 {
        color: #6b7280;
        padding-left: 16px;
        font-size: 11px;
        position: relative;
      }
      
      .forum-name.level-4:before {
        content: '◦';
        position: absolute;
        left: 4px;
        color: #94a3b8;
      }
      
      /* 子板块项目样式优化 */
      .forum-item:has(.forum-name.level-3) {
        border-color: #e2e8f0;
        background: #ffffff;
      }
      
      .forum-item:has(.forum-name.level-4) {
        border-color: #f1f5f9;
        background: #fefefe;
      }
      
      /* 按钮组 */
      .panel-buttons {
        margin-top: 24px;
        padding: 20px 24px;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
        border-radius: 0 0 12px 12px;
        display: flex;
        flex-wrap: wrap; /* 允许换行 */
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        min-height: 60px; /* 确保有足够高度容纳换行 */
      }
      
      .filter-controls {
        display: none;
        align-items: center;
        gap: 8px; /* 减小间距 */
        flex: 1;
        min-width: 200px; /* 最小宽度,避免过度压缩 */
      }
      
      /* 搜索过滤时显示筛选控件 */
      #preview-settings-panel.search-active .filter-controls {
        display: flex;
      }
      
      .main-buttons {
        display: flex;
        gap: 8px; /* 减小按钮间距 */
        flex-shrink: 0;
        flex-wrap: wrap; /* 允许按钮换行 */
      }
      
      .btn {
        padding: 10px 20px;
        border-radius: 6px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        border: 1px solid;
        min-width: 80px;
      }
      
      .btn-primary {
        background: #3b82f6;
        border-color: #3b82f6;
        color: white;
      }
      
      .btn-primary:hover {
        background: #2563eb;
        border-color: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
      }
      
      .btn-secondary {
        background: #f3f4f6;
        border-color: #d1d5db;
        color: #374151;
      }
      
      .btn-secondary:hover {
        background: #e5e7eb;
        border-color: #9ca3af;
      }
      
      /* 滚动条美化 */
      .forum-list::-webkit-scrollbar,
      #preview-settings-panel::-webkit-scrollbar {
        width: 6px;
      }
      
      .forum-list::-webkit-scrollbar-track,
      #preview-settings-panel::-webkit-scrollbar-track {
        background: #f3f4f6;
        border-radius: 3px;
      }
      
      .forum-list::-webkit-scrollbar-thumb,
      #preview-settings-panel::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 3px;
      }
      
      .forum-list::-webkit-scrollbar-thumb:hover,
      #preview-settings-panel::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
      }
      
      /* 响应式网格调整 */
      @media (min-width: 600px) {
        .forum-list {
          grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
          gap: 4px 8px;
        }
      }
      
      @media (min-width: 680px) {
        .forum-list {
          grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
        }
        
        .forum-item {
          padding: 6px 8px;
          min-height: 28px;
        }
        
        .forum-name {
          font-size: 11px;
        }
        
        .forum-name.level-2 {
          font-size: 12px;
        }
      }
      
      /* 设置面板提示消息 */
      .settings-message {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding: 16px 24px;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        color: white;
        z-index: 10002;
        opacity: 0;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(8px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.15);
        text-align: center;
        min-width: 200px;
        max-width: 400px;
      }
      
      .settings-message.show {
        opacity: 1;
      }
      
      .settings-message-success {
        background: linear-gradient(135deg, #10b981 0%, #059669 100%);
        border: 1px solid #047857;
      }
      
      .settings-message-error {
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
        border: 1px solid #b91c1c;
      }
      
      .settings-message-info {
        background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
        border: 1px solid #1d4ed8;
      }
      
      /* 快速提示消息 */
      .quick-message {
        position: fixed;
        top: 20px;
        right: 20px;
        padding: 12px 16px;
        background: rgba(16, 185, 129, 0.95);
        color: white;
        border-radius: 6px;
        font-size: 13px;
        font-weight: 500;
        z-index: 10003;
        opacity: 0;
        transform: translateX(100%);
        transition: all 0.3s ease;
        backdrop-filter: blur(8px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border: 1px solid rgba(255,255,255,0.2);
        max-width: 250px;
      }
      
      .quick-message.show {
        opacity: 1;
        transform: translateX(0);
      }
    `,document.head.appendChild(e),this.styleInjected=!0}};k.styleInjected=!1;let x=k;class h{static removeAds(){document.querySelectorAll(o.selectors.threadRows).forEach(t=>{const n=t.querySelector("td.tal");n&&n.innerHTML.includes("headtopic_3.gif")&&t.remove()}),this.removeAdButtons()}static removeGlobalAds(){this.removeAdButtons()}static removeAdButtons(){["td_ID144","td_ID86","td_ID139"].forEach(t=>{const n=document.getElementById(t);if(n){const i=n.closest("li");i?i.remove():n.remove()}})}}class w{static extractImages(e){const t=o.get("MAX_PREVIEW_IMAGES");let n=[];for(const r of o.selectors.imgSelectors)if(n=Array.from(e.querySelectorAll(r)),n.length>0)break;let a=n.filter(r=>{const c=r.getAttribute("style")||"";return!(c.includes("display: none")||c.includes("display:none"))}).map(r=>({src:r.getAttribute("data-original")||r.getAttribute("src")||"",img:r})).filter(r=>{if(!r.src||!r.src.startsWith("http")||r.src.includes("loading.")||r.src.includes("placeholder."))return!1;const b=r.src.toLowerCase().split("/").pop()||"";return!(o.filters.badImagePatterns.some(v=>v.test(b))||r.img.width&&r.img.height&&(r.img.width<o.filters.minImageSize.width||r.img.height<o.filters.minImageSize.height))});return a.sort((r,c)=>{const b=/\.(jpg|jpeg|png)$/i.test(r.src),v=/\.(jpg|jpeg|png)$/i.test(c.src);return b&&!v?-1:!b&&v?1:0}),a.map(r=>r.src).slice(0,t)}static extractFileSize(e){let t="";for(const n of o.selectors.contentSelectors){const i=e.querySelector(n);if(i){let s=i.innerHTML.match(o.regex.fileSize);if(s&&(s[1]||s[2])){t=(s[1]||s[2]).trim();break}}}return t}static extractMagnet(e){let t="",n=e.querySelector(o.selectors.magnetTextarea);if(n)t=n.value.trim();else{let i=e.querySelector(o.selectors.magnetLink);if(i)t=i.getAttribute("href")||"";else{const s=e.body.innerHTML.match(o.regex.magnetHash);s&&s[1]&&(t=`magnet:?xt=urn:btih:${s[1]}`)}}return t}}class I{static buildPreviewUI(e,t){const{imgSrcs:n,fileSize:i,magnet:a}=t;if(e.nextElementSibling&&e.nextElementSibling.classList.contains("imagePreviewTr"))return;e.classList.add("thread-title-highlighted");const s=document.createElement("tr");s.className="imagePreviewTr";const r=document.createElement("td");r.colSpan=e.children.length;const c=document.createElement("div");c.className="preview-container",c.style.borderTop="none",n.length&&c.appendChild(this.createImageSection(n)),(i||a)&&c.appendChild(this.createInfoSection(i,a)),r.appendChild(c),s.appendChild(r),e.parentNode.insertBefore(s,e.nextSibling)}static createImageSection(e){const t=document.createElement("div");t.className="preview-section";const n=document.createElement("div");n.className="preview-section-title",n.textContent="预览图片",t.appendChild(n);const i=document.createElement("div");return i.className="preview-images",e.forEach((a,s)=>{if(a&&a.startsWith("http")){const r=document.createElement("img");r.src=a,r.className="preview-image",r.onerror=()=>{r.style.display="none"},r.addEventListener("click",()=>f.showLightbox(e,s)),i.appendChild(r)}}),t.appendChild(i),t}static createInfoSection(e,t){const n=document.createElement("div");n.className="preview-section";const i=document.createElement("div");if(i.className="preview-section-title",i.textContent="资源信息",n.appendChild(i),e){const a=document.createElement("div");a.className="preview-filesize";const s=e.includes("MB")||e.includes("mb")?"【影片大小】":"【影片容量】";a.innerHTML=`${s}:${e}`,a.style.marginBottom="10px",n.appendChild(a)}if(t){const a=document.createElement("div");a.className="preview-magnet",a.textContent=t,a.title="点击链接可复制",a.onclick=function(s){m.copyToClipboard(t,s)},n.appendChild(a)}return n}}class T{static async processThreadLink(e){const t=e.href;if(!t||!o.regex.threadUrl.test(t))return;const n=e.closest("tr");if(!(!n||n.querySelector('img[src*="headtopic"]')))try{const a=await(await fetch(t)).text(),r=new DOMParser().parseFromString(a,"text/html"),c={imgSrcs:w.extractImages(r),fileSize:w.extractFileSize(r),magnet:w.extractMagnet(r)};if(!c.imgSrcs.length&&!c.fileSize&&!c.magnet)return;I.buildPreviewUI(n,c)}catch(i){console.error(`[${o.name}] 预览加载失败:`,i)}}}class S{static async displayThreadImages(){const e=o.get("CONCURRENT_LIMIT");if(m.isContentPage())return;x.injectStyles(),m.removeRules(),f.init();const t=m.safeQuerySelectorAll(o.selectors.threadLinks);t.length&&await m.asyncPool(e,t,T.processThreadLink)}static isSearchPage(){return o.regex.searchUrl.test(window.location.href)&&document.querySelector(o.selectors.searchResultTable)!==null}static async main(){try{y.init(),m.isContentPage()?console.log(`[${o.name}] 当前为内容页面`):this.isSearchPage()?(console.log(`[${o.name}] 当前为搜索结果页面`),x.injectStyles(),g.init(),await this.displayThreadImages()):(console.log(`[${o.name}] 当前为列表页面`),h.removeAds(),await this.displayThreadImages())}catch(e){console.error(`[${o.name}] 初始化失败:`,e)}}}h.removeGlobalAds(),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{h.removeGlobalAds(),S.main()}):(h.removeGlobalAds(),S.main()),window.addEventListener("load",()=>{h.removeGlobalAds()})})();