NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name mteam-preview // @namespace https://rachpt.cn // @version 2025.04.04.1937 // @author rachpt // @description mteam增强插件 // @license MIT // @icon https://static.m-team.cc/favicon.ico // @match https://kp.m-team.cc/browse/* // @match https://kp.m-team.cc/browse // @match https://kp.m-team.cc/detail/* // @connect static.m-team.cc // @connect img.m-team.cc // @connect * // @grant GM_addStyle // @grant GM_xmlhttpRequest // @run-at document-start // ==/UserScript== (n=>{if(typeof GM_addStyle=="function"){GM_addStyle(n);return}const t=document.createElement("style");t.textContent=n,document.head.append(t)})(` #app-content .app-content__inner .ant-spin-nested-loading table>thead>tr>th:nth-child(2) { width:560px !important; } #app-content .app-content__inner .ant-image .torrent-list__thumbnail { height: 444px !important; } #app-content .ant-spin-container .flex-grow .inline-flex.max-w-full.items-center.pr-3.whitespace-nowrap, #app-content .ant-spin-container .flex-grow .inline-flex.max-w-full.items-center.pr-3.whitespace-nowrap .ant-typography.ant-typography-ellipsis.ant-typography-ellipsis-single-line { flex-wrap: wrap !important; text-wrap: wrap !important; } `); (function () { 'use strict'; var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null; var Se=Object.defineProperty;var Ce=(e,t,n)=>t in e?Se(e,t,{enumerable:true,configurable:true,writable:true,value:n}):e[t]=n;var $=(e,t,n)=>Ce(e,typeof t!="symbol"?t+"":t,n);function $e(e){const t=Array.isArray(e)?e:[e],n=()=>{t.forEach((a,o)=>{try{a();}catch(r){console.error(`执行函数 ${a.name||`#${o+1}`} 时发生错误:`,r);}});};document.readyState==="complete"?n():window.addEventListener("load",n);}const j=e=>{const t=performance.now();return new Promise(n=>{const a=()=>{performance.now()-t>=e?n():requestAnimationFrame(a);};requestAnimationFrame(a);})};async function Y(e,t=200,n=300,a=false){for(;t--;){const o=document.querySelector(e);if(!o){await j(n);continue}if(a&&o.innerText?.length===0){await j(n);continue}return o}return null}async function Ee(){if(!Ae())return;const e=await Y(".grid .ant-image-img-placeholder.css-xwzqqd",50,400);if(!e)return;const t=e.closest(".grid.grid-cols-7");t?.classList?.remove("grid-cols-7"),t?.classList?.add("grid-cols-4");const n=document.querySelectorAll(".ant-image-img.ant-image-img-placeholder.css-xwzqqd");for(const a of n){const o=a;if(!o.src)continue;o.src=Re(o.src);const s=o.nextElementSibling;s?.className==="ant-image-mask"&&s?.remove();}}function Ae(){const{host:e,pathname:t}=location;return e.endsWith("m-team.cc")?t.startsWith("/detail/"):false}function Re(e){return e.replace(/(\d+)-(\d+)\.jpg$/,"$1jp-$2.jpg")}const He=e=>`<button type="button" class="ant-btn ${e} ant-btn-circle ant-btn-primary ant-btn-color-primary ant-btn-variant-solid ant-btn-sm ant-btn-icon-only ant-btn-background-ghost mr-2"> <span class="ant-btn-icon"> <span role="img" aria-label="download" class="anticon anticon-download"> <svg viewBox="64 64 896 896" focusable="false" data-icon="download" width="1em" height="1em" fill="currentColor" aria-hidden="true"> <path d="M505.7 661a8 8 0 0012.6 0l112-141.7c4.1-5.2.4-12.9-6.3-12.9h-74.1V168c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v338.3H400c-6.7 0-10.4 7.7-6.3 12.9l112 141.8zM878 626h-60c-4.4 0-8 3.6-8 8v154H214V634c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v198c0 17.7 14.3 32 32 32h684c17.7 0 32-14.3 32-32V634c0-4.4-3.6-8-8-8z"></path> </svg> </span> </span> </button>`,Te=e=>`<button type="button" class="ant-btn ${e} ant-btn-circle ant-btn-primary ant-btn-color-primary ant-btn-variant-solid ant-btn-sm ant-btn-icon-only ant-btn-background-ghost"> <span class="ant-btn-icon"> <span role="img" aria-label="star" class="anticon anticon-star"> <svg viewBox="64 64 896 896" focusable="false" data-icon="star" width="1em" height="1em" fill="currentColor" aria-hidden="true"> <path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3a32.05 32.05 0 00.6 45.3l183.7 179.1-43.4 252.9a31.95 31.95 0 0046.4 33.7L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z"></path> </svg> </span> </span> </button>`,Le=()=>`<span role="img" aria-label="arrow-up" class="anticon anticon-arrow-up mr-0.5" style="color: green;"> <svg viewBox="64 64 896 896" focusable="false" data-icon="arrow-up" width="1em" height="1em" fill="currentColor" aria-hidden="true"> <path d="M868 545.5L536.1 163a31.96 31.96 0 00-48.3 0L156 545.5a7.97 7.97 0 006 13.2h81c4.6 0 9-2 12.1-5.5L474 300.9V864c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V300.9l218.9 252.3c3 3.5 7.4 5.5 12.1 5.5h81c6.8 0 10.5-8 6-13.2z"></path> </svg> </span>`,De=()=>`<span role="img" aria-label="arrow-down" class="anticon anticon-arrow-down mr-0.5" style="color: red;"> <svg viewBox="64 64 896 896" focusable="false" data-icon="arrow-down" width="1em" height="1em" fill="currentColor" aria-hidden="true"> <path d="M862 465.3h-81c-4.6 0-9 2-12.1 5.5L550 723.1V160c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v563.1L255.1 470.8c-3-3.5-7.4-5.5-12.1-5.5h-81c-6.8 0-10.5 8.1-6 13.2L487.9 861a31.96 31.96 0 0048.3 0L868 478.5c4.5-5.2.8-13.2-6-13.2z"></path> </svg> </span>`,ke=()=>{const e=document.createElement("div");return e.className="loading-tip",e.style.cssText="position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:rgba(0, 0, 0, 0.7);color:white;padding:8px 16px;border-radius:4px;z-index:1000;display:none;",e.textContent="加载中...",e},qe=Object.freeze({1:{name:"DIY",color:"rgb(90, 189, 72)"},2:{name:"国配",color:"rgb(90, 59, 20)"},4:{name:"中字",color:"rgb(59, 74, 127)"}}),Me=e=>{const t=Number(e),n=[];return t&1&&n.push("1"),t&2&&n.push("2"),t&4&&n.push("4"),n},Ie=(e,t)=>{if(!e||String(e)==="0")return "";const n=Me(e);if(!n.length)return "";const a="ant-tag ant-tag-has-color ml-1 mt-default";return n.map(o=>{const{name:r,color:s}=qe[o];return `<span class="${a} ${t}" style="background-color:${s};">${r}</span>`}).join("")};var Pe="__monkeyWindow-"+(()=>{try{return new URL((_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('__entry.js', document.baseURI).href)).origin}catch{return location.origin}})(),ge=document[Pe]??window,je=ge.GM,Be=ge.GM_xmlhttpRequest;function Ne(e){var t;const n=new Headers,a=e.replace(/\r?\n[\t ]+/g," ");for(const o of a.split(/\r?\n/)){const r=o.split(":"),s=(t=r.shift())==null?void 0:t.trim();if(s){const c=r.join(":").trim();try{n.append(s,c);}catch(i){console.warn(`Response ${i.message}`);}}}return n}const Fe=async(e,t)=>{const n=Be||je.xmlHttpRequest;if(typeof n!="function")throw new DOMException("GM_xmlhttpRequest or GM.xmlHttpRequest is not granted.","NotFoundError");const a=new Request(e,t);if(a.signal.aborted)throw new DOMException("Network request aborted.","AbortError");const o=await a.arrayBuffer(),r=o.byteLength?new TextDecoder().decode(o):void 0,s=Object.fromEntries(a.headers);return new Headers(t?.headers).forEach((c,i)=>{s[i]=c;}),new Promise((c,i)=>{let l=false;const d=new Promise(g=>{const{abort:x}=n({method:a.method.toUpperCase(),url:a.url||location.href,headers:s,data:r,redirect:a.redirect,binary:true,nocache:a.cache==="no-store",revalidate:a.cache==="reload",timeout:3e5,responseType:n.RESPONSE_TYPE_STREAM??"blob",overrideMimeType:a.headers.get("Content-Type")??void 0,anonymous:a.credentials==="omit",onload:({response:p})=>{if(l){g(null);return}g(p);},async onreadystatechange({readyState:p,responseHeaders:b,status:m,statusText:f,finalUrl:D,response:R}){if(p===XMLHttpRequest.DONE)a.signal.removeEventListener("abort",x);else if(p!==XMLHttpRequest.HEADERS_RECEIVED)return;if(l){g(null);return}const C=Ne(b),k=a.url!==D,H=new Response(R instanceof ReadableStream?R:await d,{headers:C,status:m,statusText:f});Object.defineProperties(H,{url:{value:D},type:{value:"basic"},...H.redirected!==k?{redirected:{value:k}}:{},...C.has("set-cookie")||C.has("set-cookie2")?{headers:{value:C}}:{}}),c(H),l=true;},onerror:({statusText:p,error:b})=>{i(new TypeError(p||b||"Network request failed.")),g(null);},ontimeout(){i(new TypeError("Network request timeout.")),g(null);},onabort(){i(new DOMException("Network request aborted.","AbortError")),g(null);}});a.signal.addEventListener("abort",x);});})};let ze=(e,t)=>{console.error("Fetch Error:",e.message,t);};async function me(e,t={},n=3){let a=0,o;for(;;)try{const r=await Fe(e,t);if(!r.ok){const{status:c,statusText:i}=r,l=`状态: ${i||c}`;throw new Ve(l)}const s=t.responseType||"auto";return s==="blob"?await r.blob():s==="text"?await r.text():r.headers.get("content-type")?.includes("application/json")?await r.json():await r.text()}catch(r){if(o||(o=r),a++,a>=n)throw ze(o||r,e),o||r;await j(200*a);}}class Ve extends Error{constructor(t){super(t),this.name="FetchError";}}const Oe="mteam-preview",_e=1;var y=(e=>(e.ImageCache="image-cache",e))(y||{});function Ue(e){if(!e.objectStoreNames.contains("image-cache")){const t=e.createObjectStore("image-cache",{keyPath:"id"});t.createIndex("insertTime","insertTime",{unique:false}),t.createIndex("lastAccessTime","lastAccessTime",{unique:false});}}const Xe=e=>e?.includes("m-team.cc/")?{Referer:"https://kp.m-team.cc/"}:void 0;let E=null,re=0;async function V(){return E||new Promise((e,t)=>{const n=indexedDB.open(Oe,_e);n.onerror=()=>{t(new Error("无法打开数据库"));},n.onsuccess=a=>{E=a.target.result,E.onclose=()=>{E=null;},e(E);},n.onupgradeneeded=a=>{const o=a.target.result;Ue(o);};})}async function Ge(e,t=540,n=.75){try{const a=await me(e,{method:"GET",responseType:"blob",credentials:"include",headers:Xe(e)});return new Promise((o,r)=>{const s=new Image;s.onload=()=>{const c=document.createElement("canvas");let i=s.width,l=s.height;if(i>t){const g=t/i;i=t,l=l*g;}c.width=i,c.height=l;const d=c.getContext("2d");if(!d){r(new Error("无法获取 canvas 上下文"));return}d.drawImage(s,0,0,i,l),c.toBlob(g=>{g?o(g):r(new Error("无法创建 Blob"));},"image/webp",n);},s.onerror=()=>r(new Error("图像加载失败")),s.src=URL.createObjectURL(a);})}catch(a){throw new Error(`获取图像失败: ${a}`)}}async function We(e,t){try{const n=await Ge(t),r=(await V()).transaction(y.ImageCache,"readwrite").objectStore(y.ImageCache),s={id:e,imageData:n,originalUrl:t,insertTime:Date.now(),lastAccessTime:Date.now()},c=r.put(s);return new Promise((i,l)=>{c.onsuccess=()=>{i();},c.onerror=d=>{l(new Error(`缓存图像失败: ${d}`));};})}catch(n){throw new Error(`缓存图像时出错: ${n}`)}}async function Ke(e){try{const a=(await V()).transaction(y.ImageCache,"readwrite").objectStore(y.ImageCache),o=a.get(e);return new Promise((r,s)=>{o.onsuccess=()=>{const c=o.result;if(c){c.lastAccessTime=Date.now(),a.put(c);const i=URL.createObjectURL(c.imageData);re++,r(i);}else r(null);},o.onerror=()=>s(new Error("获取缓存图像失败"));})}catch(t){return console.error("获取缓存图像时出错:",t),null}}async function Je(e=30){try{const o=(await V()).transaction(y.ImageCache,"readwrite").objectStore(y.ImageCache).index("lastAccessTime"),r=Date.now()-e*24*60*60*1e3,s=o.openCursor(IDBKeyRange.upperBound(r));s.onsuccess=c=>{const i=c.target.result;i&&(i.delete(),i.continue());};}catch(t){console.error("清理缓存时出错:",t);}}async function Ye(){try{const n=(await V()).transaction(y.ImageCache,"readonly").objectStore(y.ImageCache);return new Promise((a,o)=>{let r=0,s=0;const c=n.openCursor();c.onsuccess=i=>{const l=i.target.result;if(l){r++;const d=l.value;s+=d.imageData.size,l.continue();}else a({count:r,size:s});},c.onerror=()=>o(new Error("获取缓存统计信息失败"));})}catch(e){return console.error("获取缓存统计信息时出错:",e),{count:0,size:0}}}function Qe(){return re}function Ze(){re=0;}function et(){const e=localStorage.getItem("lastImageCacheCleanup"),t=Date.now();(!e||t-parseInt(e)>30*24*60*60*1e3)&&Je(60).then(()=>{localStorage.setItem("lastImageCacheCleanup",t.toString()),console.log("图像缓存清理完成");}).catch(n=>{console.error("设置缓存清理任务时出错:",n);});}const tt=e=>{const t=Date.now(),a=new Date(e).getTime()-t,o=1e3*60*60*24;if(t>o)return `${Math.floor(a/o)} 天`;const r=1e3*60*60;return t>r?`${Math.floor(a/r)} 小时`:`${Math.floor(a/(1e3*60))} 分钟`},Q=1024,Z=Q*1024,ee=Z*1024,O=ee*1024,_=16,nt=e=>{if(e.length>_){const n=parseFloat(e.slice(0,_));return `${((e.length-_)*(n/O)).toFixed(2)} TB`}const t=parseFloat(e);return t<Q?`${t.toFixed(2)} B`:t<Z?`${(t/Q).toFixed(2)} KB`:t<ee?`${(t/Z).toFixed(2)} MB`:t<O?`${(t/ee).toFixed(2)} GB`:`${(t/O).toFixed(2)} TB`},at=e=>rt.find(t=>t.id===String(e)),rt=[{id:"100",image:"",name:"电影"},{id:"105",image:"",name:"影剧/综艺"},{id:"110",image:"",name:"Music"},{id:"115",image:"",name:"AV(有码)"},{id:"120",image:"",name:"AV(无码)"},{id:"401",image:"moviesd.png",name:"电影/SD"},{id:"402",image:"tvhd.png",name:"影剧/综艺/HD"},{id:"403",image:"tvsd.png",name:"影剧/综艺/SD"},{id:"404",image:"bbc.png",name:"纪录"},{id:"405",image:"anime.png",name:"动画"},{id:"406",image:"mv.png",name:"演唱"},{id:"407",image:"sport.png",name:"运动"},{id:"409",image:"other.png",name:"Misc(其他)"},{id:"410",image:"cenhd.png",name:"AV(有码)/HD Censored"},{id:"411",image:"hgame.png",name:"H-游戏"},{id:"412",image:"hanime.png",name:"H-动漫"},{id:"413",image:"hcomic.png",name:"H-漫画"},{id:"419",image:"moviehd.png",name:"电影/HD"},{id:"420",image:"moviedvd.png",name:"电影/DVDiSo"},{id:"421",image:"moviebd.png",name:"电影/Blu-Ray"},{id:"422",image:"software.png",name:"软件"},{id:"423",image:"game-pc-3.jpeg",name:"PC游戏"},{id:"424",image:"censd.png",name:"AV(有码)/SD Censored"},{id:"425",image:"ivvideo.png",name:"IV(写真影集)"},{id:"426",image:"uendvd.png",name:"AV(无码)/DVDiSo Uncensored"},{id:"427",image:"Study.png",name:"教育書面"},{id:"429",image:"uenhd.png",name:"AV(无码)/HD Uncensored"},{id:"430",image:"uensd.png",name:"AV(无码)/SD Uncensored"},{id:"431",image:"cenbd.png",name:"AV(有码)/Blu-Ray Censored"},{id:"432",image:"uenbd.png",name:"AV(无码)/Blu-Ray Uncensored"},{id:"433",image:"ivpic.png",name:"IV(写真图集)"},{id:"434",image:"flac.png",name:"Music(无损)"},{id:"435",image:"tvdvd.png",name:"影剧/综艺/DVDiSo"},{id:"436",image:"adult0day.png",name:"AV(网站)/0Day"},{id:"437",image:"cendvd.png",name:"AV(有码)/DVDiSo Censored"},{id:"438",image:"tvbd.png",name:"影剧/综艺/BD"},{id:"439",image:"movieremux.png",name:"电影/Remux"},{id:"440",image:"gayhd.gif",name:"AV(Gay)/HD"},{id:"441",image:"Study_Video.png",name:"教育(影片)"},{id:"442",image:"Study_Audio.png",name:"有声书"},{id:"443",image:"",name:"教育"},{id:"444",image:"",name:"紀錄"},{id:"445",image:"",name:"IV"},{id:"446",image:"",name:"H-ACG"},{id:"447",image:"",name:"遊戲"},{id:"448",image:"pcgame.png",name:"TV游戏"},{id:"449",image:"",name:"動漫"},{id:"450",image:"",name:"其他"}];let h="";const U={},te=e=>e?.[0]?.includes("m-team.cc/")?"origin":"no-referrer",ot=(e,t)=>!e||!t?"":`<a href="${e}" target="_blank" rel="noreferrer" class="mr-2"> <span class="ant-typography ${h}"> <img src="https://static.m-team.cc/static/douban.ico" alt="imdb" height="14" class="rounded-sm" /> <span class="align-middle">${t}</span> </span> </a>`,st=(e,t)=>!e||!t?"":`<a href="${e}" target="_blank" rel="noreferrer" class="mr-2"> <span class="ant-typography ${h}"> <img src="https://static.m-team.cc/static/imdb.gif" alt="imdb" /> <span class="align-middle">${t}</span> </span> </a>`,it=({douban:e,doubanRating:t,imdb:n,imdbRating:a})=>{const o=st(n,a),s=[ot(e,t),o].filter(Boolean);return s.length?`<div class="flex items-center justify-end flex-nowrap">${s.join("")}</div>`:""},ct=e=>Number(e)?`<img src="https://static.m-team.cc/static/ms_up.jpg" alt="+${e}%" title="+${e}%" />`:"",lt=e=>Array.from({length:Number(e)||0},()=>'<img src="https://static.m-team.cc/static/trans.gif" class="sticky" alt="sticky" title="置頂">').join(""),le=e=>{const t="background-color:rgb(255, 85, 0);",n="background-color:rgb(16, 142, 233);",a="ant-tag mt-default ml-2 css-xwzqqd";switch(e){case "NORMAL":return "";case "PERCENT_70":return `<span class="${a} ant-tag-gold">30%</span>`;case "PERCENT_50":return `<span class="${a} ant-tag-has-color" style="${t}">50%</span>`;case "FREE":return `<span class="${a} ant-tag-has-color" style="${n}">Free</span>`;default:return ""}},dt=(e,t,n)=>t?`<span class="ant-typography ml-2 ${n}" title="促销, 截止日期:${t}"> ${le(e)} <span class="ant-typography ${n}" style="font-size: 13px;">限时:${tt(t)}</span> </span>`:le(e),w="border border-solid border-black p-2";async function ut(e,t,n){if(!U[e])try{U[e]=!0,n.referrerPolicy=te([t]);const a=await Ke(e);a?n.src=a:t&&(n.src=t,We(e,t).catch(o=>{console.error("缓存图像失败:",o);}));}catch(a){console.error("加载图像时出错:",a),n.src=t;}finally{U[e]=false;}}const gt=e=>{h||(h=[...document.querySelector('[class*="ant-image"][class*="css-"]')?.classList?.values()||[]].find(q=>q.startsWith("css-"))||"css-xwzqqd");const{comments:t,seeders:n,timesCompleted:a,leechers:o,discount:r,discountEndTime:s,toppingLevel:c}=e.status,{imageList:i,msUp:l,douban:d,createdDate:g,imdbRating:x,imdb:p,doubanRating:b}=e,{name:m,id:f,smallDescr:D,category:R,size:C,labels:k}=e,H=nt(C),se=at(R),xe=it({douban:d,doubanRating:b,imdb:p,imdbRating:x}),ie=i&&i.length>0?i[0]:"",ce=`torrent-img-${f}`;return requestAnimationFrame(()=>{const q=document.getElementById(ce);q&&ie&&ut(f,ie,q);}),`<tr data-id="${f}" data-type="append"> <td class="${w}" align="center"> <a href="/browse?cat=${R}" target="_self"> <img class="cate" src="https://static.m-team.cc/static/cate/${se?.image}" alt="${se?.name}" /> </a> </td> <td class="${w}" align="center"> <div referrerpolicy="${te(i)}" class="ant-image ${h}"> <img id="${ce}" referrerpolicy="${te(i)}" class="ant-image-img torrent-list__thumbnail ${h}" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="${m}" /> </div> </td> <td class="${w}"> <div class="flex flex-nowrap"> <div class="w-2 flex-grow"> <div> <a href="/detail/${f}" target="_blank"> <div class="inline-flex max-w-full items-center pr-3 whitespace-nowrap" style="margin-top: 1px; margin-bottom: 1px"> <span class="ant-typography ant-typography-ellipsis ant-typography-ellipsis-single-line mr-1 ${h}"> <strong> ${lt(c)} ${ct(l)} <span>${m}</span> </strong> </span> <a href="https://wiki.m-team.cc/zh-tw/seedbox-rules" target="_blank"> <img class="box_img" src="https://static.m-team.cc/static/box_small.png" alt="box-img" /> </a> ${dt(r,s,h)} </div> </a> <br /> <div class="inline-flex max-w-full items-center pr-3 whitespace-nowrap"> <span class="ant-typography ant-typography-ellipsis ant-typography-ellipsis-single-line ${h}"> ${D} </span> ${Ie(k,h)} </div> </div> </div> <div> <div class="flex rows-center justify-end flex-nowrap"> <div>${He(h)} ${Te(h)}</div> </div> ${xe} </div> </div> </div> </td> <td class="${w}" align="center">${t}</td> <td class="${w}" align="center"> <span title="" class="block mx-[-5px]">${g}</span> </td> <td class="${w} whitespace-pre-line" align="center"> <div class="mx-[-5px]">${H}</div> </td> <td class="${w}" align="center"> ${Le()}<span>${n}</span> </td> <td class="${w}" align="center"> ${De()}<span>${o}/${a}</span> </td> </tr>`};function mt(e){const t=history.pushState,n=history.replaceState;history.pushState=function(a,o,r){e(a,o,r);const s=[a,o,r];return t.apply(history,s)},history.replaceState=function(a,o,r){e(a,o,r);const s=[a,o,r];return n.apply(history,s)};}async function pt(e,t){const n=new TextEncoder,a=n.encode(e),o=n.encode(t),r=await crypto.subtle.importKey("raw",o,{name:"HMAC",hash:"SHA-1"},false,["sign"]),s=await crypto.subtle.sign("HMAC",r,a);return btoa(String.fromCharCode(...new Uint8Array(s)))}const X=Object.freeze({secret:"HLkPcWmycL57mfJt",webversion:"1140",version:"1.1.4"}),v={secret:"",version:{}};function pe(e){return e?.length?e.filter(t=>!yt(t.smallDescr)):[]}async function ht(){if(v.secret)return v.secret;const{secret:e,...t}=await he();return v.version=t,v.secret=e,e}async function ft(){if(Object.keys(v.version).length)return v.version;const{secret:e,...t}=await he();return v.version=t,v.secret=e,t}async function he(){const e=bt();if(!e)return X;const t=await await me(e);if(!t)return X;const n=/version:"(?<v>[^"]+)"/,a=/secret:"(?<v>[^"]+)"/,o=n.exec(t)?.groups?.v,r=a.exec(t)?.groups?.v;if(!o||!r)return X;const s=o.split("-")[0].replace(/\./g,"")+"0";return {secret:r,version:o,webversion:s}}function yt(e){return e?["#GV","#GAY","WARNING","人妖","勿入","伪娘"].some(n=>e.includes(n)):false}function bt(){const e=document.querySelectorAll("script"),t=/\/js\/main\.[^/]+\.js$/;for(const n of e){const a=n.getAttribute("src");if(a&&t.test(a))return a}return null}const fe=()=>{const e=localStorage.getItem("visitorId"),t=localStorage.getItem("apiHost"),n=localStorage.getItem("auth"),a=localStorage.getItem("did");return {host:t,genHeaders:async()=>({...await ft(),accept:"application/json","Content-Type":"application/json",ts:Math.floor(Date.now()/1e3).toString(),...n&&{Authorization:n},...e&&{visitorId:e},...a&&{did:a}})}},wt=Object.freeze({descend:"DESC",ascend:"ASC"}),vt=()=>1+(Number(new URL(location.href).searchParams.get("pageNumber"))||1),xt=e=>e.replace(/([A-Z])/g,"_$1").toUpperCase(),St=e=>{const t=e.get("sort");if(!t)return {};const[n,a]=t.split(":");return {sortField:xt(n),sortDirection:wt[a]}},Ct=e=>{const t=e.get("uploadDateStart"),n=e.get("uploadDateEnd");return !t||!n?{}:{uploadDateStart:t,uploadDateEnd:n}},$t=()=>{const{href:e,pathname:t}=location,{searchParams:n}=new URL(e),a=t.match(/^\/browse\/(?<m>\w+)$/)?.groups?.m||"normal",o=Number(n.get("pageSize"))||100,r=n.getAll("cat")||[],s=Ct(n),c=St(n);return {mode:a,pageSize:o,categories:r,...c,...s}};async function Et(e=vt()){const t=Date.now(),n=await ht(),a=await pt(`POST&/api/torrent/search&${t}`,n),o={...$t(),visible:1,pageNumber:e,_timestamp:t,_sgin:a},{host:r,genHeaders:s}=fe(),c=`${r}/torrent/search`,i=await s(),d=await(await fetch(c,{body:JSON.stringify(o),method:"POST",headers:i})).json();return pe(d.data?.data)}const At=(e,t,n="beforeend")=>{t.insertAdjacentHTML(n,e);},Rt=(e,t)=>{let n=null;return (...a)=>{n&&clearTimeout(n),n=setTimeout(()=>{e.apply(null,a),n=null;},t);}};let u=null,B=1,A=0,N=0,G=false;const Ht=`<svg viewBox="64 64 896 896" focusable="false" data-icon="reload" width="1em" height="1em" fill="currentColor" aria-hidden="true"> <path d="M909.1 209.3l-56.4 44.1C775.8 155.1 656.2 92 521.9 92 290 92 102.3 279.5 102 511.5 101.7 743.7 289.8 932 521.9 932c181.3 0 335.8-115 394.6-276.1 1.5-4.2-.7-8.9-4.9-10.3l-56.7-19.5a8 8 0 00-10.1 4.8c-1.8 5-3.8 10-5.9 14.9-17.3 41-42.1 77.8-73.7 109.4A344.77 344.77 0 01655.9 829c-42.3 17.9-87.4 27-133.8 27-46.5 0-91.5-9.1-133.8-27A341.5 341.5 0 01279 755.2a342.16 342.16 0 01-73.7-109.4c-17.9-42.4-27-87.4-27-133.9s9.1-91.5 27-133.9c17.3-41 42.1-77.8 73.7-109.4 31.6-31.6 68.4-56.4 109.3-73.8 42.3-17.9 87.4-27 133.8-27 46.5 0 91.5 9.1 133.8 27a341.5 341.5 0 01109.3 73.8c9.9 9.9 19.2 20.4 27.8 31.4l-60.2 47a8 8 0 003 14.1l175.6 43c5 1.2 9.9-2.6 9.9-7.7l.8-180.9c-.1-6.6-7.8-10.3-13-6.2z"></path></svg>`,Tt=e=>{if(e===0)return "0 B";const t=["B","KB","MB","GB"],n=Math.floor(Math.log(e)/Math.log(1024)),a=Math.min(n,t.length-1);return (e/Math.pow(1024,a)).toFixed(2)+" "+t[a]},Lt=()=>{const e=document.createElement("div");e.id="torrent-status-indicator",e.style.cssText="position:fixed;left:0;top:50%;color:white;transform:translateY(-50%);background-color:rgba(0, 0, 0, 0.5);padding:5px 8px 6px 5px;border-radius:0 12px 12px 0;font-size:12px;z-index:1000;display:flex;flex-direction:column;box-shadow:0 0 10px rgba(0, 0, 0, 0.3);position:absolute;",e.innerHTML=`<div class="status-header" style="margin-bottom:8px;font-weight:bold;border-bottom:1px solid rgba(255,255,255,0.2);padding-bottom:5px;">状态监视器</div><div id="status-body"><div class="cache-stats" style="margin-bottom:8px;"><div>缓存:<span id="cache-count">0</span> 条</div><div>空间:<span id="cache-size">0 B</span></div><div>命中:<span id="cache-hits">0</span> 次</div></div><div class="status-content" style="margin-bottom:8px;border-top:1px solid rgba(255,255,255,0.2);padding-top:5px;"><div>页码:<span id="current-page">1 / ${N}</span></div><div>总数:<span id="total-records">${A}</span></div></div><button id="load-next-page" style=" background:none;border:1px solid rgba(255,255,255,0.6);color:#fff;padding:2px;border-radius:4px;cursor:pointer;display:flex;font-size:xx-small;align-items:center;justify-content:center;transition:background-color 0.2s;width:100%;"> ${Ht} 下一页 </button></div><div id="loading-animation" style=" display:none;position:absolute;top:24px;left:0;right:0;bottom:0;background-color:rgba(0, 0, 0, 0.7);text-align:center;flex-direction:column;justify-content:center;align-items:center;border-radius:0 0 12px 0;z-index:10;"><div class="loading-spinner" style=" width:24px;height:24px;border:2px solid rgba(255, 255, 255, 0.3);border-radius:50%;border-top-color:#fff;animation:spin 1s ease-in-out infinite;margin-top:12px;display:inline-block;"></div><style> @keyframes spin { to { transform:rotate(360deg);} } </style><div style="margin-top:5px;font-size:12px;">加载中...</div></div>`;const t=e.querySelector("#load-next-page");return t&&(t.addEventListener("mouseover",()=>{t.style.backgroundColor="rgba(255,255,255,0.1)";}),t.addEventListener("mouseout",()=>{t.style.backgroundColor="transparent";})),e},Dt=e=>{u&&document.body.removeChild(u),u=Lt(),document.body.appendChild(u);const t=u.querySelector("#load-next-page");return t&&t.addEventListener("click",e),ne(),setInterval(ne,1e4),u},ne=async()=>{if(u&&!G){G=true;try{const{count:e,size:t}=await Ye(),n=Qe(),a=u.querySelector("#cache-count"),o=u.querySelector("#cache-size"),r=u.querySelector("#cache-hits");a&&(a.textContent=String(e)),o&&(o.textContent=Tt(t)),r&&(r.textContent=String(n));}catch(e){console.error("更新缓存信息时出错:",e);}finally{G=false;}}},oe=(e,t)=>{if(!u)return;B=e,t>0&&(A+=t);const n=u.querySelector("#current-page"),a=u.querySelector("#total-records");n&&(n.textContent=`${B} / ${N}`),a&&(a.textContent=String(A)),ne();},kt=()=>{A=0,B=1;},qt=e=>{const t=e?.data?.totalPages||0,n=e?.data?.data?.length||0;if(A+=n,N=t,!u)return;const a=u?.querySelector("#current-page"),o=u?.querySelector("#total-records");a&&(a.textContent=`${B} / ${N}`),o&&(o.textContent=String(A));},Mt=e=>{if(!u)return;const t=u.querySelector("#loading-animation"),n=u.querySelector("#load-next-page");t&&(t.style.display=e?"flex":"none"),n&&(n.disabled=e);},It=()=>{u&&u.parentNode&&(u.parentNode.removeChild(u),u=null);};let I=false,P=false,T=1,F="",S=null,z=false;const Pt=()=>{const e=document.querySelector("#app-content");if(!e)return false;const{scrollHeight:t,scrollTop:n,clientHeight:a}=e;return t-n-a<=1e3},de=e=>{S&&(S.style.display=e?"block":"none",Mt(e));},ye=async()=>{if(!P)try{P=!0,de(!0);const e=document.querySelector(".ant-spin-container tbody");if(!e)return;const t=await Et(T+1);if(!t?.length)return;t.forEach(n=>{const a=gt(n);At(a,e);}),T++,oe(T,t.length);}catch(e){console.error("加载更多失败:",e);}finally{setTimeout(()=>{P=false;},3e3),de(false);}},be=Rt(async()=>{Pt()&&await ye();},1e3),jt=e=>{const t=e.target;(t.classList.contains("ant-image")||t.classList.contains("ant-image-img"))&&(e.preventDefault(),e.stopPropagation());},we=()=>{const e=document.querySelectorAll('tr[data-type="append"]');for(const t of e)t.remove();kt(),Ze();},ve=()=>{document.querySelector("#app-content")?.removeEventListener("scroll",be),S?.remove(),we(),It(),F="",I=false,T=1,P=false,S=null,z=false,window.handleScrollEventRef=void 0,console.log("run cleanup.");};async function Bt(){et(),mt((e,t,n)=>{if(console.log("url change:",n),!n?.startsWith("/browse"))return ve();n!==F&&(F=n,T=1,we(),z&&oe(1,0)),ue();}),Nt()&&await ue();}async function ue(){if(I)return;F=location.pathname,await Y(".ant-image-img",50,400),await j(500),await Y(".ant-image-mask",50,400),S||(S=ke(),document.body.appendChild(S)),z||(Dt(ye),oe(1,0),z=true),document.querySelector("#float-btns")?.remove(),document.querySelectorAll(".ant-image > .ant-image-mask").forEach(n=>n?.remove()),document.addEventListener("click",jt,true),setTimeout(()=>{const n=document.querySelector("#app-content");n&&(I||(I=true,window.handleScrollEventRef&&window.handleScrollEventRef?.(),n.addEventListener("scroll",be),window.handleScrollEventRef=ve,console.log("Adding scroll listener to #app-content")));},8e3);}function Nt(){const{host:e,pathname:t}=location;return e.endsWith("m-team.cc")?t.startsWith("/browse"):false}let M=null;const L=class L{constructor(t){$(this,"originalXHRopen");$(this,"originalXHRsend");$(this,"interceptConfigs",[]);$(this,"originalFetch");if(L.isHijacked){if(M)return M.addConfig(t),M;console.warn("XHRAndFetchInterceptor: 拦截器已经被激活,避免重复拦截。");return}this.interceptConfigs=Array.isArray(t)?t:[t],this.originalXHRopen=XMLHttpRequest.prototype.open,this.originalXHRsend=XMLHttpRequest.prototype.send,this.originalFetch=window.fetch,this.hijackXHR(),this.hijackFetch(),L.isHijacked=true,M=this;}addConfig(t){(Array.isArray(t)?t:[t]).forEach(a=>{this.interceptConfigs.some(r=>r.url===a.url&&r.method===a.method)||this.interceptConfigs.push(a);});}hijackXHR(){const t=this;XMLHttpRequest.prototype.open=function(n,a,o=true,r,s){this.uri=a,this.method=n,t.originalXHRopen.apply(this,[n,a,o,r,s]);},XMLHttpRequest.prototype.send=async function(n){const a=this.onreadystatechange,o=t.originalXHRsend.bind(this),r={status:0,statusText:"",response:null,responseText:"",responseXML:null,responseType:"",readyState:0},s=new Proxy(this,{get:(i,l)=>l==="readyState"?r.readyState:Reflect.get(i,l)}),c=this.uri?.startsWith("/")?`${location.origin}${this.uri}`:this.uri;for(const i of t.interceptConfigs)if(W(c,i.url)&&K(this.method,i.method)){if(i.beforeSendCallback){const l={url:new URL(c),data:n},{data:d,url:g}=await i.beforeSendCallback(l)||{};d&&(n=d),g&&(this.uri=g.toString(),t.originalXHRopen.apply(this,[this.method,this.uri,true]));}break}return this.onreadystatechange=async function(i){let l=true;if(this.readyState===4&&this.status===200)for(const d of t.interceptConfigs){if(!W(this.responseURL,d.url)||!K(this.method,d.method))continue;const g={url:new URL(this.responseURL),data:n};if(d.preCallback){const[p,b]=await d.preCallback(J(this),g);if(!p){l=false;const m=new XMLHttpRequest;return m.open(this.method,b.uri,true),m.onreadystatechange=async()=>{if(m.readyState===4){if(r.status=m.status,r.statusText=m.statusText,r.response=m.response,r.responseText=m.responseText,r.responseXML=m.responseXML,r.readyState=m.readyState,d.lastCallback){const f=await d.lastCallback(J(r),g);r.response=f,r.responseText=JSON.stringify(f);}Object.defineProperties(this,{status:{get:()=>r.status},response:{get:()=>r.response},statusText:{get:()=>r.statusText},responseXML:{get:()=>r.responseXML},responseText:{get:()=>r.responseText},responseType:{get:()=>r.responseType},readyState:{get:()=>r.readyState}}),a&&a.call(s,i);}},m.send(b?.data)}}const x=J(this);if(d.callback&&await d.callback(x),d.lastCallback){const p=await d.lastCallback(x,g);r.response=p,r.responseText=JSON.stringify(p),Object.defineProperties(this,{response:{get:()=>r.response},responseText:{get:()=>r.responseText}});}}a&&l&&a.call(this,i);},o(n)};}hijackFetch(){const t=this,n=this.originalFetch;window.fetch=async function(a,o){const r=typeof a=="string"?a:a instanceof URL?a.href:a.url,s=o&&o.method?o.method:"GET",c=await n.apply(window,[a,o]);return c.clone().text().then(async i=>{for(const l of t.interceptConfigs)W(c.url,l.url)&&K(s,l.method)&&(console.log(`Fetch 请求被拦截,URL: ${r}, ${s}`),l.callback&&await l.callback(i));}),c};}restore(){XMLHttpRequest.prototype.open=this.originalXHRopen,XMLHttpRequest.prototype.send=this.originalXHRsend,window.fetch=this.originalFetch;}};$(L,"isHijacked",false);let ae=L;function W(e,t){if(t instanceof RegExp)return t.test(e);try{const n=new URL(e),a=new URL(t);return n.host===a.host&&n.protocol===a.protocol&&n.pathname===a.pathname}catch{return false}}function K(e,t){return e?.toLocaleLowerCase()===t?.toLocaleLowerCase()}function J(e){return e.responseType==="json"?e.response:e.responseText}async function Ft(){if(!zt())return;const{host:e}=fe();new ae([{method:"POST",url:`${e}/torrent/search`,lastCallback:Vt}]);}function zt(){const{host:e}=location;return e.endsWith(".m-team.cc")}async function Vt(e){const t=typeof e=="string"?JSON.parse(e):e;return t?.data?.data?.length&&(t.data.data=pe(t.data.data),qt(t)),t}Ft(),$e([Bt,Ee]); })();