tanhuazu-helper

tanhuazu.com 探花族论坛助手

14.03.2023 itibariyledir. En son verisyonu görün.

// ==UserScript==
// @name         tanhuazu-helper
// @namespace    tanhuazu-helper.xyjtyskfydhqss.none
// @version      0.1.3
// @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/react@18.2.0/umd/react.production.min.js
// @require      https://unpkg.com/react-dom@18.2.0/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{background-color:#ff8c00;color:#fff}.tanhuazu .structItem.structItem--thread.last-clicked a{color:#fff}
 `);

(function(v,Oe){"use strict";function Pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={},xe={get exports(){return S},set exports(e){S=e}};const Ae=(e,t)=>Math.floor(Math.random()*(t-e+1)+e),se=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},ne=({clearTimeout:e,setTimeout:t,willResolve:o})=>(r,{value:s,signal:n}={})=>{if(n&&n.aborted)return Promise.reject(se());let i,c,u;const a=e||clearTimeout,l=()=>{a(i),u(se())},b=()=>{n&&n.removeEventListener("abort",l)},h=new Promise((y,m)=>{c=()=>{b(),o?y(s):m(s)},u=m,i=(t||setTimeout)(c,r)});return n&&n.addEventListener("abort",l,{once:!0}),h.clear=()=>{a(i),i=null,c()},h},ae=e=>{const t=ne({...e,willResolve:!0});return t.reject=ne({...e,willResolve:!1}),t.range=(o,r,s)=>t(Ae(o,r),s),t},H=ae();H.createWithTimers=ae,xe.exports=H,S.default=H;function ke(){return new Promise(e=>{requestIdleCallback(()=>e(void 0))})}async function Me(){for(;;)await De(),await S(1e3)}async function De(){let e,t,o="",r="";const s=async()=>{var i,c,u;if(await ke(),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 Le(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 je(e){const t=new Response(e.response,{statusText:e.statusText,status:e.status,headers:Le(e.responseHeaders)});return Object.defineProperty(t,"url",{value:e.finalUrl}),t}async function Ce(e,t){const o=new Request(e,t);let r;return t!=null&&t.body&&(r=await o.text()),await qe(o,t,r)}function qe(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:We(e.method.toUpperCase()),headers:Object.fromEntries(new Headers(t==null?void 0:t.headers).entries()),data:o,responseType:"blob",onload(n){r(je(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 Ue=["GET","POST","PUT","DELETE","PATCH","HEAD","TRACE","OPTIONS","CONNECT"];function Ie(e,t){return e.includes(t)}function We(e){if(Ie(Ue,e))return e;throw new Error(`unsupported http method ${e}`)}class ie 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 ce 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 C=e=>e!==null&&typeof e=="object",q=(...e)=>{for(const t of e)if((!C(t)||Array.isArray(t))&&typeof t<"u")throw new TypeError("The `options` argument must be an object");return V({},...e)},ue=(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(C(r)){for(let[s,n]of Object.entries(r))C(n)&&s in t&&(n=V(t[s],n)),t={...t,[s]:n};C(r.headers)&&(o=ue(o,r.headers),t.headers=o)}return t},Ne=(()=>{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})(),Be=typeof globalThis.AbortController=="function",He=typeof globalThis.ReadableStream=="function",Ve=typeof globalThis.FormData=="function",le=["get","post","put","patch","head","delete"],ze={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"},z=2147483647,fe=Symbol("stop"),Fe=e=>le.includes(e)?e.toUpperCase():e,$e=["get","put","head","delete","options","trace"],Ge=[408,413,429,500,502,503,504],he=[413,429,503],de={limit:2,methods:$e,statusCodes:Ge,afterStatusCodes:he,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY},Ke=(e={})=>{if(typeof e=="number")return{...de,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{...de,...e,afterStatusCodes:he}};async function Je(e,t,o){return new Promise((r,s)=>{const n=setTimeout(()=>{t&&t.abort(),s(new ce(e))},o.timeout);o.fetch(e).then(r).catch(s).then(()=>{clearTimeout(n)})})}const Ye=Boolean(globalThis.DOMException);function pe(e){if(Ye)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 Xe(e,{signal:t}){return new Promise((o,r)=>{if(t){if(t.aborted){r(pe(t));return}t.addEventListener("abort",s,{once:!0})}function s(){r(pe(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 ie(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(!He)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(ze))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:ue(this._input.headers,o.headers),hooks:V({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},o.hooks),method:Fe(o.method??this._input.method),prefixUrl:String(o.prefixUrl||""),retry:Ke(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(Be){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(Ne&&(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);(Ve&&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 ce)){if(t instanceof ie){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 Xe(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})===fe)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()):Je(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 F=e=>{const t=(o,r)=>U.create(o,q(e,r));for(const o of le)t[o]=(r,s)=>U.create(r,q(e,s,{method:o}));return t.create=o=>F(q(o)),t.extend=o=>F(q(e,o)),t.stop=fe,t},ye=F(),Qe=ye.extend({fetch:Ce});async function Ze(){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 Qe.get(r,{retry:5}).text(),i=new DOMParser().parseFromString(s,"text/html"),c=Array.from(i.querySelectorAll("span.text-secondary")).filter(E=>{var L;return((L=E.textContent)==null?void 0:L.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},y=h();a.appendChild(y);const m=h();m.style.top="unset",m.style.bottom="0",a.appendChild(m)}var $={},et={get exports(){return $},set exports(e){$=e}},I={};/**
 * @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 tt=v,rt=Symbol.for("react.element"),ot=Symbol.for("react.fragment"),st=Object.prototype.hasOwnProperty,nt=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0};function me(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)st.call(t,r)&&!at.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:rt,type:e,key:n,ref:i,props:s,_owner:nt.current}}I.Fragment=ot,I.jsx=me,I.jsxs=me,function(e){e.exports=I}(et);const G=$.jsx;var we,be=Oe;we=be.createRoot,be.hydrateRoot;const it=Symbol(),K=Symbol(),k="a",M="w";let ct=(e,t)=>new Proxy(e,t);const J=Object.getPrototypeOf,Y=new WeakMap,ge=e=>e&&(Y.has(e)?Y.get(e):J(e)===Object.prototype||J(e)===Array.prototype),W=e=>typeof e=="object"&&e!==null,ut=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,_e=(e,t,o,r)=>{if(!ge(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,ut(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=(m,w)=>{if(!b){let _=l[k].get(u);if(_||(_={},l[k].set(u,_)),m===M)_[M]=!0;else{let g=_[m];g||(g=new Set,_[m]=g),g.add(w)}}},y={get:(m,w)=>w===K?u:(h("k",w),_e(Reflect.get(m,w),l[k],l.c)),has:(m,w)=>w===it?(b=!0,l[k].delete(u),!0):(h("h",w),Reflect.has(m,w)),getOwnPropertyDescriptor:(m,w)=>(h("o",w),Reflect.getOwnPropertyDescriptor(m,w)),ownKeys:m=>(h(M),Reflect.ownKeys(m))};return a&&(y.set=y.deleteProperty=()=>!1),[y,l]})(n,!!i),c[1].p=ct(i||n,c[0]),o&&o.set(n,c)),c[1][k]=t,c[1].c=o,c[1].p},Re=(e,t,o,r)=>{if(Object.is(e,t))return!1;if(!W(e)||!W(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=Re(e[i],t[i],o,r),n)return n;return n===null&&(n=!0),n}finally{r&&r.set(e,{n:t,g:n})}},lt=e=>ge(e)&&e[K]||null,ve=(e,t=!0)=>{Y.set(e,t)},ft=(e,t,o)=>{const r=[],s=new WeakSet,n=(i,c)=>{if(s.has(i))return;W(i)&&s.add(i);const u=W(i)&&t.get(X(i));if(u){var a,l;if((a=u.h)==null||a.forEach(h=>{const y=`:has(${String(h)})`;r.push(c?[...c,y]:[y])}),u[M]===!0){const h=":ownKeys";r.push(c?[...c,h]:[h])}else{var b;(b=u.o)==null||b.forEach(h=>{const y=`:hasOwn(${String(h)})`;r.push(c?[...c,y]:[y])})}(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,D=new WeakSet,ht=(e=Object.is,t=(a,l)=>new Proxy(a,l),o=a=>Q(a)&&!D.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 y=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return ve(y,!0),s.set(a,[l,y]),Reflect.ownKeys(a).forEach(m=>{if(Object.getOwnPropertyDescriptor(y,m))return;const w=Reflect.get(a,m),_={value:w,enumerable:!0,configurable:!0};if(D.has(w))ve(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(y,m,_)}),y},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,y=(p,d=++c[0])=>{b!==d&&(b=d,h.forEach(f=>f(p,d)))};let m=c[1];const w=(p=++c[1])=>(m!==p&&!h.size&&(m=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]],y(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])},L=p=>{var d;const f=g.get(p);f&&(g.delete(p),(d=f[1])==null||d.call(f))},Nt=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 j=f[3](_(A));g.set(A,[f,j])}),()=>{h.delete(p),h.size===0&&g.forEach(([f,R],A)=>{R&&(R(),g.set(A,[f]))})}),oe=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a)),N=t(oe,{deleteProperty(p,d){const f=Reflect.get(p,d);L(d);const R=Reflect.deleteProperty(p,d);return R&&y(["delete",[d],f]),R},set(p,d,f,R){const A=Reflect.has(p,d),j=Reflect.get(p,d,R);if(A&&(e(j,f)||i.has(f)&&e(j,i.get(f))))return!0;L(d),Q(f)&&(f=lt(f)||f);let B=f;if(f instanceof Promise)f.then(P=>{f.status="fulfilled",f.value=P,y(["resolve",[d],P])}).catch(P=>{f.status="rejected",f.reason=P,y(["reject",[d],P])});else{!T.has(f)&&o(f)&&(B=u(f));const P=!D.has(B)&&T.get(B);P&&E(d,P)}return Reflect.set(p,d,B,R),y(["set",[d],f,j]),!0}});i.set(a,N);const Bt=[oe,w,n,Nt];return T.set(N,Bt),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(oe,p,d)}),N})=>[u,T,D,e,t,o,r,s,n,i,c],[dt]=ht();function pt(e={}){return dt(e)}function yt(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 Ee(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 mt(e){return D.add(e),e}var Z={},wt={get exports(){return Z},set exports(e){Z=e}},Se={};/**
 * @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 bt(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var gt=typeof Object.is=="function"?Object.is:bt,_t=x.useState,Rt=x.useEffect,vt=x.useLayoutEffect,Et=x.useDebugValue;function St(e,t){var o=t(),r=_t({inst:{value:o,getSnapshot:t}}),s=r[0].inst,n=r[1];return vt(function(){s.value=o,s.getSnapshot=t,ee(s)&&n({inst:s})},[e,o,t]),Rt(function(){return ee(s)&&n({inst:s}),e(function(){ee(s)&&n({inst:s})})},[e]),Et(o),o}function ee(e){var t=e.getSnapshot;e=e.value;try{var o=t();return!gt(e,o)}catch{return!0}}function Tt(e,t){return t()}var Ot=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Tt:St;Se.useSyncExternalStore=x.useSyncExternalStore!==void 0?x.useSyncExternalStore:Ot,function(e){e.exports=Se}(wt);const Pt=Pe(Z),{use:Te}=v,{useSyncExternalStore:xt}=Pt,At=(e,t)=>{const o=v.useRef();v.useEffect(()=>{o.current=ft(e,t,!0)}),v.useDebugValue(o.current)},kt=new WeakMap;function Mt(e,t){const o=t==null?void 0:t.sync,r=v.useRef(),s=v.useRef();let n=!0;const i=xt(v.useCallback(a=>{const l=yt(e,a,o);return a(),l},[e,o]),()=>{const a=Ee(e,Te);try{if(!n&&r.current&&s.current&&!Re(r.current,a,s.current,new WeakMap))return r.current}catch{}return a},()=>Ee(e,Te));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"&&At(i,c);const u=v.useMemo(()=>new WeakMap,[]);return _e(i,c,u,kt)}const Dt={previewImgWrapper:"_preview-img-wrapper_1v8wn_1"};function Lt(){const e=re();e&&(e.onmouseover=async t=>{const o=t.target;if(o.tagName.toLowerCase()!=="a"||!new URL(o.href,location.href).pathname.startsWith("/threads/"))return;const s=o.href.replace(/unread/,"");console.log("hover: %s",s),O.a=mt(o),O.threadUrl=s;const n=await jt(s);if(console.log(n),O.threadUrl===s&&(O.imgs=n),!te){const i=document.createElement("div");i.classList.add("preview-img-root"),document.body.appendChild(i),te=we(i),te.render(G(Ct,{}))}},e.onmouseout=function(t){O.a=void 0,O.threadUrl="",O.imgs=[]})}async function jt(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=pt({threadUrl:"",a:void 0,imgs:[]});function Ct(){const{imgs:e,a:t}=Mt(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:Dt.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 qt(){const e=re();e&&(e.onclick=t=>{It(t),Ut(t)},Lt())}function re(){return document.querySelector(['.block[data-type="thread"]','.block[data-widget-key="whats_new_new_posts"]','.p-body-pageContent:has(> form[action^="/watched/threads"])'].join(","))}function Ut(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 It(e){var r;const t=".structItem.structItem--thread",o=e.target.closest(t);o==null||o.classList.add("last-clicked"),(r=re())==null||r.querySelectorAll(t).forEach(s=>{s!==o&&s.classList.remove("last-clicked")})}const zt="";Wt();function Wt(){document.body.classList.add("tanhuazu");const e=location.pathname;if(e.startsWith("/threads/")){Me(),Ze();return}if(e.startsWith("/forums/")||e==="/whats-new/"||e.startsWith("/whats-new/posts/")||e.startsWith("/find-threads/")||e.startsWith("/watched/threads"))return qt()}})(React,ReactDOM);