"use strict";(()=>{var Ie=Object.create;var ne=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var Ae=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var De=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Oe(t))!Fe.call(e,r)&&r!==n&&ne(e,r,{get:()=>t[r],enumerable:!(o=Pe(t,r))||o.enumerable});return e};var Be=(e,t,n)=>(n=e!=null?Ie(qe(e)):{},De(t||!e||!e.__esModule?ne(n,"default",{value:e,enumerable:!0}):n,e));var de=Ae((ht,N)=>{"use strict";var C=typeof Reflect=="object"?Reflect:null,oe=C&&typeof C.apply=="function"?C.apply:function(t,n,o){return Function.prototype.apply.call(t,n,o)},P;C&&typeof C.ownKeys=="function"?P=C.ownKeys:Object.getOwnPropertySymbols?P=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:P=function(t){return Object.getOwnPropertyNames(t)};function je(e){console&&console.warn&&console.warn(e)}var ae=Number.isNaN||function(t){return t!==t};function s(){s.init.call(this)}N.exports=s;N.exports.once=We;s.EventEmitter=s;s.prototype._events=void 0;s.prototype._eventsCount=0;s.prototype._maxListeners=void 0;var re=10;function O(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return re},set:function(e){if(typeof e!="number"||e<0||ae(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");re=e}});s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};s.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||ae(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ie(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return ie(this)};s.prototype.emit=function(t){for(var n=[],o=1;o0&&(i=n[0]),i instanceof Error)throw i;var c=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw c.context=i,c}var p=a[t];if(p===void 0)return!1;if(typeof p=="function")oe(p,this,n);else for(var l=p.length,d=fe(p,l),o=0;o0&&i.length>r&&!i.warned){i.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+i.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=i.length,je(c)}return e}s.prototype.addListener=function(t,n){return se(this,t,n,!1)};s.prototype.on=s.prototype.addListener;s.prototype.prependListener=function(t,n){return se(this,t,n,!0)};function He(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ce(e,t,n){var o={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=He.bind(o);return r.listener=n,o.wrapFn=r,r}s.prototype.once=function(t,n){return O(n),this.on(t,ce(this,t,n)),this};s.prototype.prependOnceListener=function(t,n){return O(n),this.prependListener(t,ce(this,t,n)),this};s.prototype.removeListener=function(t,n){var o,r,a,i,c;if(O(n),r=this._events,r===void 0)return this;if(o=r[t],o===void 0)return this;if(o===n||o.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,o.listener||n));else if(typeof o!="function"){for(a=-1,i=o.length-1;i>=0;i--)if(o[i]===n||o[i].listener===n){c=o[i].listener,a=i;break}if(a<0)return this;a===0?o.shift():Ne(o,a),o.length===1&&(r[t]=o[0]),r.removeListener!==void 0&&this.emit("removeListener",t,c||n)}return this};s.prototype.off=s.prototype.removeListener;s.prototype.removeAllListeners=function(t){var n,o,r;if(o=this._events,o===void 0)return this;if(o.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):o[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete o[t]),this;if(arguments.length===0){var a=Object.keys(o),i;for(r=0;r=0;r--)this.removeListener(t,n[r]);return this};function le(e,t,n){var o=e._events;if(o===void 0)return[];var r=o[t];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?Ue(r):fe(r,r.length)}s.prototype.listeners=function(t){return le(this,t,!0)};s.prototype.rawListeners=function(t){return le(this,t,!1)};s.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):ue.call(e,t)};s.prototype.listenerCount=ue;function ue(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?P(this._events):[]};function fe(e,t){for(var n=new Array(t),o=0;o{let e=typeof crypto!="undefined"?crypto:typeof window!="undefined"?window.crypto||window.msCrypto:void 0;if(e!==void 0){if(e.randomBytes!==void 0)return e.randomBytes;if(e.getRandomValues!==void 0)return t=>{let n=new Uint8Array(t);return e.getRandomValues(n),n}}return t=>{let n=[];for(let o=t;o>0;o--)n.push(Math.floor(Math.random()*256));return n}})(),me=4096;function he(){(U===void 0||q+16>me)&&(q=0,U=Ve(me));let e=Array.prototype.slice.call(U,q,q+=16);return e[6]=e[6]&15|64,e[8]=e[8]&63|128,u[e[0]]+u[e[1]]+u[e[2]]+u[e[3]]+"-"+u[e[4]]+u[e[5]]+"-"+u[e[6]]+u[e[7]]+"-"+u[e[8]]+u[e[9]]+"-"+u[e[10]]+u[e[11]]+u[e[12]]+u[e[13]]+u[e[14]]+u[e[15]]}var ze={undefined:()=>0,boolean:()=>4,number:()=>8,string:e=>2*e.length,object:e=>e?Object.keys(e).reduce((t,n)=>W(n)+W(e[n])+t,0):0},W=e=>ze[typeof e](e),w=class extends ge.EventEmitter{constructor(t){super(),this.setMaxListeners(1/0),this.wall=t,t.listen(n=>{Array.isArray(n)?n.forEach(o=>this._emit(o)):this._emit(n)}),this._sendingQueue=[],this._sending=!1,this._maxMessageSize=32*1024*1024}send(t,n){return this._send([{event:t,payload:n}])}getEvents(){return this._events}on(t,n){return super.on(t,o=>{n({...o,respond:r=>this.send(o.eventResponseKey,r)})})}_emit(t){typeof t=="string"?this.emit(t):this.emit(t.event,t.payload)}_send(t){return this._sendingQueue.push(t),this._nextSend()}_nextSend(){if(!this._sendingQueue.length||this._sending)return Promise.resolve();this._sending=!0;let t=this._sendingQueue.shift(),n=t[0],o=`${n.event}.${he()}`,r=o+".result";return new Promise((a,i)=>{let c=[],p=l=>{if(l!==void 0&&l._chunkSplit){let d=l._chunkSplit;c=[...c,...l.data],d.lastChunk&&(this.off(r,p),a(c))}else this.off(r,p),a(l)};this.on(r,p);try{let l=t.map(d=>({...d,payload:{data:d.payload,eventResponseKey:r}}));this.wall.send(l)}catch(l){let d="Message length exceeded maximum allowed length.";if(l.message===d&&Array.isArray(n.payload)){let m=W(n);if(m>this._maxMessageSize){let g=Math.ceil(m/this._maxMessageSize),h=Math.ceil(n.payload.length/g),v=n.payload;for(let _=0;_this._nextSend(),16)})}};var ye=(e,t)=>{window.addEventListener("message",n=>{if(n.source===window&&n.data.from!==void 0&&n.data.from===t){let o=n.data[0],r=e.getEvents();for(let a in r)a===o.event&&r[a](o.payload)}},!1)};var Qe=chrome.runtime.getURL("assets/config.js"),Ce,L=(Ce=globalThis.browser)!=null?Ce:globalThis.chrome;async function Ge(){var Z,ee;let e=await L.storage.local.get("defaultConfig");if((Z=e.defaultConfig)!=null&&Z.apiKey)return e.defaultConfig;let t={},n=["DelayTime","RepeatTimes","port"],o=["enabledFor","useCapsolver","manualSolving","useProxy","showSolveButton"],r=/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,c=(await(await fetch(Qe)).text()).replace(r,""),p=c.slice(c.indexOf("{")+1,c.lastIndexOf("}")),l=JSON.stringify(p).replaceAll('\\"',"'").replaceAll("\\n","").replaceAll('"',"").replaceAll(" ",""),d=l.indexOf("blackUrlList"),m=l.slice(d),g=m.indexOf("],"),h=m.slice(0,g+1);l.replace(h,"").split(",").forEach(Re=>{let[I,te]=Re.split(":");if(I&&te){let x=te.replaceAll("'","").replaceAll('"',"");for(let b=0;b{let o=new Image;o.src=e,o.setAttribute("crossOrigin","anonymous"),o.onload=()=>{let r=document.createElement("canvas");r.width=o.width,r.height=o.height,r.getContext("2d").drawImage(o,0,0,o.width,o.height);let i=r.toDataURL();t(i)},o.onerror=r=>{n(r)}})}function y(e){return new Promise(t=>setTimeout(t,e))}function f(e,t){let n=t-e+1;return Math.floor(Math.random()*n+e)}function K(e){let t=e==null?void 0:e.getBoundingClientRect();return t?{x:t.top+window.scrollY-document.documentElement.clientTop+f(-5,5),y:t.left+window.scrollX-document.documentElement.clientLeft+f(-5,5)}:{x:0,y:0}}function Ye(e,t,n,o,r){let[a,i]=t,[c,p]=r,[l,d]=n,[m,g]=o,h=a*(1-e)*(1-e)*(1-e)+3*l*e*(1-e)*(1-e)+3*m*e*e*(1-e)+c*e*e*e,v=i*(1-e)*(1-e)*(1-e)+3*d*e*(1-e)*(1-e)+3*g*e*e*(1-e)+p*e*e*e;return[h,v]}function $e(e,t,n=30){let o=[],r=0,a=1;for(let m=0;m=n*9/10&&(a-=f(60,100),a=Math.max(20,a)),r+=a;let i=[],c=[e.x,e.y],p=[(e.x+t.x)/2+f(30,100)*1,(e.y+t.y)/2+f(30,100)*1],l=[(e.x+t.x)/2+f(30,100)*1,(e.y+t.y)/2+f(30,100)*1],d=[t.x,t.y];for(let m of o){let[g,h]=Ye(m/r,c,p,l,d);i.push({x:g,y:h})}return i}function Je(e,t){let n=$e(e,t,f(15,30));for(let o=0;o{if(k()){let t=document.querySelector(".answer-frame img");(t==null?void 0:t.style.backgroundImage)&&e(!0)}else if(S()){let t=document.querySelector("#game_challengeItem_image");(t==null?void 0:t.src)&&e(!0)}else if(B()){let t=Array.from(document.querySelectorAll(".tile")),n=!0;for(let o=0;oe||!await Me())return!1;let n="";if(k())n=document.querySelector(".answer-frame img").style.backgroundImage;else if(S()){let o=document.querySelector("#game_challengeItem_image");n=o==null?void 0:o.src}else B()&&(n=document.querySelector(".tile").style.backgroundImage);return A===n?!1:(A=n,!0)}async function $(){let e=await st(),t={action:"solver",captchaType:"funCaptcha",params:e};chrome.runtime.sendMessage(t).then(n=>{var o,r;if(!(n!=null&&n.response)||((o=n==null?void 0:n.response)==null?void 0:o.error)){A="",D++;return}lt((r=n.response.response)==null?void 0:r.solution)})}async function lt(e){let t=[],n=e==null?void 0:e.objects[0];if(k()){let o=document.querySelector(".answer-frame .right-arrow");for(let r=0;r{if(z()&&Q(e.funCaptchaRepeatTimes),G()){if(!await X()||!await Y(e.funCaptchaRepeatTimes))return;await $()}},1e3))}async function pt(e){setInterval(async()=>{if(z()&&Q(e.funCaptchaRepeatTimes),G()){if(!await X()||!await Y(e.funCaptchaRepeatTimes))return;await $()}},1e3)}var j=null;j&&window.clearInterval(j);j=window.setInterval(async()=>{let e=await T.getAll();!e.isInit||(e.manualSolving?chrome.runtime.onMessage.addListener(t=>{t.command==="execute"&&pt(e)}):ft(e),window.clearInterval(j))},100);var Ee=e=>{};var J=chrome.runtime.connect({name:"contentScript"}),ke=!1;J.onDisconnect.addListener(()=>{ke=!0});var Se=new w({listen(e){J.onMessage.addListener(e)},send(e){ke||(J.postMessage(e),window.postMessage({...e,from:"bex-content-script"},"*"))}});function dt(e){let t=document.createElement("script");t.src=e,t.onload=function(){this.remove()},(document.head||document.documentElement).appendChild(t)}document instanceof HTMLDocument&&dt(chrome.runtime.getURL("dom.js"));ye(Se,"bex-dom");Ee(Se);})();