Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save origamiofficial/2557dd47fb0aaf08e3c298a236bfa14d to your computer and use it in GitHub Desktop.

Select an option

Save origamiofficial/2557dd47fb0aaf08e3c298a236bfa14d to your computer and use it in GitHub Desktop.
Recaptcha Solver in Browser | Automatically solves Recaptcha in browser by engageub | Note: This script is solely intended for the use of educational purposes only and not to abuse any website. This script uses audio in order to solve the captcha. Use it wisely and do not abuse any website. Click "Raw" to install it on Tampermonkey
// ==UserScript==
// @name Recaptcha Solver (Automatically solves Recaptcha in browser)
// @namespace Recaptcha Solver
// @version 2.1
// @description Recaptcha Solver in Browser | Automatically solves Recaptcha in browser
// @author engageub
// @match *://*/recaptcha/*
// @connect engageub.pythonanywhere.com
// @connect engageub1.pythonanywhere.com
// @grant GM_xmlhttpRequest
/*
██████╗ ███████╗ ██████╗ █████╗ ██████╗ ████████╗ ██████╗██╗ ██╗ █████╗ ███████╗ ██████╗ ██╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔════╝██╔════╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██║ ██║██╔══██╗ ██╔════╝██╔═══██╗██║ ██║ ██║██╔════╝██╔══██╗
██████╔╝█████╗ ██║ ███████║██████╔╝ ██║ ██║ ███████║███████║ ███████╗██║ ██║██║ ██║ ██║█████╗ ██████╔╝
██╔══██╗██╔══╝ ██║ ██╔══██║██╔═══╝ ██║ ██║ ██╔══██║██╔══██║ ╚════██║██║ ██║██║ ╚██╗ ██╔╝██╔══╝ ██╔══██╗
██║ ██║███████╗╚██████╗██║ ██║██║ ██║ ╚██████╗██║ ██║██║ ██║ ███████║╚██████╔╝███████╗╚████╔╝ ███████╗██║ ██║
╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
/*
/** Note: This script is solely intended for the use of educational purposes only and not to abuse any website.
This script uses audio in order to solve the captcha. Use it wisely and do not abuse any website.
*/
// ==/UserScript==
(function() {
'use strict';
var solved = false;
var checkBoxClicked = false;
var waitingForAudioResponse = false;
//Node Selectors
const CHECK_BOX = ".recaptcha-checkbox-border";
const AUDIO_BUTTON = "#recaptcha-audio-button";
const PLAY_BUTTON = ".rc-audiochallenge-play-button .rc-button-default";
const AUDIO_SOURCE = "#audio-source";
const IMAGE_SELECT = "#rc-imageselect";
const RESPONSE_FIELD = ".rc-audiochallenge-response-field";
const AUDIO_ERROR_MESSAGE = ".rc-audiochallenge-error-message";
const AUDIO_RESPONSE = "#audio-response";
const RELOAD_BUTTON = "#recaptcha-reload-button";
const RECAPTCHA_STATUS = "#recaptcha-accessible-status";
const DOSCAPTCHA = ".rc-doscaptcha-body";
const VERIFY_BUTTON = "#recaptcha-verify-button";
const MAX_ATTEMPTS = 5;
var requestCount = 0;
var recaptchaLanguage = qSelector("html").getAttribute("lang");
var audioUrl = "";
var recaptchaInitialStatus = qSelector(RECAPTCHA_STATUS) ? qSelector(RECAPTCHA_STATUS).innerText : ""
var serversList = ["https://engageub.pythonanywhere.com","https://engageub1.pythonanywhere.com"];
var latencyList = Array(serversList.length).fill(10000);
//Check for visibility && Click the check box
function isHidden(el) {
return(el.offsetParent === null)
}
async function getTextFromAudio(URL) {
var minLatency = 100000;
var url = "";
//Selecting the last/latest server by default if latencies are equal
for(let k=0; k< latencyList.length;k++){
if(latencyList[k] <= minLatency){
minLatency = latencyList[k];
url = serversList[k];
}
}
requestCount = requestCount + 1;
URL = URL.replace("recaptcha.net", "google.com");
if(recaptchaLanguage.length < 1) {
console.log("Recaptcha Language is not recognized");
recaptchaLanguage = "en-US";
}
console.log("Recaptcha Language is " + recaptchaLanguage);
GM_xmlhttpRequest({
method: "POST",
url: url,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: "input=" + encodeURIComponent(URL) + "&lang=" + recaptchaLanguage,
timeout: 60000,
onload: function(response) {
console.log("Response::" + response.responseText);
try {
if(response && response.responseText) {
var responseText = response.responseText;
//Validate Response for error messages or html elements
if(responseText == "0" || responseText.includes("<") || responseText.includes(">") || responseText.length < 2 || responseText.length > 50) {
//Invalid Response, Reload the captcha
console.log("Invalid Response. Retrying..");
} else if(qSelector(AUDIO_SOURCE) && qSelector(AUDIO_SOURCE).src && audioUrl == qSelector(AUDIO_SOURCE).src && qSelector(AUDIO_RESPONSE)
&& !qSelector(AUDIO_RESPONSE).value && qSelector(AUDIO_BUTTON).style.display == "none" && qSelector(VERIFY_BUTTON)) {
qSelector(AUDIO_RESPONSE).value = responseText;
qSelector(VERIFY_BUTTON).click();
} else {
console.log("Could not locate text input box")
}
waitingForAudioResponse = false;
}
} catch(err) {
console.log(err.message);
console.log("Exception handling response. Retrying..");
waitingForAudioResponse = false;
}
},
onerror: function(e) {
console.log(e);
waitingForAudioResponse = false;
},
ontimeout: function() {
console.log("Response Timed out. Retrying..");
waitingForAudioResponse = false;
},
});
}
async function pingTest(url) {
var start = new Date().getTime();
GM_xmlhttpRequest({
method: "GET",
url: url,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: "",
timeout: 8000,
onload: function(response) {
if(response && response.responseText && response.responseText=="0") {
var end = new Date().getTime();
var milliseconds = end - start;
// For large values use Hashmap
for(let i=0; i< serversList.length;i++){
if (url == serversList[i]) {
latencyList[i] = milliseconds;
}
}
}
},
onerror: function(e) {
console.log(e);
},
ontimeout: function() {
console.log("Ping Test Response Timed out for " + url);
},
});
}
function qSelectorAll(selector) {
return document.querySelectorAll(selector);
}
function qSelector(selector) {
return document.querySelector(selector);
}
if(qSelector(CHECK_BOX)){
qSelector(CHECK_BOX).click();
} else if(window.location.href.includes("bframe")){
for(let i=0; i< serversList.length;i++){
pingTest(serversList[i]);
}
}
//Solve the captcha using audio
var startInterval = setInterval(function() {
try {
if(!checkBoxClicked && qSelector(CHECK_BOX) && !isHidden(qSelector(CHECK_BOX))) {
//console.log("checkbox clicked");
qSelector(CHECK_BOX).click();
checkBoxClicked = true;
}
//Check if the captcha is solved
if(qSelector(RECAPTCHA_STATUS) && (qSelector(RECAPTCHA_STATUS).innerText != recaptchaInitialStatus)) {
solved = true;
console.log("SOLVED");
clearInterval(startInterval);
}
if(requestCount > MAX_ATTEMPTS) {
console.log("Attempted Max Retries. Stopping the solver");
solved = true;
clearInterval(startInterval);
}
if(!solved) {
if(qSelector(AUDIO_BUTTON) && !isHidden(qSelector(AUDIO_BUTTON)) && qSelector(IMAGE_SELECT)) {
// console.log("Audio button clicked");
qSelector(AUDIO_BUTTON).click();
}
if((!waitingForAudioResponse && qSelector(AUDIO_SOURCE) && qSelector(AUDIO_SOURCE).src
&& qSelector(AUDIO_SOURCE).src.length > 0 && audioUrl == qSelector(AUDIO_SOURCE).src
&& qSelector(RELOAD_BUTTON)) ||
(qSelector(AUDIO_ERROR_MESSAGE) && qSelector(AUDIO_ERROR_MESSAGE).innerText.length > 0 && qSelector(RELOAD_BUTTON) &&
!qSelector(RELOAD_BUTTON).disabled)){
qSelector(RELOAD_BUTTON).click();
} else if(!waitingForAudioResponse && qSelector(RESPONSE_FIELD) && !isHidden(qSelector(RESPONSE_FIELD))
&& !qSelector(AUDIO_RESPONSE).value && qSelector(AUDIO_SOURCE) && qSelector(AUDIO_SOURCE).src
&& qSelector(AUDIO_SOURCE).src.length > 0 && audioUrl != qSelector(AUDIO_SOURCE).src
&& requestCount <= MAX_ATTEMPTS) {
waitingForAudioResponse = true;
audioUrl = qSelector(AUDIO_SOURCE).src
getTextFromAudio(audioUrl);
}else {
//Waiting
}
}
//Stop solving when Automated queries message is shown
if(qSelector(DOSCAPTCHA) && qSelector(DOSCAPTCHA).innerText.length > 0) {
console.log("Automated Queries Detected");
clearInterval(startInterval);
}
} catch(err) {
console.log(err.message);
console.log("An error occurred while solving. Stopping the solver.");
clearInterval(startInterval);
}
}, 5000);
})();
@rakibxdev

