PageSourceSearch

https://xoigac.top/dist/js/captcha-manager.js?v=6Cj5aPMUUHrOwMbOlykc3RZYjobhKsvkLc5aNPDmZi0

js xoigac.top collected 2026-10-10 02:21:56 UTC 5,505 bytes, 1 lines download raw bytes

1!function(){"use strict";const CaptchaManager={provider:null,enabled:!0,recaptchaSiteKey:null,turnstileSiteKey:null,widgets:{login:null,register:null},recaptchaReady:!1,init(){const enabledMeta=document.querySelector('meta[name="captcha-enabled"]')?.content;if(this.enabled="false"!==enabledMeta,this.enabled)if(this.provider=document.querySelector('meta[name="captcha-provider"]')?.content||"turnstile",this.recaptchaSiteKey=document.querySelector('meta[name="recaptcha-sitekey"]')?.content,this.turnstileSiteKey=document.querySelector('meta[name="turnstile-sitekey"]')?.content,this.provider,this.recaptchaSiteKey,this.turnstileSiteKey,"recaptcha"===this.provider){if(!this.recaptchaSiteKey)return void console.error("[CaptchaManager] ❌ reCAPTCHA SiteKey 未配置!请检查 appsettings.json");"undefined"==typeof grecaptcha?(console.warn("[CaptchaManager] ⚠️ grecaptcha 对象未定义"),console.warn("[CaptchaManager] 这可能是因为:"),console.warn("[CaptchaManager] 1. 脚本正在异步加载中(稍后会可用)"),console.warn("[CaptchaManager] 2. 脚本加载失败(检查 Network 选项卡)"),console.warn("[CaptchaManager] 3. 用户已登录,脚本未加载(检查 _Layout.cshtml 条件)"),console.warn("[CaptchaManager] 4. 网络问题或被广告拦截器阻止")):grecaptcha.ready(()=>{this.recaptchaReady=!0})}else"turnstile"===this.provider&&(this.turnstileSiteKey||console.error("[CaptchaManager] ❌ Turnstile SiteKey 未配置!"))},render(container,action,callback){return this.enabled?"recaptcha"===this.provider?this.renderRecaptcha(container,action,callback):this.renderTurnstile(container,action,callback):(callback&&callback("disabled"),null)},renderRecaptcha:(container,action,callback)=>(container.style.display="none",callback&&callback("recaptcha-ready"),"recaptcha-v3"),renderTurnstile(container,action,callback){if(void 0===window.turnstile)return console.error("[Turnstile] ❌ API 未加载"),console.error("[Turnstile] 请确保在 _Layout.cshtml 中包含:"),console.error('[Turnstile] <script src="https://challenges.cloudflare.com/turnstile/v0/api.js"><\/script>'),null;if(container.dataset.widgetId)return container.dataset.widgetId;try{const widgetId=window.turnstile.render(container,{sitekey:this.turnstileSiteKey,theme:container.dataset.theme||"light",callback:callback,"error-callback":err=>{console.error("[Turnstile] ❌ 验证错误:",err)},"expired-callback":()=>{console.warn("[Turnstile] ⚠️ Token 已过期,正在重置..."),window.turnstile.reset(widgetId)}});return container.dataset.widgetId=widgetId,this.widgets[action]=widgetId,widgetId}catch(err){return console.error("[Turnstile] ❌ 渲染失败:",err),null}},async getToken(action){return this.enabled?(this.provider,"recaptcha"===this.provider?await this.getRecaptchaToken(action):this.getTurnstileToken(action)):null},async getRecaptchaToken(action){try{await this.waitForRecaptchaLoad();return await new Promise((resolve,reject)=>{const timeout=setTimeout(()=>{reject(new Error("reCAPTCHA 执行超时(15秒)"))},15e3);grecaptcha.ready(()=>{grecaptcha.execute(this.recaptchaSiteKey,{action:action}).then(token=>{clearTimeout(timeout),token.substring(0,30),resolve(token)}).catch(err=>{clearTimeout(timeout),console.error("[reCAPTCHA] ❌ execute 失败:",err),reject(err)})})})}catch(err){return console.error("[reCAPTCHA] ❌ 获取 token 失败:",err.message),console.error("[reCAPTCHA] 详细错误:",err),console.group("[reCAPTCHA] 🔍 故障排查建议"),this.recaptchaSiteKey,console.groupEnd(),null}},waitForRecaptchaLoad:async()=>new Promise((resolve,reject)=>{if("undefined"!=typeof grecaptcha&&grecaptcha.ready)return void resolve();const timeout=setTimeout(()=>{console.error("[reCAPTCHA] ❌ 加载超时(30秒)"),console.error("[reCAPTCHA] 可能原因:"),console.error("[reCAPTCHA] 1. 网络问题,无法访问 www.google.com"),console.error("[reCAPTCHA] 2. 脚本被浏览器扩展(如广告拦截器)阻止"),console.error("[reCAPTCHA] 3. CSP 策略阻止了脚本加载"),console.error("[reCAPTCHA] 4. 脚本 URL 错误或 SiteKey 无效"),reject(new Error("reCAPTCHA 脚本加载超时"))},3e4),checkInterval=setInterval(()=>{"undefined"!=typeof grecaptcha&&grecaptcha.ready&&(clearInterval(checkInterval),clearTimeout(timeout),resolve())},100)}),getTurnstileToken(action){const widgetId=this.widgets[action];if(null==widgetId)return console.error("[Turnstile] ❌ Widget 未初始化:",action),null;try{const token=window.turnstile.getResponse(widgetId);return token||(console.warn("[Turnstile] ⚠️ Token 为空,用户可能未完成验证"),null)}catch(err){return console.error("[Turnstile] ❌ 获取 token 失败:",err),null}},reset(action){if(this.enabled)if("recaptcha"===this.provider);else{const widgetId=this.widgets[action];if(null!==widgetId&&void 0!==window.turnstile)try{window.turnstile.reset(widgetId)}catch(err){console.error("[Turnstile] ❌ 重置失败:",err)}}},addTokenToForm(form,token){if(!this.enabled||!token)return;const fieldName="recaptcha"===this.provider?"g-recaptcha-response":"cf-turnstile-response",oldField=form.querySelector(`input[name="${fieldName}"]`);oldField&&oldField.remove();const input=document.createElement("input");input.type="hidden",input.name=fieldName,input.value=token,form.appendChild(input)}};window.CaptchaManager=CaptchaManager,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{CaptchaManager.init()}):CaptchaManager.init()}();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.