var content=(function(){"use strict";function C(t){return t}const a=globalThis.browser?.runtime?.id?globalThis.browser:globalThis.chrome,f="browser-send-event";function w(t){return new Promise(e=>{a.runtime.sendMessage(t,n=>{e(n)})})}const v="send-global-message",E="receive-global-message";function p(){window.addEventListener("message",t=>{const{action:e}=t.data;if(e===v){const{id:n,message:r}=t.data;w(r).then(s=>{window.postMessage({action:E,id:n,response:s})})}})}function S(){a.runtime.onMessage.addListener((t,e,n)=>(t?.action===f&&(window.postMessage(t),n()),!0))}const b="yiketu-extension";function T(t,e){const n=/^\d+(\.\d+)*$/;if(!n.test(t)||!n.test(e))throw new Error('版本号格式不正确，应为数字和点组成，如"1.2.3"');const r=t.split(".").map(Number),s=e.split(".").map(Number),i=Math.max(r.length,s.length);for(let o=0;o<i;o++){const g=r[o]||0,m=s[o]||0;if(g>m)return 1;if(g<m)return-1}return 0}async function I(){const t=document.querySelectorAll(`[data-name="${b}"]`);if(t.length<=0)return Promise.reject("未检测到版本信息，请确认插件是否正常");const e=[];for(const s of t){const{id:i,version:o}=s.dataset;i&&o&&e.push({id:i,version:o})}const n="1.0.0",r=e.reduce((s,i)=>T(s,i.version)===1?s:i.version,n);if(r!==n)return Promise.reject(`检查到最新版本：${r}，请使用最新版本插件`)}const N={matches:["<all_urls>"],async main(){await I(),p(),S()}};function c(t,...e){}const M={debug:(...t)=>c(console.debug,...t),log:(...t)=>c(console.log,...t),warn:(...t)=>c(console.warn,...t),error:(...t)=>c(console.error,...t)};class u extends Event{constructor(e,n){super(u.EVENT_NAME,{}),this.newUrl=e,this.oldUrl=n}static EVENT_NAME=h("wxt:locationchange")}function h(t){return`${a?.runtime?.id}:content:${t}`}function A(t){let e,n;return{run(){e==null&&(n=new URL(location.href),e=t.setInterval(()=>{let r=new URL(location.href);r.href!==n.href&&(window.dispatchEvent(new u(r,n)),n=r)},1e3))}}}class l{constructor(e,n){this.contentScriptName=e,this.options=n,this.abortController=new AbortController,this.isTopFrame?(this.listenForNewerScripts({ignoreFirstEvent:!0}),this.stopOldScripts()):this.listenForNewerScripts()}static SCRIPT_STARTED_MESSAGE_TYPE=h("wxt:content-script-started");isTopFrame=window.self===window.top;abortController;locationWatcher=A(this);receivedMessageIds=new Set;get signal(){return this.abortController.signal}abort(e){return this.abortController.abort(e)}get isInvalid(){return a.runtime.id==null&&this.notifyInvalidated(),this.signal.aborted}get isValid(){return!this.isInvalid}onInvalidated(e){return this.signal.addEventListener("abort",e),()=>this.signal.removeEventListener("abort",e)}block(){return new Promise(()=>{})}setInterval(e,n){const r=setInterval(()=>{this.isValid&&e()},n);return this.onInvalidated(()=>clearInterval(r)),r}setTimeout(e,n){const r=setTimeout(()=>{this.isValid&&e()},n);return this.onInvalidated(()=>clearTimeout(r)),r}requestAnimationFrame(e){const n=requestAnimationFrame((...r)=>{this.isValid&&e(...r)});return this.onInvalidated(()=>cancelAnimationFrame(n)),n}requestIdleCallback(e,n){const r=requestIdleCallback((...s)=>{this.signal.aborted||e(...s)},n);return this.onInvalidated(()=>cancelIdleCallback(r)),r}addEventListener(e,n,r,s){n==="wxt:locationchange"&&this.isValid&&this.locationWatcher.run(),e.addEventListener?.(n.startsWith("wxt:")?h(n):n,r,{...s,signal:this.signal})}notifyInvalidated(){this.abort("Content script context invalidated"),M.debug(`Content script "${this.contentScriptName}" context invalidated`)}stopOldScripts(){window.postMessage({type:l.SCRIPT_STARTED_MESSAGE_TYPE,contentScriptName:this.contentScriptName,messageId:Math.random().toString(36).slice(2)},"*")}verifyScriptStartedEvent(e){const n=e.data?.type===l.SCRIPT_STARTED_MESSAGE_TYPE,r=e.data?.contentScriptName===this.contentScriptName,s=!this.receivedMessageIds.has(e.data?.messageId);return n&&r&&s}listenForNewerScripts(e){let n=!0;const r=s=>{if(this.verifyScriptStartedEvent(s)){this.receivedMessageIds.add(s.data.messageId);const i=n;if(n=!1,i&&e?.ignoreFirstEvent)return;this.notifyInvalidated()}};addEventListener("message",r),this.onInvalidated(()=>removeEventListener("message",r))}}function x(){}function d(t,...e){}const _={debug:(...t)=>d(console.debug,...t),log:(...t)=>d(console.log,...t),warn:(...t)=>d(console.warn,...t),error:(...t)=>d(console.error,...t)};return(async()=>{try{const{main:t,...e}=N,n=new l("content",e);return await t(n)}catch(t){throw _.error('The content script "content" crashed on startup!',t),t}})()})();
content;