Copy link
Copy Markdown

Bro I was searching for it a long time.. Now Finally got it.. Tnx

@Mujahid2002

Copy link
Copy Markdown

Thank you very much.

@Tcspy34

Tcspy34 commented Jul 1, 2022

Copy link
Copy Markdown

can i get contact Mujahid2002

@Mujahid2002

Copy link
Copy Markdown

Yes ? @Tcspy34

@Tcspy34

Tcspy34 commented Jul 2, 2022 via email

Copy link
Copy Markdown

@soymadip

Copy link
Copy Markdown

When script is running, recaptcha popup is frequently coming at some sites like zoro.to (mainly this ). After 2 or 3 popups, site is saying that "you computer may be sending automatic requests, please try again later".

@The-KTC

The-KTC commented Aug 23, 2022

Copy link
Copy Markdown

wow, thank you very much!

@jahidash

Copy link
Copy Markdown

I have a problem..When i run recaptcha, always show try again later. How can i solve this problem.

@abarth1312

Copy link
Copy Markdown

Top!!!

@culinaxok

Copy link
Copy Markdown

Yes ? @Tcspy34

How to setting interval? I want setting solve every 1 minute.

@zhsohan9086

Copy link
Copy Markdown

can i get contact

@zhsohan9086

Copy link
Copy Markdown

