tanhuazu-helper

tanhuazu.com 探花族论坛助手

נכון ליום 14-03-2023. ראה הגרסה האחרונה.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         tanhuazu-helper
// @namespace    tanhuazu-helper.xyjtyskfydhqss.none
// @version      0.1.4
// @author       xyjtyskfydhqss
// @description  tanhuazu.com 探花族论坛助手
// @license      MIT
// @icon         https://www.tanhuazu.com/favicon.ico
// @include      https://www.tanhuazu.com/*
// @include      https://tanhuazu.com/*
// @require      https://unpkg.com/[email protected]/umd/react.production.min.js
// @require      https://unpkg.com/[email protected]/umd/react-dom.production.min.js
// @connect      self
// @connect      obdown.com
// @grant        GM.xmlHttpRequest
// @grant        GM_notification
// @grant        GM_openInTab
// ==/UserScript==

(e=>{const t=document.createElement("style");t.dataset.source="vite-plugin-monkey",t.innerText=e,document.head.appendChild(t)})(` ._preview-img-wrapper_1v8wn_1{z-index:500}._preview-img-wrapper_1v8wn_1 img{max-height:100%;max-width:100%}.tanhuazu-download-btn{position:relative;display:inline-block;font-weight:400;white-space:nowrap;text-align:center;background-image:none;background-color:transparent;border:1px solid transparent;cursor:pointer;transition:all .2s cubic-bezier(.645,.045,.355,1);user-select:none;touch-action:manipulation;line-height:1.57142857;font-size:16px;height:40px;border-radius:8px;color:#fff;background-color:#1677ff;outline:none;position:absolute;left:calc(100% + 10px);width:100px;top:0;height:auto;width:auto;font-size:30px;padding:5px;display:flex;align-items:center;justify-content:center;text-decoration:none}.tanhuazu-download-btn:hover,.tanhuazu-download-btn:visited{text-decoration:none}.tanhuazu .block-body .message:first-child .message-attribution{font-size:30px}.tanhuazu .structItem.structItem--thread.last-clicked,.tanhuazu .block-row.last-clicked{background-color:#ff8c00;color:#fff}.tanhuazu .structItem.structItem--thread.last-clicked a,.tanhuazu .block-row.last-clicked a{color:#fff}
 `);

