Greasy Fork

Anti-captcha JS

Just a script

目前为 2019-07-23 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.icu/scripts/384000/719134/Anti-captcha%20JS.js

//============================================================================
// Anti-captcha System -submit
//============================================================================
function antiGoogleShits(token){
    function bitir(code)
    {	
    	var taskSolution=code;
    	var injectedCode = "(" + function(taskSolution) {
                        var recaptchaCallbackAlreadyFired = false;
                        
                        var recursiveCallbackSearch = function(object, solution, currentDepth, maxDepth) {
                            if (recaptchaCallbackAlreadyFired) {
                                return
                            }
                            var passedProperties = 0;
                            for (var i in object) {
                                passedProperties++;
                                if (passedProperties > 15) {
                                    break
                                }
                                try {
                                    if (typeof object[i] == "object" && currentDepth <= maxDepth) {
                                        recursiveCallbackSearch(object[i], solution, currentDepth + 1, maxDepth)
                                    } else if (i == "callback") {
                                        if (typeof object[i] == "function") {
                                            recaptchaCallbackAlreadyFired = true;
                                            object[i](solution)
                                        } else if (typeof object[i] == "string" && typeof window[object[i]] == "function") {
                                            recaptchaCallbackAlreadyFired = true;
                                            window[object[i]](solution)
                                        }
                                        return
                                    }
                                } catch (e) {}
                            }
                        };
                        
                        if (!recaptchaCallbackAlreadyFired) {
                            if (typeof ___grecaptcha_cfg != "undefined" && typeof ___grecaptcha_cfg.clients != "undefined") {
                                var oneVisibleRecaptchaClientKey = null;
                                visible_recaptcha_element_search_loop: for (var i in ___grecaptcha_cfg.clients) {
                                    for (var j in ___grecaptcha_cfg.clients[i]) {
                                        if (___grecaptcha_cfg.clients[i][j] && typeof ___grecaptcha_cfg.clients[i][j].nodeName == "string" && typeof ___grecaptcha_cfg.clients[i][j].innerHTML == "string" && typeof ___grecaptcha_cfg.clients[i][j].innerHTML.indexOf("iframe") != -1) {
                                            if (___grecaptcha_cfg.clients[i][j].offsetHeight != 0 || ___grecaptcha_cfg.clients[i][j].childNodes.length && ___grecaptcha_cfg.clients[i][j].childNodes[0].offsetHeight != 0 || ___grecaptcha_cfg.clients[i][j].dataset.size == "invisible") {
                                                if (oneVisibleRecaptchaClientKey === null) {
                                                    oneVisibleRecaptchaClientKey = i;
                                                    break
                                                } else {
                                                    oneVisibleRecaptchaClientKey = null;
                                                    break visible_recaptcha_element_search_loop
                                                }
                                            }
                                        }
                                    }
                                }
                                if (oneVisibleRecaptchaClientKey !== null) {
                                    recursiveCallbackSearch(___grecaptcha_cfg.clients[oneVisibleRecaptchaClientKey], taskSolution, 1, 2)
                                }
                            }
                        }
                    } + ')("' + taskSolution + '");';
                    var script = document.createElement("script");
                    script.textContent = injectedCode;
                    (document.head || document.documentElement).appendChild(script);
                    script.remove();
    }
    
    //============================================================================
    // Anti-captcha System -captcha
    //============================================================================
    (function(){
        // ...
        var d = document.getElementById("anticaptcha-imacros-account-key");
        if (!d) {
            d = document.createElement("div");
            d.innerHTML = token;
            d.style.display = "none";
            d.id = "anticaptcha-imacros-account-key";
            document.body.appendChild(d);
        }
    
        var s = document.createElement("script");
        s.src = "https://cdn.antcpt.com/imacros_inclusion/recaptcha.js?" + Math.random();
        document.body.appendChild(s);
        // ...
    })();
    //============================================================================
    // Anti-captcha System -error_control
    //============================================================================
    setInterval(function(){captFixError()},10000);
    function captFixError()
    {
    	// If the captcha api get an error, we will try to solve it
    	//document.getElementsByClassName('antigate_solver in_process');
    	if (document.getElementsByClassName('error').length >= 1)
    	{
    	    document.getElementsByClassName("disconnectbtn")[0].click();
    	    document.getElementsByClassName("disconnectbtn")[0].click();
    	    window.location.reload();
    	}
    	else {
    	    console.log('Captcha Status: Good');
            if(document.getElementsByClassName('antigate_solver in_process')){ 
                var keyvalue = document.getElementById('g-recaptcha-response-3').value; 
                if( !keyvalue.length <= 1){
                    bitir(keyvalue);
                }
            }
    	}
    }
}