can i get contact plz zakir.hasan.kushtia@gmail.com

@YesTrustMe

YesTrustMe commented May 5, 2023

Copy link
Copy Markdown

Having this script enabled is causing sites to push captchas onto you. For instance: https://apnews.com/.

And then the error message:
"Try again later. Your computer or network may be sending automated queries. To protect our users, we can't process your request right now. For more details visit our help page"

@Jaiyanth0

Copy link
Copy Markdown

How can i make it so that the script is enabled only for the websites of my choice?

@ltfschoen

ltfschoen commented Mar 25, 2024

Copy link
Copy Markdown

How do you get around XSS protection, since the reCAPTCHA iframe loads from a different domain (i.e. www.google.com) and the cross-site contents cannot be read by JavaScript?
When you run the function qSelector(CHECK_BOX) to select the reCAPTCHA checkbox it runs document.querySelector(".recaptcha-checkbox-border") and returns null because it can't find the element since it's looking in the "top", but the reCAPTCHA is loaded from a different domain in an iframe that has a title of "reCAPTCHA".
If you go into your browser inspector console, you can find the name of that iframe, and choose it from the dropdown instead of "top" as shown here
have https://stackoverflow.com/questions/40428105/cant-get-element-in-chrome-dev-tools-unless-i-inspect-it-manually, then its possible to run:

document.querySelector(".recaptcha-checkbox-border")

Then it returns the reCAPTCHA element

But if you instead select "top" instead of the iframe that has loaded from a different domain anchor (i.e. www.google.com) and run:

document.querySelector(".recaptcha-checkbox-border")

It returns

null

Or if you instead run:

document.querySelector('iframe[title=reCAPTCHA]').contentWindow.document.querySelector(".recaptcha-checkbox-border")

Then you'll get error:

Uncaught DOMException: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "http://_____" from accessing a cross-origin frame.

Since the src of the iframe is:

https://www.google.com/recaptcha/api2/anchor?ar=1&k=___________&co=___________&hl=en&v=____________&theme=dark&size=normal&cb=____________

@hammadkhurshid

Copy link
Copy Markdown

@Mujahid2002 this script is not working on text image captcha. Can you please help me out?

@BuiQuocDung1991

Copy link
Copy Markdown

Thank you very much. It has been working normally and faster than using images manually

@vitasnelson-lab

Copy link
Copy Markdown

It stopped working a week ago. The servers aren't responding.

@notMudassirHussain

Copy link
Copy Markdown

Can i get your email?? @origamiofficial

@vitasnelson-lab

vitasnelson-lab commented Jul 20, 2026

Copy link
Copy Markdown

Can i get your email?? @origamiofficial

Hi! vitasnelson@hotmail.com
But after my message, I moved my laptop to a different location, and your solver works here. Apparently, the problem was with the router or internet provider. Actually, I don't know how to check the solver's connection to the servers. I just assumed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment