check recaptcha before calling 2captcha

This commit is contained in:
2023-03-06 19:53:43 +01:00
parent c363620b65
commit c687b92c1c
+25 -19
View File
@@ -7,7 +7,7 @@ const {
shell
} = require('electron')
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html"
// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html"
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
const BLANK_URL = "about:blank"
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
@@ -312,27 +312,33 @@ class CommandorPage {
await this.push_message_to_queue(PublishType.SUCCESS)
return
}
this.captchaSolver = new SolveCaptcha(page);
await this.captchaSolver.start((solution) => {
log("solution is: " + solution);
if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) {
try {
if (!page.isClosed()) {
page.evaluate((solution) => {
let element = document.getElementById("g-recaptcha-response");
if (element != null)
document.getElementById("g-recaptcha-response").innerHTML = solution;
}, solution)
this.clickValid();
//check whether there is captcha
let hasCaptcha = await page.isVisible("g-recaptcha-response")
if (hasCaptcha) {
this.captchaSolver = new SolveCaptcha(page);
await this.captchaSolver.start((solution) => {
log("solution is: " + solution);
if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) {
try {
if (!page.isClosed()) {
page.evaluate((solution) => {
let element = document.getElementById("g-recaptcha-response");
if (element != null)
document.getElementById("g-recaptcha-response").innerHTML = solution;
}, solution)
this.clickValid();
}
} catch (e) {
log(e)
this.isTerminated = true;
}
} catch (e) {
log(e)
} else {
this.isTerminated = true;
}
} else {
this.isTerminated = true;
}
})
})
} else {
await this.clickValid();
}
}
async isBlocked() {