2048-预览

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

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         2048-预览
// @version      1.2.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 CONFIG={defaults:{MAX_PREVIEW_IMAGES:3,CONCURRENT_LIMIT:9,PREVIEW_IMAGE_HEIGHT:300,
EXCLUDED_FORUMS:["56","102"]},get(e){try{return GM_getValue(e,this.defaults[e])}catch(t){
console.warn("[2048-预览] 获取配置失败:",t);return this.defaults[e]}},set(e,t){try{GM_setValue(e,t)}catch(n){
console.warn("[2048-预览] 保存配置失败:",n)}},getAll(){const e={};for(const t in this.defaults)e[t]=this.get(t)
;e["EXCLUDED_FORUMS"]=this.get("EXCLUDED_FORUMS");return e},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}},btSites:[{name:"bxmho",
pattern:/(?:\/\/bt\.bxmho\.cn\/list\.php\?name=|userscript\.html\?name=)([0-9a-z]+)/i,
url:"https://bt.bxmho.cn/list.php",method:"GET",getHash:e=>{const t=e.match(/([0-9a-z]+)$/i);return t?t[1]:""}},{
name:"82bt",pattern:/\/\/www\.82bt\.com\/(?:cao\.php|dlink\.php)\?hash=([0-9a-z]+)/i,
url:"https://www.82bt.com/downt-m.php",method:"POST",paramName:"code",referer:"https://www.82bt.com",getHash:e=>{
const t=e.match(/hash=([0-9a-z]+)/i);return t?t[1]:""}}]};const e={copyToClipboard(e,t){
navigator.clipboard.writeText(e).then(()=>{this.showClickTip("已复制",t)}).catch(()=>{this.fallbackCopyTextToClipboard(e,t)
})},fallbackCopyTextToClipboard(e,t){const n=document.createElement("textarea");n.value=e;n.style.position="fixed"
;n.style.top="-1000px";n.style.left="-1000px";document.body.appendChild(n);n.focus();n.select();try{
document.execCommand("copy");this.showClickTip("已复制",t)}catch(i){console.error("复制失败:",i);this.showClickTip("复制失败",t)}
document.body.removeChild(n)},showClickTip(e,t){const n=t;let i=document.querySelector(".click-tip");if(i)i.remove()
;i=document.createElement("div");i.className="click-tip";i.textContent=e;document.body.appendChild(i)
;i.style.left=`${n.clientX}px`;i.style.top=`${n.clientY}px`;setTimeout(()=>{i.style.opacity="1"},10);setTimeout(()=>{
i.style.opacity="0";setTimeout(()=>{if(i.parentElement)i.remove()},200)},1e3)},removeRules(){try{
const e=document.querySelector(".collapse-header");if(e){
const t=e.closest("div, section, .rule-container, .collapse-container");if(t)t.remove()}}catch(e){
console.error("移除版规时出错:",e)}},isContentPage(){return CONFIG.regex.threadUrl.test(window.location.href)},
async asyncPool(e,t,n){const i=[];const a=[];for(const l of t){const r=Promise.resolve().then(()=>n(l,t));i.push(r)
;if(e<=t.length){const t=r.then(()=>{const e=a.indexOf(t);if(-1!==e)a.splice(e,1)});a.push(t)
;if(a.length>=e)await Promise.race(a)}}return Promise.all(i)},debounce(e,t,n){let i=null;return function(...a){
const later=()=>{i=null;if(!n)e.apply(this,a)};const l=n&&!i;if(i)clearTimeout(i);i=setTimeout(later,t)
;if(l)e.apply(this,a)}},waitForElement(e,t=5e3){return new Promise(n=>{const i=document.querySelector(e);if(i){n(i)
;return}const observer=new MutationObserver(()=>{const t=document.querySelector(e);if(t){observer.disconnect();n(t)}})
;observer.observe(document.body,{childList:true,subtree:true});setTimeout(()=>{observer.disconnect();n(null)},t)})},
safeQuerySelector(e,t=document){try{return t.querySelector(e)}catch(n){return null}},safeQuerySelectorAll(e,t=document){
try{return Array.from(t.querySelectorAll(e))}catch(n){return[]}}};const t=class _ForumData{static getForumById(e){
return this.FORUM_SECTIONS.find(t=>t.id===e)}static getChildForums(e){return this.FORUM_SECTIONS.filter(t=>t.parent===e)
}static getMainCategories(){return this.FORUM_SECTIONS.filter(e=>2===e.level&&"1"===e.parent)}
static getSexInfoForumIds(){return this.FORUM_SECTIONS.filter(e=>e.name.includes("性息")||"218"===e.parent).map(e=>e.id)}
static getDisplayName(e){const t=" ".repeat(Math.max(0,e.level-2));return`${t}${e.name}`}static getForumTree(){
const e=[];const t=this.getMainCategories();t.forEach(t=>{e.push(t);const n=this.getChildForums(t.id);n.forEach(t=>{
e.push(t);const n=this.getChildForums(t.id);n.forEach(t=>{e.push(t);const n=this.getChildForums(t.id);e.push(...n)})})})
;return e}};t.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 n=t
;const i=class _UltraMinimalStyleManager{static injectStyles(){const e=document.getElementById(this.styleElementId)
;if(e)e.remove();const t=document.createElement("style");t.id=this.styleElementId
;const n=CONFIG.get("PREVIEW_IMAGE_HEIGHT")||300
;t.textContent=`.click-tip{position:fixed;background:rgba(0,0,0,0.8);color:#fff;padding:6px 12px;border-radius:4px;font-size:13px;z-index:10000}.thread-title-highlighted{background:#e8f4fd!important;border-radius:4px 4px 0 0}.preview-container{margin:0 0 10px 0;border:1px solid #dee2e6;border-top:none;border-radius:0 0 4px 4px;padding:16px;background:#f8f9fa}.preview-images{display:flex;gap:12px;margin-bottom:16px}.preview-image-wrapper{height:${n}px;flex:0 0 auto;border-radius:4px;cursor:pointer;overflow:hidden}.preview-image{width:100%;height:100%;object-fit:cover}.preview-magnet{font-size:13px;word-break:break-all;cursor:pointer;padding:10px 12px;background:#f0f9ff;border:1px solid #e0f2fe;border-radius:4px;margin-bottom:10px}.lightbox{position:fixed;inset:0;background:rgba(0,0,0,0.9);display:flex;align-items:center;justify-content:center;z-index:9999;opacity:0;visibility:hidden}.lightbox.active{opacity:1;visibility:visible}.lightbox-image{border-radius:8px;display:block;object-fit:contain}.lightbox-prev,.lightbox-next,.lightbox-close{position:absolute;color:#fff;cursor:pointer;background:rgba(0,0,0,0.5);border-radius:50%;display:flex;align-items:center;justify-content:center}.lightbox-prev,.lightbox-next{top:50%;transform:translateY(-50%);font-size:36px;width:60px;height:60px}.lightbox-close{top:20px;right:20px;font-size:24px;width:40px;height:40px}.lightbox-prev{left:20px}.lightbox-next{right:20px}.compact-panel{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:10001;background:#fff;border:1px solid #ddd;border-radius:6px;font-family:system-ui,sans-serif;width:360px;box-shadow:0 4px 12px rgba(0,0,0,0.15)}.compact-panel header{position:relative;padding:12px 16px;border-bottom:1px solid #eee;background:#fafafa;border-radius:6px 6px 0 0;font-size:14px;font-weight:500;color:#333}.close-x{position:absolute;top:12px;right:16px;width:24px;height:24px;border:none;background:none;color:#999;font-size:18px;cursor:pointer;display:flex;align-items:center;justify-content:center;line-height:1}.close-x:hover{color:#666}.settings-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding:16px}.setting-group{display:flex;flex-direction:column;gap:6px}.group-title{font-size:13px;font-weight:500;color:#666;margin-bottom:2px}.radio-item{display:flex;align-items:center;gap:6px;padding:4px 8px;border-radius:4px;cursor:pointer;font-size:13px;color:#333}.radio-item input[type="radio"]{margin:0}.compact-panel footer{padding:12px 16px;border-top:1px solid #eee;text-align:right}.compact-panel button{padding:6px 16px;border:1px solid #ddd;border-radius:4px;background:#fff;color:#333;cursor:pointer;font-size:13px}.compact-panel #save-settings-btn{background:#007bff;border-color:#007bff;color:#fff}.clean-search-panel{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);z-index:10001;background:#fff;border:1px solid #ddd;border-radius:8px;font-family:system-ui,sans-serif;width:750px;max-height:80vh;overflow:hidden;box-shadow:0 4px 16px rgba(0,0,0,0.2)}.clean-search-panel header{position:relative;padding:16px 20px;border-bottom:1px solid #e5e7eb;background:#f8f9fa;border-radius:8px 8px 0 0;font-size:15px;font-weight:600;color:#374151}.clean-forum-tree{padding:20px;max-height:500px;overflow-y:auto}.clean-forum-card{margin-bottom:20px;border:1px solid #e5e7eb;border-radius:8px;overflow:hidden;background:#fff}.clean-forum-card:last-child{margin-bottom:0}.clean-card-header{padding:12px 16px;background:#f1f5f9;border-bottom:1px solid #e5e7eb;display:flex;align-items:center;gap:10px}.main-forum-title{font-weight:600;font-size:14px;color:#1f2937;cursor:pointer}.main-forum-checkbox{margin:0;transform:scale(1.1)}.clean-card-content{padding:16px}.clean-sub-section{margin-bottom:16px;border-left:3px solid #e5e7eb;padding-left:12px}.clean-sub-section:last-child{margin-bottom:0}.clean-sub-header{display:flex;align-items:center;gap:8px;margin-bottom:12px}.sub-forum-title{font-weight:500;font-size:13px;color:#4b5563;cursor:pointer}.sub-forum-checkbox{margin:0}.clean-level4-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:8px;margin-left:20px}.clean-level4-item{display:flex;align-items:center;gap:6px;padding:8px 12px;background:#f9fafb;border:1px solid #f3f4f6;border-radius:6px;cursor:pointer;font-size:12px;color:#6b7280}.clean-level4-item:hover{background:#f3f4f6}.level4-forum-checkbox{margin:0;transform:scale(0.9)}.clean-compact-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;padding:12px}.clean-compact-item{display:flex;align-items:center;gap:6px;padding:10px 12px;background:#fff;border:1px solid #e5e7eb;border-radius:6px;cursor:pointer;font-size:13px;color:#4b5563}.clean-compact-item:hover{background:#f9fafb}.compact-forum-checkbox{margin:0;transform:scale(1.05)}.filter-controls{display:flex;gap:10px}.clean-search-panel footer{padding:16px 20px;background:#f8f9fa;border-top:1px solid #e5e7eb;border-radius:0 0 8px 8px;display:flex;justify-content:space-between;align-items:center}.clean-search-panel button{padding:8px 16px;border:1px solid #d1d5db;border-radius:6px;background:#fff;color:#374151;cursor:pointer;font-size:13px;font-weight:500}.clean-search-panel button.secondary{background:#f9fafb}.clean-search-panel #search-save-settings-btn{background:#3b82f6;border-color:#3b82f6;color:#fff}.quick-message{position:fixed;top:20px;right:20px;padding:10px 14px;background:#28a745;color:#fff;border-radius:4px;font-size:13px;z-index:10003}.quick-message.show{display:block}.flex{display:flex}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:0.5rem}.mb-3{margin-bottom:0.75rem}.p-3{padding:0.75rem}.text-center{text-align:center}.cursor-pointer{cursor:pointer}`
;document.head.appendChild(t);this.styleInjected=true}static setImageGridWidth(e,t){let n;if(1===t)n="50%";else{
const e=12*(t-1);n=`calc((100% - ${e}px) / ${t})`}Array.from(e.children).forEach(e=>{e.style.width=n
;e.style.flex="0 0 auto"})}};i.styleInjected=false;i.styleElementId="ultra-minimal-styles";let a=i
;const l=class _ModernSettingsPanel{static init(){if(this.initialized)return;this.removeSearchButton()
;this.addSettingsButton();this.initialized=true}static removeSearchButton(){try{
const e=document.getElementById("td_ID141");if(e){const t=e.closest("li");if(t){t.remove();return}}
const t=document.querySelectorAll('a[href="/search.php"]');t.forEach(e=>{const t=e.closest("li");if(t)t.remove()})
}catch(e){console.warn("[2048-预览] 移除搜索按钮时出错:",e)}}static addSettingsButton(){const e=document.getElementById("nav-pc")
;if(e){const t=document.createElement("li");const n=document.createElement("a");n.href="javascript:;"
;n.textContent="预览图设置";n.onclick=()=>false;t.appendChild(n);e.appendChild(t);const i=this.createSettingsPanel()
;n.addEventListener("click",e=>{e.preventDefault();i.show()});const a=document.createElement("li")
;const l=document.createElement("a");l.href="javascript:;";l.textContent="搜索过滤";l.onclick=()=>false;a.appendChild(l)
;e.appendChild(a);const r=this.createSearchFilterPanel();l.addEventListener("click",e=>{e.preventDefault();r.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",e=>{e.preventDefault();n.show()})}}static createSettingsPanel(){
const e=`\n      <dialog id="preview-settings-panel" class="compact-panel script-container">\n        <header>\n          <span>预览图设置</span>\n          <button id="close-settings-btn" class="close-x">×</button>\n        </header>\n        <main class="settings-grid">\n          <div class="setting-group">\n            <label class="group-title">预览图数量</label>\n            <label class="radio-item"><input type="radio" name="MAX_PREVIEW_IMAGES" value="3" checked>少量 (3张)</label>\n            <label class="radio-item"><input type="radio" name="MAX_PREVIEW_IMAGES" value="4">适中 (4张)</label>\n            <label class="radio-item"><input type="radio" name="MAX_PREVIEW_IMAGES" value="5">较多 (5张)</label>\n          </div>\n          <div class="setting-group">\n            <label class="group-title">加载速度</label>\n            <label class="radio-item"><input type="radio" name="CONCURRENT_LIMIT" value="6">稳定 (6个并发)</label>\n            <label class="radio-item"><input type="radio" name="CONCURRENT_LIMIT" value="9" checked>平衡 (9个并发)</label>\n            <label class="radio-item"><input type="radio" name="CONCURRENT_LIMIT" value="12">快速 (12个并发)</label>\n          </div>\n          <div class="setting-group">\n            <label class="group-title">预览图高度</label>\n            <label class="radio-item"><input type="radio" name="PREVIEW_IMAGE_HEIGHT" value="200">小 (200px)</label>\n            <label class="radio-item"><input type="radio" name="PREVIEW_IMAGE_HEIGHT" value="300" checked>中 (300px)</label>\n            <label class="radio-item"><input type="radio" name="PREVIEW_IMAGE_HEIGHT" value="400">大 (400px)</label>\n          </div>\n        </main>\n        <footer>\n          <button id="save-settings-btn">保存</button>\n        </footer>\n      </dialog>\n      <div id="preview-settings-overlay" style="display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:10000;"></div>\n    `
;document.body.insertAdjacentHTML("beforeend",e);const t=document.getElementById("preview-settings-panel")
;const n=document.getElementById("preview-settings-overlay");this.loadBasicSettings();setTimeout(()=>{
if(n)this.setupBasicEventListeners(t,n)},50);return{show:()=>{t.style.display="block";n.style.display="block"}}}
static createSearchFilterPanel(){
const e=`\n      <dialog id="search-filter-panel" class="clean-search-panel script-container">\n        <header>\n          <span>搜索过滤设置</span>\n          <button id="search-close-settings-btn" class="close-x">×</button>\n        </header>\n        <main id="search-forum-list" class="clean-forum-tree"></main>\n        <footer>\n          <div class="filter-controls">\n            <button id="search-clear-all-filters" class="secondary">清除全部</button>\n            <button id="search-select-all-forums" class="secondary">全选</button>\n          </div>\n          <button id="search-save-settings-btn">保存设置</button>\n        </footer>\n      </dialog>\n      <div id="search-filter-overlay" style="display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:10000;"></div>\n    `
;document.body.insertAdjacentHTML("beforeend",e);const t=document.getElementById("search-filter-panel")
;const n=document.getElementById("search-filter-overlay");this.generateCleanSearchForumList()
;this.loadSearchFilterSettings();setTimeout(()=>{if(n)this.setupSearchFilterEventListeners(t,n)},50);return{show:()=>{
t.style.display="block";n.style.display="block"}}}static loadBasicSettings(){const config=CONFIG.getAll()
;for(const e in config){if("EXCLUDED_FORUMS"===e)continue
;const t=document.querySelector(`[name="${e}"][value="${config[e]}"]`);if(t)t.checked=true}}
static setupBasicEventListeners(e,t){const n=document.getElementById("save-settings-btn")
;if(n)n.addEventListener("click",e=>{e.preventDefault();e.stopPropagation();this.saveBasicSettings()})
;const closePanel=()=>{e.style.display="none";t.style.display="none"}
;const i=document.getElementById("close-settings-btn");if(i)i.addEventListener("click",closePanel)
;t.addEventListener("click",closePanel)}static saveBasicSettings(){try{
const e=document.querySelectorAll('#preview-settings-panel input[type="radio"]:checked');e.forEach(e=>{const t=e
;const n=isNaN(Number(t.value))?t.value:Number(t.value);CONFIG.set(t.name,n)});a.injectStyles()
;this.showMessage("保存成功!","success");setTimeout(()=>{const e=document.getElementById("preview-settings-panel")
;const t=document.getElementById("preview-settings-overlay");if(e)e.style.display="none";if(t)t.style.display="none"
},1e3)}catch(e){console.error("保存设置失败:",e);this.showMessage("保存失败!","error")}}static generateCleanSearchForumList(){
const e=document.getElementById("search-forum-list");if(!e)return;const t=n.getForumTree()
;const i=t.filter(e=>2===e.level);i.forEach(n=>{const i=document.createElement("div");i.className="clean-forum-card"
;const a=document.createElement("div");a.className="clean-card-header";const l=document.createElement("input")
;l.type="checkbox";l.id=`search-forum-${n.id}`;l.value=n.id;l.className="main-forum-checkbox"
;const r=document.createElement("span");r.className="main-forum-title";r.textContent=n.name;a.appendChild(l)
;a.appendChild(r);i.appendChild(a);const s=document.createElement("div");s.className="clean-card-content"
;this.addCleanSubForums(t,n.id,s,n.id);i.appendChild(s);e.appendChild(i);l.addEventListener("change",()=>{
this.handleSearchFilterParentToggle(n.id,l.checked)})})}static addCleanSubForums(e,t,n,i){
const a=e.filter(e=>e.parent===t&&3===e.level);if(0===a.length)return
;const l=a.some(t=>e.some(e=>4===e.level&&e.parent===t.id));if(l)a.forEach(t=>{const a=document.createElement("div")
;a.className="clean-sub-section";const l=document.createElement("div");l.className="clean-sub-header"
;const r=document.createElement("input");r.type="checkbox";r.id=`search-forum-${t.id}`;r.value=t.id
;r.className="sub-forum-checkbox";r.dataset.parent=i;const s=document.createElement("span")
;s.className="sub-forum-title";s.textContent=t.name;l.appendChild(r);l.appendChild(s);a.appendChild(l)
;const o=e.filter(e=>4===e.level&&e.parent===t.id);if(o.length>0){const e=document.createElement("div")
;e.className="clean-level4-grid";o.forEach(t=>{const n=document.createElement("label");n.className="clean-level4-item"
;const a=document.createElement("input");a.type="checkbox";a.id=`search-forum-${t.id}`;a.value=t.id
;a.className="level4-forum-checkbox";a.dataset.parent=i;const l=document.createElement("span");l.textContent=t.name
;n.appendChild(a);n.appendChild(l);e.appendChild(n)});a.appendChild(e)}n.appendChild(a)});else{
const e=document.createElement("div");e.className="clean-compact-grid";a.forEach(t=>{
const n=document.createElement("label");n.className="clean-compact-item";const a=document.createElement("input")
;a.type="checkbox";a.id=`search-forum-${t.id}`;a.value=t.id;a.className="compact-forum-checkbox";a.dataset.parent=i
;const l=document.createElement("span");l.textContent=t.name;n.appendChild(a);n.appendChild(l);e.appendChild(n)})
;n.appendChild(e)}}static loadSearchFilterSettings(){const e=CONFIG.get("EXCLUDED_FORUMS")||[];e.forEach(e=>{
const t=document.getElementById(`search-forum-${e}`);if(t)t.checked=true})}static setupSearchFilterEventListeners(e,t){
const n=document.getElementById("search-save-settings-btn")
;if(n)n.addEventListener("click",()=>this.saveSearchFilterSettings());const closePanel=()=>{e.style.display="none"
;t.style.display="none"};const i=document.getElementById("search-close-settings-btn")
;if(i)i.addEventListener("click",closePanel);t.addEventListener("click",closePanel)
;const a=document.getElementById("search-clear-all-filters");const l=document.getElementById("search-select-all-forums")
;if(a)a.addEventListener("click",()=>this.clearAllSearchFilters())
;if(l)l.addEventListener("click",()=>this.selectAllSearchForums())}static saveSearchFilterSettings(){
const e=document.querySelectorAll('.clean-search-panel input[type="checkbox"]:checked')
;const t=Array.from(e).map(e=>e.value);CONFIG.set("EXCLUDED_FORUMS",t);this.showMessage("过滤设置已保存!","success")
;setTimeout(()=>{const e=document.getElementById("search-filter-panel")
;const t=document.getElementById("search-filter-overlay");if(e)e.style.display="none";if(t)t.style.display="none"},1e3)}
static handleSearchFilterParentToggle(e,t){const n=document.querySelectorAll(`[data-parent="${e}"]`);n.forEach(e=>{
e.checked=t})}static clearAllSearchFilters(){
const e=document.querySelectorAll('.clean-search-panel input[type="checkbox"]');e.forEach(e=>e.checked=false)}
static selectAllSearchForums(){const e=document.querySelectorAll('.clean-search-panel input[type="checkbox"]')
;e.forEach(e=>e.checked=true)}static showMessage(e,t){const n=document.querySelector(".quick-message");if(n)n.remove()
;const i=document.createElement("div");i.className="quick-message";i.textContent=e
;i.style.background="success"===t?"#10b981":"#ef4444";document.body.appendChild(i)
;setTimeout(()=>i.classList.add("show"),10);setTimeout(()=>{i.classList.remove("show");setTimeout(()=>i.remove(),300)
},2e3)}};l.initialized=false;let r=l;const s=class _LightboxManager{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(){
if(!this.closeBtn||!this.prevBtn||!this.nextBtn||!this.lightbox)return
;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=>{if(e.target===this.lightbox)this.closeLightbox()})
;document.addEventListener("keydown",e=>{if(!this.lightbox?.classList.contains("active"))return
;if("Escape"===e.key)this.closeLightbox();else if("ArrowLeft"===e.key)this.prevBtn?.click();else if("ArrowRight"===e.key)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.lightboxImg.style.maxWidth="";this.lightboxImg.style.maxHeight=""
;this.lightboxContent.classList.remove("landscape","portrait");this.lightboxImg.src=e;this.lightboxImg.onload=()=>{
if(!this.lightboxImg||!this.loadingText||!this.lightboxContent)return;this.loadingText.style.display="none"
;this.lightboxImg.style.display="block";const e=.9*window.innerWidth;const t=.9*window.innerHeight
;const n=this.lightboxImg.naturalWidth;const i=this.lightboxImg.naturalHeight;if(n<300&&i<300){const a=2*n;const l=2*i
;if(a<=e&&l<=t){this.lightboxImg.style.width=a+"px";this.lightboxImg.style.height=l+"px"
}else this.scaleImageToFit(a,l,e,t)}else if(n>e||i>t)this.scaleImageToFit(n,i,e,t);else{
this.lightboxImg.style.width=n+"px";this.lightboxImg.style.height=i+"px"}};this.lightboxImg.onerror=()=>{
if(this.loadingText)this.loadingText.textContent="图片加载失败"}}static scaleImageToFit(e,t,n,i){if(!this.lightboxImg)return
;const a=n/e;const l=i/t;const r=Math.min(a,l);const s=e*r;const o=t*r;this.lightboxImg.style.width=s+"px"
;this.lightboxImg.style.height=o+"px"}static showLightbox(e,t){if(!this.lightbox)return;this.currentImages=e
;this.currentIndex=t;this.updateLightboxImage();this.lightbox.classList.add("active")}static closeLightbox(){
if(this.lightbox)this.lightbox.classList.remove("active")}};s.lightbox=null;s.lightboxImg=null;s.lightboxContent=null
;s.loadingText=null;s.currentImages=[];s.currentIndex=0;s.closeBtn=null;s.prevBtn=null;s.nextBtn=null;let o=s
;class AdRemover{static removeAds(){const e=document.querySelectorAll(CONFIG.selectors.threadRows);e.forEach(e=>{
const t=e.querySelector("td.tal");if(t&&t.innerHTML.includes("headtopic_3.gif"))e.remove()});this.removeAdButtons()}
static removeGlobalAds(){this.removeAdButtons()}static removeAdButtons(){const e=["td_ID144","td_ID86","td_ID139"]
;e.forEach(e=>{const t=document.getElementById(e);if(t){const e=t.closest("li");if(e)e.remove();else t.remove()}})}}
class DataExtractor{static extractImages(e){const t=CONFIG.get("MAX_PREVIEW_IMAGES");let n=[]
;for(const r of CONFIG.selectors.imgSelectors){n=Array.from(e.querySelectorAll(r));if(n.length>0)break}
const i=n.filter(e=>{const t=e.getAttribute("style")||""
;if(t.includes("display: none")||t.includes("display:none"))return false;return true});let a=i.map(e=>({
src:e.getAttribute("data-original")||e.getAttribute("src")||"",img:e})).filter(e=>{
if(!e.src||!e.src.startsWith("http"))return false
;if(e.src.includes("loading.")||e.src.includes("placeholder."))return false;const t=e.src.toLowerCase()
;const n=t.split("/").pop()||"";if(CONFIG.filters.badImagePatterns.some(e=>e.test(n)))return false
;if(e.img.width&&e.img.height)if(e.img.width<CONFIG.filters.minImageSize.width||e.img.height<CONFIG.filters.minImageSize.height)return false
;return true});a.sort((e,t)=>{const n=/\.(jpg|jpeg|png)$/i.test(e.src);const i=/\.(jpg|jpeg|png)$/i.test(t.src)
;if(n&&!i)return-1;if(!n&&i)return 1;return 0});const l=a.map(e=>e.src).slice(0,t);return l}static extractFileSize(e){
let t="";for(const n of CONFIG.selectors.contentSelectors){const i=e.querySelector(n);if(i){const e=i.innerHTML
;let n=e.match(CONFIG.regex.fileSize);if(n&&(n[1]||n[2])){t=(n[1]||n[2]).trim();break}}}return t}
static extractMagnet(e){let t="";let n=e.querySelector(CONFIG.selectors.magnetTextarea);if(n)t=n.value.trim();else{
let n=e.querySelector(CONFIG.selectors.magnetLink);if(n)t=n.getAttribute("href")||"";else{const n=e.body.innerHTML
;const i=n.match(CONFIG.regex.magnetHash);if(i&&i[1])t=`magnet:?xt=urn:btih:${i[1]}`}}return t}}
class ExternalMagnetExtractor{static async extractFromPage(e){try{for(const t of CONFIG.btSites){
const n=e.match(t.pattern);if(n){const e=t.getHash(n[0]);const i=await this.fetchFromBtSite(t,e);if(i){
const e=this.cleanMagnetLink(i);return e}}}return null}catch(t){console.error("[2048-预览] 外链磁力获取失败:",t);return null}}
static cleanMagnetLink(e){const t=e.match(/magnet:\?xt=urn:btih:([a-f0-9]{40})/i)
;if(t)return`magnet:?xt=urn:btih:${t[1]}`;return e}static async fetchFromBtSite(e,t){try{return new Promise(n=>{
const i={method:e.method,url:"GET"===e.method?`${e.url}?name=${t}`:e.url,headers:{
Accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8",DNT:"1",Connection:"keep-alive","Upgrade-Insecure-Requests":"1"},onload:t=>{
if(t.status>=200&&t.status<300)try{const e=(new DOMParser).parseFromString(t.responseText,"text/html")
;const i=e.querySelector("#magnetInput");if(i){const e=i.value||i.getAttribute("value");if(e){
const t=e.replace(/&amp;/g,"&");n(t);return}}const a=e.querySelector(".magnet-box input");if(a){
const e=a.getAttribute("value")||a.value;if(e){const t=e.replace(/&amp;/g,"&");n(t);return}}
const l=t.responseText.match(/magnet:\?xt=urn:btih:[a-f0-9]{40}[^"'\s]*/i);if(l){const e=l[0].replace(/&amp;/g,"&");n(e)
;return}n(null)}catch(i){console.error(`[2048-预览] ${e.name}HTML解析失败:`,i);n(null)}else n(null)},onerror:()=>n(null),
ontimeout:()=>n(null)};if("POST"===e.method){i.headers["Content-Type"]="application/x-www-form-urlencoded"
;i.headers["Referer"]=e.referer;i.headers["Origin"]=e.referer;const n={};n[e.paramName]=t
;i.data=new URLSearchParams(n).toString()}GM_xmlhttpRequest(i)})}catch(n){
console.error(`[2048-预览] 获取${e.name}站点链接失败:`,n);return null}}}class UIComponents{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");if(i){const t=e.querySelector("td:nth-child(2)");if(t){
const e=document.createElement("span")
;e.style.cssText="margin-left: 8px; color: #ff6b35; font-weight: 600; font-size: 13px;";e.textContent=`[${i}]`
;t.appendChild(e)}}const l=document.createElement("tr");l.className="imagePreviewTr"
;const r=document.createElement("td");r.colSpan=e.children.length;const s=document.createElement("div")
;s.className="preview-container";s.style.borderTop="none";if(n.length)s.appendChild(this.createImageSection(n))
;if(a)s.appendChild(this.createInfoSection(a));r.appendChild(s);l.appendChild(r)
;e.parentNode.insertBefore(l,e.nextSibling)}static createImageSection(e){const t=document.createElement("div")
;t.className="preview-images";e.forEach((n,i)=>{if(n&&n.startsWith("http")){const a=document.createElement("div")
;a.className="preview-image-wrapper";const l=document.createElement("img");l.src=n;l.className="preview-image"
;l.onerror=()=>{a.style.display="none"};l.onload=()=>{if(l.naturalHeight>l.naturalWidth){
const e=l.naturalHeight/l.naturalWidth
;if(e>1.9&&l.naturalHeight>1800)l.style.objectPosition="top";else l.style.objectFit="contain"}}
;a.addEventListener("click",()=>o.showLightbox(e,i));a.appendChild(l);t.appendChild(a)}})
;if(t.children.length>0)a.setImageGridWidth(t,t.children.length);return t}static createInfoSection(t){
const n=document.createElement("div");n.className="preview-magnet";n.textContent=t;n.title="点击链接可复制"
;n.onclick=function(n){e.copyToClipboard(t,n)};return n}}const c=class _SearchFilter{static init(){
if(this.initialized)return;if(!this.isSearchResultPage())return;this.filterSearchResults();this.updateResultStats()
;this.initialized=true}static isSearchResultPage(){if(!window.location.href.includes("search.php"))return false
;const e=document.querySelector(".t table");const 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 e=t.split("_");if(e.length>=2)return e[1]}return null}static getExcludedForums(){
return CONFIG.get("EXCLUDED_FORUMS")||[]}static filterSearchResults(){const e=this.getExcludedForums()
;if(0===e.length)return;const t=document.querySelectorAll('tr[id^="search_"]');this.totalCount=t.length;let n=0
;t.forEach(t=>{const i=this.extractForumId(t);if(i&&e.includes(i)){t.style.display="none";const e=t.nextElementSibling
;if(e&&e.classList.contains("imagePreviewTr"))e.style.display="none";n++}});this.filteredCount=n
;if(n>0)console.log(`[2048-预览] 搜索过滤: 已隐藏 ${n}/${this.totalCount} 条结果`)}static updateResultStats(){
if(0===this.filteredCount)return;const e=document.querySelector(".t table .h");if(e){const t=e.textContent||"主题列表"
;const n=this.totalCount-this.filteredCount
;e.textContent=`${t} (显示 ${n}/${this.totalCount} 条结果,已过滤 ${this.filteredCount} 条)`
;e.setAttribute("title",`已根据设置隐藏${this.filteredCount}条不相关结果`)}}static reapplyFilter(){
if(!this.isSearchResultPage())return;const e=document.querySelectorAll('tr[id^="search_"], tr.imagePreviewTr')
;e.forEach(e=>{e.style.display=""});this.filteredCount=0;this.filterSearchResults();this.updateResultStats()}
static getFilterStats(){return{total:this.totalCount,filtered:this.filteredCount,
visible:this.totalCount-this.filteredCount}}static clearAllFilters(){CONFIG.set("EXCLUDED_FORUMS",[])
;this.reapplyFilter()}static applyPresetExcludeSexInfo(){const e=n.getSexInfoForumIds();const t=this.getExcludedForums()
;const i=[...new Set([...t,...e])];CONFIG.set("EXCLUDED_FORUMS",i);this.reapplyFilter()}static addExcludedForum(e){
const t=this.getExcludedForums();if(!t.includes(e)){t.push(e);CONFIG.set("EXCLUDED_FORUMS",t);this.reapplyFilter()}}
static removeExcludedForum(e){const t=this.getExcludedForums();const n=t.filter(t=>t!==e)
;CONFIG.set("EXCLUDED_FORUMS",n);this.reapplyFilter()}static toggleForumExclusion(e){const t=this.getExcludedForums()
;if(t.includes(e))this.removeExcludedForum(e);else this.addExcludedForum(e)}static shouldFilterRow(e){
const t=this.extractForumId(e);const n=this.getExcludedForums();return t?n.includes(t):false}};c.initialized=false
;c.filteredCount=0;c.totalCount=0;let d=c;class PreviewProcessor{static async processThreadLink(e){const t=e.href
;if(!t||!CONFIG.regex.threadUrl.test(t))return;const n=e.closest("tr")
;if(!n||n.querySelector('img[src*="headtopic"]'))return;if(d.shouldFilterRow(n))return;try{const e=await fetch(t)
;const i=await e.text();const a=new DOMParser;const l=a.parseFromString(i,"text/html")
;let r=DataExtractor.extractMagnet(l);if(!r){const e=await ExternalMagnetExtractor.extractFromPage(i);r=e||""}const s={
imgSrcs:DataExtractor.extractImages(l),fileSize:DataExtractor.extractFileSize(l),magnet:r||""}
;if(!s.imgSrcs.length&&!s.fileSize&&!s.magnet)return;UIComponents.buildPreviewUI(n,s)}catch(i){
console.error("[2048-预览] 预览加载失败:",i)}}}class App2048{static async displayThreadImages(){
const t=CONFIG.get("CONCURRENT_LIMIT");if(e.isContentPage())return;e.removeRules();o.init()
;const n=e.safeQuerySelectorAll(CONFIG.selectors.threadLinks)
;if(n.length)await e.asyncPool(t,n,PreviewProcessor.processThreadLink)}static isSearchPage(){
return CONFIG.regex.searchUrl.test(window.location.href)&&null!==document.querySelector(CONFIG.selectors.searchResultTable)
}static async main(){try{r.init();a.injectStyles();if(e.isContentPage())return;if(this.isSearchPage()){d.init()
;await this.displayThreadImages()}else{AdRemover.removeAds();await this.displayThreadImages()}}catch(t){
console.error("[2048-预览] 初始化失败:",t)}}}AdRemover.removeGlobalAds()
;if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",()=>{AdRemover.removeGlobalAds()
;App2048.main()});else{AdRemover.removeGlobalAds();App2048.main()}window.addEventListener("load",()=>{
AdRemover.removeGlobalAds()})})();