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 shell
} = require('electron') } = require('electron')
const GeoCaptchaSolver = require("./GeoCaptchaSolver"); 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 RDV_URL = "https://rendezvousparis.hermes.com/client/register";
const BLANK_URL = "about:blank" const BLANK_URL = "about:blank"
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
@@ -312,27 +312,33 @@ class CommandorPage {
await this.push_message_to_queue(PublishType.SUCCESS) await this.push_message_to_queue(PublishType.SUCCESS)
return return
} }
this.captchaSolver = new SolveCaptcha(page); //check whether there is captcha
await this.captchaSolver.start((solution) => { let hasCaptcha = await page.isVisible("g-recaptcha-response")
log("solution is: " + solution); if (hasCaptcha) {
if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { this.captchaSolver = new SolveCaptcha(page);
try { await this.captchaSolver.start((solution) => {
if (!page.isClosed()) { log("solution is: " + solution);
page.evaluate((solution) => { if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) {
let element = document.getElementById("g-recaptcha-response"); try {
if (element != null) if (!page.isClosed()) {
document.getElementById("g-recaptcha-response").innerHTML = solution; page.evaluate((solution) => {
}, solution) let element = document.getElementById("g-recaptcha-response");
this.clickValid(); if (element != null)
document.getElementById("g-recaptcha-response").innerHTML = solution;
}, solution)
this.clickValid();
}
} catch (e) {
log(e)
this.isTerminated = true;
} }
} catch (e) { } else {
log(e)
this.isTerminated = true; this.isTerminated = true;
} }
} else { })
this.isTerminated = true; } else {
} await this.clickValid();
}) }
} }
async isBlocked() { async isBlocked() {