NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name u3c3-preview
// @namespace https://rachpt.cn
// @version 2025.07.13.1916
// @author rachpt
// @description U3C3 增强插件
// @license MIT
// @icon https://u001.25img.com/nnn/favicon.png
// @match https://u001.25img.com/*
// @match https://u3c3u3c3.u3c3u3c3u3c3.com/*
// @exclude */view*
// @run-at document-start
// ==/UserScript==
(function () {
'use strict';
function P(t){const r=Array.isArray(t)?t:[t],e=()=>{r.forEach((n,s)=>{try{n();}catch(l){console.error(`执行函数 ${n.name||`#${s+1}`} 时发生错误:`,l);}});};document.readyState==="complete"?e():window.addEventListener("load",e);}const E=(t,r)=>{let e=null;return (...n)=>{e&&clearTimeout(e),e=setTimeout(()=>{t.apply(null,n),e=null;},r);}};function L(t){const r=t.querySelector("td:nth-child(2)>a");if(!r)return false;const e=r.getAttribute("title")||r.textContent?.trim()||"";return !!(e==="國產原创"||e?.startsWith("【表妹推荐】")||/^\((同人|成年).*?\).*/.test(e)||/(Vol|No)\.\d+$/.test(e)||/【.*?-手机搜索】/.test(e)||/^\w+-\d+(-\w+)?\s*/.test(e.replace(/^\++\s*/,""))||/^[\w]+-[\d]+\s/.test(e.replace(/\[[\w\d/ ]+?\]\s*/,""))||/^[\w]+-[\d]+\s/.test(e.replace(/^(\+{3}\s*)?\[?F?HDC?\]?\s*/,""))||/^[-/[\]()\.',\w\d]+$/.test(e.replace(/\s+/g,""))||/^(\[[\w\d\/\s]+?\]\s*)?(FC|fc)2-?(PPV|ppv)[-\s]*\d+?[-\s]*/.test(e.replace(/^\++\s*/,"")))}function v(t){return [...t.values()].filter(r=>!L(r))}let i=null,o=null,h=null;function C(t,r){h=r,i=document.createElement("div"),i.className="status-indicator",i.style.cssText="position:fixed;left:0;top:50%;color:white;padding:5px;z-index:9999;font-size:11px;transform:translateY(-50%);border-radius:0 10px 10px 0;background-color:rgba(0, 0, 0, 0.5);box-shadow:0 0 10px rgba(0, 0, 0, 0.3);width:fit-content;min-width:80px;",o=document.createElement("button"),o.textContent="下一页",o.style.cssText="display:block;margin-top:4px;padding:5px;width:100%;background-color:#337ab7;color:white;border:none;border-radius:3px;cursor:pointer;",o.addEventListener("click",()=>{h&&h();}),i.appendChild(o),document.body.appendChild(i),b(t);}function b(t){if(!i)return;Array.from(i.childNodes).forEach(n=>{n!==o&&i?.removeChild(n);});const e=document.createElement("div");e.innerHTML=`<section>页码:${t.currentPage}</section><section>条数:${t.currentPageItems}</section><section>总条:${t.totalItemsLoaded}</section><section>过滤:${t.totalItemsFiltered}</section>`,i.insertBefore(e,o),o&&(o.disabled=t.isLoading,o.style.opacity=t.isLoading?"0.6":"1",o.textContent=t.isLoading?"加载中...":"下一页");}let d=1,a=false,y=0,w=0,u=0;function x(){return new URLSearchParams(window.location.search)}function I(){const t=x(),r=d+1;return t.set("p",r.toString()),`/?${t.toString()}`}function m(){b({currentPage:d,currentPageItems:u,totalItemsLoaded:y,totalItemsFiltered:w,isLoading:a});}function T(t){const n=new DOMParser().parseFromString(t,"text/html").querySelectorAll("table.torrent-list tbody tr"),s=n.length,l=v(n),g=s-l.length,c=document.createDocumentFragment();for(const f of l)c.appendChild(f.cloneNode(true));return {fragment:c,filtered:g,total:s}}async function p(t=false){if(!(a&&!t)){a=true,m();try{const r=I(),e=await fetch(r);if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);const n=await e.text(),{fragment:s,filtered:l,total:g}=T(n);d++,w+=l,y+=g,u=document.querySelectorAll("table.torrent-list tbody tr").length,m();const c=s.childNodes.length;if(c){const f=document.querySelector("table.torrent-list tbody");f&&(f.appendChild(s),u=document.querySelectorAll("table.torrent-list tbody tr").length,m());}c<=40&&await p(!0);}catch(r){console.error("加载下一页失败:",r);}finally{a=false,m();}}}function S(){const t=window.innerHeight+window.scrollY,r=document.body.offsetHeight;return t>=r-400}const A=E(async()=>{S()&&await p();},1e3);function $(){const t=x();d=parseInt(t.get("p")||"1"),u=document.querySelectorAll("table.torrent-list tbody tr").length,C({currentPage:d,currentPageItems:u,totalItemsLoaded:y,totalItemsFiltered:w,isLoading:a},()=>p(true)),window.addEventListener("scroll",A,{passive:true}),S()&&p(),console.log("无限滚动功能已初始化"),document.querySelector(".center>nav")?.remove(),document.querySelector("#addEmail_n")?.remove();}P([$]);
})();