"use strict";(()=>{var fe=Object.create;var K=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,me=Object.prototype.hasOwnProperty;var ge=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ve=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pe(t))!me.call(e,o)&&o!==n&&K(e,o,{get:()=>t[o],enumerable:!(r=de(t,o))||r.enumerable});return e};var ye=(e,t,n)=>(n=e!=null?fe(he(e)):{},ve(t||!e||!e.__esModule?K(n,"default",{value:e,enumerable:!0}):n,e));var X=ge((Ie,O)=>{"use strict";var g=typeof Reflect=="object"?Reflect:null,U=g&&typeof g.apply=="function"?g.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)},E;g&&typeof g.ownKeys=="function"?E=g.ownKeys:Object.getOwnPropertySymbols?E=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:E=function(t){return Object.getOwnPropertyNames(t)};function Ce(e){console&&console.warn&&console.warn(e)}var H=Number.isNaN||function(t){return t!==t};function a(){a.init.call(this)}O.exports=a;O.exports.once=Le;a.EventEmitter=a;a.prototype._events=void 0;a.prototype._eventsCount=0;a.prototype._maxListeners=void 0;var W=10;function S(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return W},set:function(e){if(typeof e!="number"||e<0||H(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");W=e}});a.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};a.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||H(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 V(e){return e._maxListeners===void 0?a.defaultMaxListeners:e._maxListeners}a.prototype.getMaxListeners=function(){return V(this)};a.prototype.emit=function(t){for(var n=[],r=1;r0&&(i=n[0]),i instanceof Error)throw i;var c=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw c.context=i,c}var f=s[t];if(f===void 0)return!1;if(typeof f=="function")U(f,this,n);else for(var u=f.length,d=G(f,u),r=0;r0&&i.length>o&&!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,Ce(c)}return e}a.prototype.addListener=function(t,n){return z(this,t,n,!1)};a.prototype.on=a.prototype.addListener;a.prototype.prependListener=function(t,n){return z(this,t,n,!0)};function xe(){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 q(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=xe.bind(r);return o.listener=n,r.wrapFn=o,o}a.prototype.once=function(t,n){return S(n),this.on(t,q(this,t,n)),this};a.prototype.prependOnceListener=function(t,n){return S(n),this.prependListener(t,q(this,t,n)),this};a.prototype.removeListener=function(t,n){var r,o,s,i,c;if(S(n),o=this._events,o===void 0)return this;if(r=o[t],r===void 0)return this;if(r===n||r.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,r.listener||n));else if(typeof r!="function"){for(s=-1,i=r.length-1;i>=0;i--)if(r[i]===n||r[i].listener===n){c=r[i].listener,s=i;break}if(s<0)return this;s===0?r.shift():be(r,s),r.length===1&&(o[t]=r[0]),o.removeListener!==void 0&&this.emit("removeListener",t,c||n)}return this};a.prototype.off=a.prototype.removeListener;a.prototype.removeAllListeners=function(t){var n,r,o;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[t]),this;if(arguments.length===0){var s=Object.keys(r),i;for(o=0;o=0;o--)this.removeListener(t,n[o]);return this};function Q(e,t,n){var r=e._events;if(r===void 0)return[];var o=r[t];return o===void 0?[]:typeof o=="function"?n?[o.listener||o]:[o]:n?we(o):G(o,o.length)}a.prototype.listeners=function(t){return Q(this,t,!0)};a.prototype.rawListeners=function(t){return Q(this,t,!1)};a.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):$.call(e,t)};a.prototype.listenerCount=$;function $(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}a.prototype.eventNames=function(){return this._eventsCount>0?E(this._events):[]};function G(e,t){for(var n=new Array(t),r=0;r{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 r=t;r>0;r--)n.push(Math.floor(Math.random()*256));return n}})(),Y=4096;function Z(){(j===void 0||T+16>Y)&&(T=0,j=_e(Y));let e=Array.prototype.slice.call(j,T,T+=16);return e[6]=e[6]&15|64,e[8]=e[8]&63|128,l[e[0]]+l[e[1]]+l[e[2]]+l[e[3]]+"-"+l[e[4]]+l[e[5]]+"-"+l[e[6]]+l[e[7]]+"-"+l[e[8]]+l[e[9]]+"-"+l[e[10]]+l[e[11]]+l[e[12]]+l[e[13]]+l[e[14]]+l[e[15]]}var Ee={undefined:()=>0,boolean:()=>4,number:()=>8,string:e=>2*e.length,object:e=>e?Object.keys(e).reduce((t,n)=>B(n)+B(e[n])+t,0):0},B=e=>Ee[typeof e](e),x=class extends ee.EventEmitter{constructor(t){super(),this.setMaxListeners(1/0),this.wall=t,t.listen(n=>{Array.isArray(n)?n.forEach(r=>this._emit(r)):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,r=>{n({...r,respond:o=>this.send(r.eventResponseKey,o)})})}_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],r=`${n.event}.${Z()}`,o=r+".result";return new Promise((s,i)=>{let c=[],f=u=>{if(u!==void 0&&u._chunkSplit){let d=u._chunkSplit;c=[...c,...u.data],d.lastChunk&&(this.off(o,f),s(c))}else this.off(o,f),s(u)};this.on(o,f);try{let u=t.map(d=>({...d,payload:{data:d.payload,eventResponseKey:o}}));this.wall.send(u)}catch(u){let d="Message length exceeded maximum allowed length.";if(u.message===d&&Array.isArray(n.payload)){let y=B(n);if(y>this._maxMessageSize){let m=Math.ceil(y/this._maxMessageSize),p=Math.ceil(n.payload.length/m),A=n.payload;for(let L=0;Lthis._nextSend(),16)})}};var te=(e,t)=>{window.addEventListener("message",n=>{if(n.source===window&&n.data.from!==void 0&&n.data.from===t){let r=n.data[0],o=e.getEvents();for(let s in o)s===r.event&&o[s](r.payload)}},!1)};var Se=chrome.runtime.getURL("assets/config.js"),re,w=(re=globalThis.browser)!=null?re:globalThis.chrome;async function Te(){var I,F;let e=await w.storage.local.get("defaultConfig");if((I=e.defaultConfig)!=null&&I.apiKey)return e.defaultConfig;let t={},n=["DelayTime","RepeatTimes","port"],r=["enabledFor","useCapsolver","manualSolving","useProxy","showSolveButton"],o=/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,c=(await(await fetch(Se)).text()).replace(o,""),f=c.slice(c.indexOf("{")+1,c.lastIndexOf("}")),u=JSON.stringify(f).replaceAll('\\"',"'").replaceAll("\\n","").replaceAll('"',"").replaceAll(" ",""),d=u.indexOf("blackUrlList"),y=u.slice(d),m=y.indexOf("],"),p=y.slice(0,m+1);u.replace(p,"").split(",").forEach(ue=>{let[_,N]=ue.split(":");if(_&&N){let C=N.replaceAll("'","").replaceAll('"',"");for(let h=0;h{var r,o,s,i;((o=(r=n==null?void 0:n.response)==null?void 0:r.response)==null?void 0:o.status)==="ready"&&(window==null||window.postMessage({type:"turnstileSolved",token:(i=(s=n==null?void 0:n.response)==null?void 0:s.response)==null?void 0:i.code}),M(chrome.i18n.getMessage("solved"),"solved"))})}window.addEventListener("message",async function(e){var t;if(!!["registerTurnstile","capsolverSolve"].includes(e.data.type)&&!(!((t=e.data)!=null&&t.sitekey)&&!P)){if(e.data.type==="registerTurnstile"){Re(e);return}chrome.runtime.sendMessage({action:"solveTurnstile",sitekey:P,websiteURL:window.location.href}).then(n=>{var r,o,s,i;((o=(r=n==null?void 0:n.response)==null?void 0:r.response)==null?void 0:o.status)==="ready"&&(window==null||window.postMessage({type:"turnstileSolved",token:(i=(s=n==null?void 0:n.response)==null?void 0:s.response)==null?void 0:i.code}),M(chrome.i18n.getMessage("solved"),"solved"))})}});async function Oe(){let e=await v.getAll();!e.useCapsolver||!e.enabledForCloudflare||Ae()}Oe();function je(){let e=document.querySelector(".cf-turnstile");if(!e)return null;let t=e.getAttribute("data-sitekey"),n=e.getAttribute("data-action"),r=e.getAttribute("data-cdata"),o=document.location.href;return{sitekey:t,action:n,cData:r,website:o}}function Be(){let e=Array.from(document.querySelectorAll("iframe[src]")),t="";e.forEach(o=>{o.src.startsWith("https://challenges.cloudflare.com/cdn-cgi/challenge-platform/h/b/turnstile")&&(t=o.src)});let n=t.split("/");return n[n.length-3]}chrome.runtime.onMessage.addListener((e,t,n)=>{if((e==null?void 0:e.command)==="get-cloudflare-info"){let r={sitekey:"",website:document.location.href},o=je();if(!o||!o.sitekey){r.sitekey=Be(),n(r);return}n(o);return}});var se=e=>{};var D=chrome.runtime.connect({name:"contentScript"}),ae=!1;D.onDisconnect.addListener(()=>{ae=!0});var ce=new x({listen(e){D.onMessage.addListener(e)},send(e){ae||(D.postMessage(e),window.postMessage({...e,from:"bex-content-script"},"*"))}});function Pe(e){let t=document.createElement("script");t.src=e,t.onload=function(){this.remove()},(document.head||document.documentElement).appendChild(t)}document instanceof HTMLDocument&&Pe(chrome.runtime.getURL("dom.js"));te(ce,"bex-dom");se(ce);})();