(function(v,xe){"use strict";function Ae(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={},ke={get exports(){return S},set exports(e){S=e}};const Me=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),oe=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},se=({clearTimeout:e,setTimeout:t,willResolve:o})=>(r,{value:s,signal:n}={})=>{if(n&&n.aborted)return Promise.reject(oe());let i,c,u;const a=e||clearTimeout,l=()=>{a(i),u(oe())},b=()=>{n&&n.removeEventListener("abort",l)},h=new Promise((m,y)=>{c=()=>{b(),o?m(s):y(s)},u=y,i=(t||setTimeout)(c,r)});return n&&n.addEventListener("abort",l,{once:!0}),h.clear=()=>{a(i),i=null,c()},h},ne=e=>{const t=se({...e,willResolve:!0});return t.reject=se({...e,willResolve:!1}),t.range=(o,r,s)=>t(Me(o,r),s),t},H=ne();H.createWithTimers=ne,ke.exports=H,S.default=H;function Le(){return new Promise(e=>{requestIdleCallback(()=>e(void 0))})}const ae="tanhuazu-helper";function ie(...e){const[t,...o]=e;typeof t=="string"?console.log(`[${ae}]: ${t}`,...o):console.log(`[${ae}]: `,t,...o)}async function De(){for(;;)await Ce(),await S(1e3)}async function Ce(){let e,t,o="",r="";const s=async()=>{var i,c,u;if(await Le(),e=document.querySelector(".overlay-container.is-active .overlay"),!!e&&(o=((c=(i=e.querySelector(".overlay-title"))==null?void 0:i.textContent)==null?void 0:c.trim())??"",t=e==null?void 0:e.querySelector(".overlay-content .blockMessage"),r=((u=t==null?void 0:t.textContent)==null?void 0:u.trim())??"",o==="哎呀!我们遇到了一些问题。"&&r&&r.includes("您必须等待")&&r.includes("后才可以继续执行此操作")))return!0};for(;!await s();)await S(500);let n=Number(/您必须等待 (\d+) 秒后才可以继续执行此操作。/.exec(r)[1]);if(!(!n||isNaN(n))){for(;n>0;){if(!document.querySelector(".overlay-container.is-active .overlay"))return;await S(1e3),n--;const i=n>=60?`${Math.floor(n/60)} 分 ${n%60} 秒`:`${n} 秒`;t.textContent=`您必须等待 ${i} 后才可以继续执行此操作。`}await S(1e3),GM_notification({title:"tanhuazu.com 可以继续操作了",text:document.title,onclick(){GM_openInTab(location.href,{active:!0,insert:!0})}})}}function je(e){const t=e.trim();if(!t)return new Headers;const o=t.split(`\r
`).map(r=>{let s=r.split(":");return[s[0].trim(),s[1].trim()]});return new Headers(o)}function qe(e){const t=new Response(e.response,{statusText:e.statusText,status:e.status,headers:je(e.responseHeaders)});return Object.defineProperty(t,"url",{value:e.finalUrl}),t}async function Ue(e,t){const o=new Request(e,t);let r;return t!=null&&t.body&&(r=await o.text()),await We(o,t,r)}function We(e,t,o){return new Promise((r,s)=>{if(e.signal&&e.signal.aborted)return s(new DOMException("Aborted","AbortError"));GM.xmlHttpRequest({url:e.url,method:Be(e.method.toUpperCase()),headers:Object.fromEntries(new Headers(t==null?void 0:t.headers).entries()),data:o,responseType:"blob",onload(n){r(qe(n))},onabort(){s(new DOMException("Aborted","AbortError"))},ontimeout(){s(new TypeError("Network request failed, timeout"))},onerror(n){s(new TypeError("Failed to fetch: "+n.finalUrl))}})})}const Ie=["GET","POST","PUT","DELETE","PATCH","HEAD","TRACE","OPTIONS","CONNECT"];function Ne(e,t){return e.includes(t)}function Be(e){if(Ne(Ie,e))return e;throw new Error(`unsupported http method ${e}`)}class ce extends Error{constructor(t,o,r){const s=t.status||t.status===0?t.status:"",n=t.statusText||"",i=`${s} ${n}`.trim(),c=i?`status code ${i}`:"an unknown error";super(`Request failed with ${c}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=t,this.request=o,this.options=r}}class ue extends Error{constructor(t){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=t}}const j=e=>e!==null&&typeof e=="object",q=(...e)=>{for(const t of e)if((!j(t)||Array.isArray(t))&&typeof t<"u")throw new TypeError("The `options` argument must be an object");return V({},...e)},le=(e={},t={})=>{const o=new globalThis.Headers(e),r=t instanceof globalThis.Headers,s=new globalThis.Headers(t);for(const[n,i]of s.entries())r&&i==="undefined"||i===void 0?o.delete(n):o.set(n,i);return o},V=(...e)=>{let t={},o={};for(const r of e)if(Array.isArray(r))Array.isArray(t)||(t=[]),t=[...t,...r];else if(j(r)){for(let[s,n]of Object.entries(r))j(n)&&s in t&&(n=V(t[s],n)),t={...t,[s]:n};j(r.headers)&&(o=le(o,r.headers),t.headers=o)}return t},He=(()=>{let e=!1,t=!1;return typeof globalThis.ReadableStream=="function"&&(t=new globalThis.Request("https://a.com",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})(),Ve=typeof globalThis.AbortController=="function",ze=typeof globalThis.ReadableStream=="function",$e=typeof globalThis.FormData=="function",fe=["get","post","put","patch","head","delete"],Fe={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},z=2147483647,he=Symbol("stop"),Ge=e=>fe.includes(e)?e.toUpperCase():e,Ke=["get","put","head","delete","options","trace"],Je=[408,413,429,500,502,503,504],de=[413,429,503],pe={limit:2,methods:Ke,statusCodes:Je,afterStatusCodes:de,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY},Ye=(e={})=>{if(typeof e=="number")return{...pe,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...pe,...e,afterStatusCodes:de}};async function Xe(e,t,o){return new Promise((r,s)=>{const n=setTimeout(()=>{t&&t.abort(),s(new ue(e))},o.timeout);o.fetch(e).then(r).catch(s).then(()=>{clearTimeout(n)})})}const Qe=Boolean(globalThis.DOMException);function me(e){if(Qe)return new DOMException((e==null?void 0:e.reason)??"The operation was aborted.","AbortError");const t=new Error((e==null?void 0:e.reason)??"The operation was aborted.");return t.name="AbortError",t}async function Ze(e,{signal:t}){return new Promise((o,r)=>{if(t){if(t.aborted){r(me(t));return}t.addEventListener("abort",s,{once:!0})}function s(){r(me(t)),clearTimeout(n)}const n=setTimeout(()=>{t==null||t.removeEventListener("abort",s),o()},e)})}class U{static create(t,o){const r=new U(t,o),s=async()=>{if(r._options.timeout>z)throw new RangeError(`The \`timeout\` option cannot be greater than ${z}`);await Promise.resolve();let c=await r._fetch();for(const u of r._options.hooks.afterResponse){const a=await u(r.request,r._options,r._decorateResponse(c.clone()));a instanceof globalThis.Response&&(c=a)}if(r._decorateResponse(c),!c.ok&&r._options.throwHttpErrors){let u=new ce(c,r.request,r._options);for(const a of r._options.hooks.beforeError)u=await a(u);throw u}if(r._options.onDownloadProgress){if(typeof r._options.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ze)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return r._stream(c.clone(),r._options.onDownloadProgress)}return c},i=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(s):s();for(const[c,u]of Object.entries(Fe))i[c]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||u);const l=(await i).clone();if(c==="json"){if(l.status===204||(await l.clone().arrayBuffer()).byteLength===0)return"";if(o.parseJson)return o.parseJson(await l.text())}return l[c]()};return i}constructor(t,o={}){if(Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t,this._options={credentials:this._input.credentials||"same-origin",...o,headers:le(this._input.headers,o.headers),hooks:V({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},o.hooks),method:Ge(o.method??this._input.method),prefixUrl:String(o.prefixUrl||""),retry:Ye(o.retry),throwHttpErrors:o.throwHttpErrors!==!1,timeout:typeof o.timeout>"u"?1e4:o.timeout,fetch:o.fetch??globalThis.fetch.bind(globalThis)},typeof this._input!="string"&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&typeof this._input=="string"){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(Ve){if(this.abortController=new globalThis.AbortController,this._options.signal){const r=this._options.signal;this._options.signal.addEventListener("abort",()=>{this.abortController.abort(r.reason)})}this._options.signal=this.abortController.signal}if(He&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const s="?"+(typeof this._options.searchParams=="string"?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),n=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,s);($e&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)&&!(this._options.headers&&this._options.headers["content-type"])&&this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(n,{...this.request}),this._options)}this._options.json!==void 0&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(t instanceof ue)){if(t instanceof ce){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;const r=t.response.headers.get("Retry-After");if(r&&this._options.retry.afterStatusCodes.includes(t.response.status)){let s=Number(r);return Number.isNaN(s)?s=Date.parse(r)-Date.now():s*=1e3,typeof this._options.retry.maxRetryAfter<"u"&&s>this._options.retry.maxRetryAfter?0:s}if(t.response.status===413)return 0}const o=.3;return Math.min(this._options.retry.backoffLimit,o*2**(this._retryCount-1)*1e3)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(o){const r=Math.min(this._calculateRetryDelay(o),z);if(r!==0&&this._retryCount>0){await Ze(r,{signal:this._options.signal});for(const s of this._options.hooks.beforeRetry)if(await s({request:this.request,options:this._options,error:o,retryCount:this._retryCount})===he)return;return this._retry(t)}throw o}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const o=await t(this.request,this._options);if(o instanceof Request){this.request=o;break}if(o instanceof Response)return o}return this._options.timeout===!1?this._options.fetch(this.request.clone()):Xe(this.request.clone(),this.abortController,this._options)}_stream(t,o){const r=Number(t.headers.get("content-length"))||0;let s=0;return t.status===204?(o&&o({percent:1,totalBytes:r,transferredBytes:s},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(n){const i=t.body.getReader();o&&o({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array);async function c(){const{done:u,value:a}=await i.read();if(u){n.close();return}if(o){s+=a.byteLength;const l=r===0?0:s/r;o({percent:l,transferredBytes:s,totalBytes:r},a)}n.enqueue(a),await c()}await c()}}),{status:t.status,statusText:t.statusText,headers:t.headers})}}/*! MIT License © Sindre Sorhus */const $=e=>{const t=(o,r)=>U.create(o,q(e,r));for(const o of fe)t[o]=(r,s)=>U.create(r,q(e,s,{method:o}));return t.create=o=>$(q(o)),t.extend=o=>$(q(e,o)),t.stop=he,t},ye=$(),et=ye.extend({fetch:Ue});async function tt(){var w,_,g;const e=()=>document.querySelector('.block-body article.message .message-body a[href*="obdown.com"][href*=".torrent"]'),t=performance.now()+5e3;for(;!e()&&performance.now()<t;)await S(500);const o=e();if(!o)return;const r=o.getAttribute("href");if(!r)return;console.log("[tanhuazu-helper]: torrent download page %s",r);const s=await et.get(r,{retry:5}).text(),i=new DOMParser().parseFromString(s,"text/html"),c=Array.from(i.querySelectorAll("span.text-secondary")).filter(E=>{var D;return((D=E.textContent)==null?void 0:D.trim())==="MAGENT"})[0],u=(_=(w=c==null?void 0:c.nextElementSibling)==null?void 0:w.querySelector('a[href^="magnet:?xt="]'))==null?void 0:_.getAttribute("href");if(console.log("[tanhuazu-helper]: magnet link %s",u),!u)return;const a=document.querySelector(".block-body article.message");a.style.position="relative";const l=(g=a.querySelector('a[aria-label="分享"]'))==null?void 0:g.parentElement,b=document.createElement("li");b.innerHTML=`
    <a href="${u}" class="message-attribution-gadget" title="磁力链接">
      <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>
    </a>
  `,l==null||l.insertAdjacentElement("afterend",b),l==null||l.remove();const h=()=>{const E=document.createElement("a");return E.href=u,E.innerHTML=`
      <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>
    `,E.className="tanhuazu-download-btn",E},m=h();a.appendChild(m);const y=h();y.style.top="unset",y.style.bottom="0",a.appendChild(y)}var F={},rt={get exports(){return F},set exports(e){F=e}},W={};/**
 * @license React
 * react-jsx-runtime.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var ot=v,st=Symbol.for("react.element"),nt=Symbol.for("react.fragment"),at=Object.prototype.hasOwnProperty,it=ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,ct={key:!0,ref:!0,__self:!0,__source:!0};function we(e,t,o){var r,s={},n=null,i=null;o!==void 0&&(n=""+o),t.key!==void 0&&(n=""+t.key),t.ref!==void 0&&(i=t.ref);for(r in t)at.call(t,r)&&!ct.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:st,type:e,key:n,ref:i,props:s,_owner:it.current}}W.Fragment=nt,W.jsx=we,W.jsxs=we,function(e){e.exports=W}(rt);const G=F.jsx;var be,ge=xe;be=ge.createRoot,ge.hydrateRoot;const ut=Symbol(),K=Symbol(),k="a",M="w";let lt=(e,t)=>new Proxy(e,t);const J=Object.getPrototypeOf,Y=new WeakMap,_e=e=>e&&(Y.has(e)?Y.get(e):J(e)===Object.prototype||J(e)===Array.prototype),I=e=>typeof e=="object"&&e!==null,ft=e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(o=>{o.configurable=!0}),Object.create(J(e),t)},X=e=>e[K]||e,Re=(e,t,o,r)=>{if(!_e(e))return e;let s=r&&r.get(e);if(!s){const u=X(e);s=(a=>Object.values(Object.getOwnPropertyDescriptors(a)).some(l=>!l.configurable&&!l.writable))(u)?[u,ft(u)]:[u],r==null||r.set(e,s)}const[n,i]=s;let c=o&&o.get(n);return c&&c[1].f===!!i||(c=((u,a)=>{const l={f:a};let b=!1;const h=(y,w)=>{if(!b){let _=l[k].get(u);if(_||(_={},l[k].set(u,_)),y===M)_[M]=!0;else{let g=_[y];g||(g=new Set,_[y]=g),g.add(w)}}},m={get:(y,w)=>w===K?u:(h("k",w),Re(Reflect.get(y,w),l[k],l.c)),has:(y,w)=>w===ut?(b=!0,l[k].delete(u),!0):(h("h",w),Reflect.has(y,w)),getOwnPropertyDescriptor:(y,w)=>(h("o",w),Reflect.getOwnPropertyDescriptor(y,w)),ownKeys:y=>(h(M),Reflect.ownKeys(y))};return a&&(m.set=m.deleteProperty=()=>!1),[m,l]})(n,!!i),c[1].p=lt(i||n,c[0]),o&&o.set(n,c)),c[1][k]=t,c[1].c=o,c[1].p},ve=(e,t,o,r)=>{if(Object.is(e,t))return!1;if(!I(e)||!I(t))return!0;const s=o.get(X(e));if(!s)return!0;if(r){const i=r.get(e);if(i&&i.n===t)return i.g;r.set(e,{n:t,g:!1})}let n=null;try{for(const i of s.h||[])if(n=Reflect.has(e,i)!==Reflect.has(t,i),n)return n;if(s[M]===!0){if(n=((i,c)=>{const u=Reflect.ownKeys(i),a=Reflect.ownKeys(c);return u.length!==a.length||u.some((l,b)=>l!==a[b])})(e,t),n)return n}else for(const i of s.o||[])if(n=!!Reflect.getOwnPropertyDescriptor(e,i)!=!!Reflect.getOwnPropertyDescriptor(t,i),n)return n;for(const i of s.k||[])if(n=ve(e[i],t[i],o,r),n)return n;return n===null&&(n=!0),n}finally{r&&r.set(e,{n:t,g:n})}},ht=e=>_e(e)&&e[K]||null,Ee=(e,t=!0)=>{Y.set(e,t)},dt=(e,t,o)=>{const r=[],s=new WeakSet,n=(i,c)=>{if(s.has(i))return;I(i)&&s.add(i);const u=I(i)&&t.get(X(i));if(u){var a,l;if((a=u.h)==null||a.forEach(h=>{const m=`:has(${String(h)})`;r.push(c?[...c,m]:[m])}),u[M]===!0){const h=":ownKeys";r.push(c?[...c,h]:[h])}else{var b;(b=u.o)==null||b.forEach(h=>{const m=`:hasOwn(${String(h)})`;r.push(c?[...c,m]:[m])})}(l=u.k)==null||l.forEach(h=>{o&&!("value"in(Object.getOwnPropertyDescriptor(i,h)||{}))||n(i[h],c?[...c,h]:[h])})}else c&&r.push(c)};return n(e),r},Q=e=>typeof e=="object"&&e!==null,T=new WeakMap,L=new WeakSet,pt=(e=Object.is,t=(a,l)=>new Proxy(a,l),o=a=>Q(a)&&!L.has(a)&&(Array.isArray(a)||!(Symbol.iterator in a))&&!(a instanceof WeakMap)&&!(a instanceof WeakSet)&&!(a instanceof Error)&&!(a instanceof Number)&&!(a instanceof Date)&&!(a instanceof String)&&!(a instanceof RegExp)&&!(a instanceof ArrayBuffer),r=a=>{switch(a.status){case"fulfilled":return a.value;case"rejected":throw a.reason;default:throw a}},s=new WeakMap,n=(a,l,b=r)=>{const h=s.get(a);if((h==null?void 0:h[0])===l)return h[1];const m=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return Ee(m,!0),s.set(a,[l,m]),Reflect.ownKeys(a).forEach(y=>{if(Object.getOwnPropertyDescriptor(m,y))return;const w=Reflect.get(a,y),_={value:w,enumerable:!0,configurable:!0};if(L.has(w))Ee(w,!1);else if(w instanceof Promise)delete _.value,_.get=()=>b(w);else if(T.has(w)){const[g,E]=T.get(w);_.value=n(g,E(),b)}Object.defineProperty(m,y,_)}),m},i=new WeakMap,c=[1,1],u=a=>{if(!Q(a))throw new Error("object required");const l=i.get(a);if(l)return l;let b=c[0];const h=new Set,m=(p,d=++c[0])=>{b!==d&&(b=d,h.forEach(f=>f(p,d)))};let y=c[1];const w=(p=++c[1])=>(y!==p&&!h.size&&(y=p,g.forEach(([d])=>{const f=d[1](p);f>b&&(b=f)})),b),_=p=>(d,f)=>{const R=[...d];R[1]=[p,...R[1]],m(R,f)},g=new Map,E=(p,d)=>{if(({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&g.has(p))throw new Error("prop listener already exists");if(h.size){const f=d[3](_(p));g.set(p,[d,f])}else g.set(p,[d])},D=p=>{var d;const f=g.get(p);f&&(g.delete(p),(d=f[1])==null||d.call(f))},Vt=p=>(h.add(p),h.size===1&&g.forEach(([f,R],A)=>{if(({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&R)throw new Error("remove already exists");const C=f[3](_(A));g.set(A,[f,C])}),()=>{h.delete(p),h.size===0&&g.forEach(([f,R],A)=>{R&&(R(),g.set(A,[f]))})}),re=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),N=t(re,{deleteProperty(p,d){const f=Reflect.get(p,d);D(d);const R=Reflect.deleteProperty(p,d);return R&&m(["delete",[d],f]),R},set(p,d,f,R){const A=Reflect.has(p,d),C=Reflect.get(p,d,R);if(A&&(e(C,f)||i.has(f)&&e(C,i.get(f))))return!0;D(d),Q(f)&&(f=ht(f)||f);let B=f;if(f instanceof Promise)f.then(P=>{f.status="fulfilled",f.value=P,m(["resolve",[d],P])}).catch(P=>{f.status="rejected",f.reason=P,m(["reject",[d],P])});else{!T.has(f)&&o(f)&&(B=u(f));const P=!L.has(B)&&T.get(B);P&&E(d,P)}return Reflect.set(p,d,B,R),m(["set",[d],f,C]),!0}});i.set(a,N);const zt=[re,w,n,Vt];return T.set(N,zt),Reflect.ownKeys(a).forEach(p=>{const d=Object.getOwnPropertyDescriptor(a,p);"value"in d&&(N[p]=a[p],delete d.value,delete d.writable),Object.defineProperty(re,p,d)}),N})=>[u,T,L,e,t,o,r,s,n,i,c],[mt]=pt();function yt(e={}){return mt(e)}function wt(e,t,o){const r=T.get(e);({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!r&&console.warn("Please use proxy object");let s;const n=[],i=r[3];let c=!1;const a=i(l=>{if(n.push(l),o){t(n.splice(0));return}s||(s=Promise.resolve().then(()=>{s=void 0,c&&t(n.splice(0))}))});return c=!0,()=>{c=!1,a()}}function Se(e,t){const o=T.get(e);({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!o&&console.warn("Please use proxy object");const[r,s,n]=o;return n(r,s(),t)}function bt(e){return L.add(e),e}var Z={},gt={get exports(){return Z},set exports(e){Z=e}},Te={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var x=v;function _t(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Rt=typeof Object.is=="function"?Object.is:_t,vt=x.useState,Et=x.useEffect,St=x.useLayoutEffect,Tt=x.useDebugValue;function Ot(e,t){var o=t(),r=vt({inst:{value:o,getSnapshot:t}}),s=r[0].inst,n=r[1];return St(function(){s.value=o,s.getSnapshot=t,ee(s)&&n({inst:s})},[e,o,t]),Et(function(){return ee(s)&&n({inst:s}),e(function(){ee(s)&&n({inst:s})})},[e]),Tt(o),o}function ee(e){var t=e.getSnapshot;e=e.value;try{var o=t();return!Rt(e,o)}catch{return!0}}function Pt(e,t){return t()}var xt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Pt:Ot;Te.useSyncExternalStore=x.useSyncExternalStore!==void 0?x.useSyncExternalStore:xt,function(e){e.exports=Te}(gt);const At=Ae(Z),{use:Oe}=v,{useSyncExternalStore:kt}=At,Mt=(e,t)=>{const o=v.useRef();v.useEffect(()=>{o.current=dt(e,t,!0)}),v.useDebugValue(o.current)},Lt=new WeakMap;function Dt(e,t){const o=t==null?void 0:t.sync,r=v.useRef(),s=v.useRef();let n=!0;const i=kt(v.useCallback(a=>{const l=wt(e,a,o);return a(),l},[e,o]),()=>{const a=Se(e,Oe);try{if(!n&&r.current&&s.current&&!ve(r.current,a,s.current,new WeakMap))return r.current}catch{}return a},()=>Se(e,Oe));n=!1;const c=new WeakMap;v.useEffect(()=>{r.current=i,s.current=c}),({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&Mt(i,c);const u=v.useMemo(()=>new WeakMap,[]);return Re(i,c,u,Lt)}const Ct={previewImgWrapper:"_preview-img-wrapper_1v8wn_1"};function jt(e){e&&(e.onmouseover=async t=>{const o=t.target;if(o.tagName.toLowerCase()!=="a")return;const r=new URL(o.href,location.href);if(!r.pathname.startsWith("/threads/"))return;const s=r.pathname.split("/").slice(0,3).join("/")+"/";ie("hover: %s",s),O.a=bt(o),O.threadUrl=s;const n=await qt(s);if(ie("fetched imgs",n),O.threadUrl===s&&(O.imgs=n),!te){const i=document.createElement("div");i.classList.add("preview-img-root"),document.body.appendChild(i),te=be(i),te.render(G(Ut,{}))}},e.onmouseout=function(t){O.a=void 0,O.threadUrl="",O.imgs=[]})}async function qt(e){const t=await ye.get(e,{cache:"force-cache"}).text(),r=new DOMParser().parseFromString(t,"text/html");return Array.from(r.querySelectorAll(".block-body .message:first-child .bbImageWrapper img")).map(n=>n.src)}const O=yt({threadUrl:"",a:void 0,imgs:[]});function Ut(){const{imgs:e,a:t}=Dt(O),o=v.useMemo(()=>{const r=t==null?void 0:t.getBoundingClientRect();return((r==null?void 0:r.right)||0)+50},[t]);return e.length?G("div",{className:Ct.previewImgWrapper,style:{position:"fixed",left:o,top:10,width:`calc(100vw - ${o}px - 20px)`,height:"calc(100vh - 20px)",overflow:"hidden"},children:e.slice(0,1).map(r=>G("img",{src:r,alt:""},r))}):null}let te;function Wt(){const e=It();e&&(e.onclick=t=>{Bt(t),Nt(t)},jt(e))}function Pe(){return!(!/^\/search\/\d+\//.test(location.pathname)||new URL(location.href).searchParams.get("searchform")==="1")}function It(){let e;if((e=document.querySelector(['.block[data-type="thread"]','.block[data-widget-key="whats_new_new_posts"]','.p-body-pageContent:has(> form[action^="/watched/threads"])'].join(",")))||Pe()&&(e=document.querySelector(".p-body-pageContent"))||(e=document.querySelector(".p-body-pageContent")))return e}function Nt(e){const t=e.target;if(t.tagName.toLowerCase()!=="a")return;const o=new URL(t.href,location.href);if(o.pathname.startsWith("/threads/")&&o.pathname.includes("unread")){e.preventDefault();const r=t.href.replace(/unread/,"");GM_openInTab(r)}}function Bt(e){var r;const t=".structItem.structItem--thread, .block-row",o=e.target.closest(t);o==null||o.classList.add("last-clicked"),(r=e.currentTarget)==null||r.querySelectorAll(t).forEach(s=>{s!==o&&s.classList.remove("last-clicked")})}const Gt="";Ht();function Ht(){document.body.classList.add("tanhuazu");const e=location.pathname;if(e.startsWith("/threads/")){De(),tt();return}if(e.startsWith("/forums/")||e==="/whats-new/"||e.startsWith("/whats-new/posts/")||e.startsWith("/find-threads/")||e.startsWith("/watched/threads")||Pe()||e.startsWith("/tags/"))return Wt()}})(React,ReactDOM);