chatgpt-api/third-party/nopecha-chrome-extension/funcaptcha.js

2 wiersze
2.0 KiB
JavaScript

(async()=>{function o(){return null!==(document.querySelector('button[aria-describedby="descriptionVerify"]')||document.querySelector("#wrong_children_button")||document.querySelector("#wrongTimeout_children_button"))}function r(){try{var e=document.querySelector('button[aria-describedby="descriptionVerify"]'),t=(e&&(window.parent.postMessage({nopecha:!0,action:"clear"},"*"),e.click()),document.querySelector("#wrong_children_button")),a=(t&&(window.parent.postMessage({nopecha:!0,action:"clear"},"*"),t.click()),document.querySelector("#wrongTimeout_children_button"));a&&(window.parent.postMessage({nopecha:!0,action:"clear"},"*"),a.click())}catch(e){}}function u(){return document.querySelector("#game_children_text > h2")?.innerText?.trim()}function s(){return document.querySelector("img#game_challengeItem_image")?.src?.split(";base64,")[1]}let d=null;async function e(){e=500;var e,{task:t,cells:a,image_data:n}=await new Promise(n=>{let c=!1;const i=setInterval(async()=>{if(!c){c=!0;var e=await BG.exec("Settings.get");if(e.enabled&&e.funcaptcha_auto_solve){e.funcaptcha_auto_open&&o()&&await r();e=u();if(e){var t=document.querySelectorAll("#game_children_challenge ul > li > a");if(6===t.length){var a=s();if(a&&d!==a)return d=a,clearInterval(i),c=!1,n({task:e,cells:t,image_data:a})}}c=!1}}},e)});if(null!==t&&null!==a&&null!==n){var c=await BG.exec("Settings.get");if(c.enabled&&c.funcaptcha_auto_solve){var i=Time.time(),l=(await NopeCHA.post({captcha_type:IS_DEVELOPMENT?"funcaptcha_dev":"funcaptcha",task:t,image_data:[n],key:c.key}))["data"];if(l){t=parseInt(c.funcaptcha_solve_delay_time)||1e3,n=c.funcaptcha_solve_delay?t-(Time.time()-i):0;0<n&&await Time.sleep(n);for(let e=0;e<l.length;e++)!1!==l[e]&&a[e].click()}d=null}}}if(window.location.pathname.startsWith("/fc/assets/tile-game-ui/"))for(;;){await Time.sleep(1e3);var t,a=await BG.exec("Settings.get");a&&a.enabled&&(t=await Location.hostname(),a.disabled_hosts.includes(t)||(a.funcaptcha_auto_open&&o()?await r():a.funcaptcha_auto_solve&&null!==u()&&null!==s()&&await e()))}})();