From 5e69d68dde111f5473c9dd33f32d501fcf5c5b7d Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Wed, 19 Jul 2023 19:10:45 +0200 Subject: [PATCH] more possibility --- src/workers/CommandorPage.js | 10 ++++++++-- src/workers/OCRChecker.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 44d8da9..98aa248 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -838,13 +838,13 @@ class CommandorPage { pages.forEach((currentPage) => { if (currentPage.url() === RDV_URL) { this.page = currentPage; + } else { + currentPage.close() } }) logWithDevice("this.page.bringToFront();", this.device) await this.page.bringToFront(); - // this.page = pages; - // this.page.await await this.fillFields(this.page) await delay(2 * 1000); } catch (e) { @@ -863,6 +863,8 @@ class CommandorPage { pages.forEach((currentPage) => { if (currentPage.url() === RDV_URL) { this.page = currentPage; + } else { + currentPage.close() } }) logWithDevice("this.page.bringToFront();", this.device) @@ -894,7 +896,11 @@ class CommandorPage { break; case OCRResult.RECAPTCHA_ERROR: + // if (!this.isFillingFields) this.isTerminated = true; + // else { + // await this.checkResultWithOcr(); + // } // await this.connect_to_browser(OCRResult.RECAPTCHA_ERROR) break; case diff --git a/src/workers/OCRChecker.js b/src/workers/OCRChecker.js index 47818a4..3fcd0ac 100644 --- a/src/workers/OCRChecker.js +++ b/src/workers/OCRChecker.js @@ -24,6 +24,7 @@ const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again" const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué" const BLOCKED_MSG_EN = "have been blocked" const BLOCKED_MSG_FR = "avez été bloqué" +const BLOCKED_MSG_FR_2 = "Pourquoi ce blocage" const CHECKING_MSG_FR = "Verifying" const ERR_CACHE_MISS = "ERR_CACHE_MISS" const ERR_CACHE_MISS_2 = "ERR_CACHE-MISS" @@ -34,7 +35,10 @@ const SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour" const SLIDING_CAPTCHA_FR_3 = "la droite pour completer le puzzle" const SLIDING_CAPTCHA_FR_4 = " s'assure qu'on s'adresse bien" const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour" -const MESSAGE_FILL_FIELD_FR_2 = "Lensemble des champs de données doivent étre complétés" +const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés" +const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré" +const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré" +const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous" const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome" const PAGE_OPTIMIZATION_CHROME_FR = "Vous pouvez changer d'avis a tout moment dans" const PAGE_OPTIMIZATION_CHROME_FR_6 = "Vous pouvez changer davis a tout moment" @@ -90,9 +94,11 @@ class OCRChecker { console.log(result) if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) { return OCRResult.SUCCESS + } else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5)) { + return OCRResult.FILL_FIELD } else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) { return OCRResult.RECAPTCHA_ERROR - } else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR)) { + } else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR) || result.includes(BLOCKED_MSG_FR_2)) { return OCRResult.BLOCKED } else if (result.includes(ERR_CACHE_MISS) || result.includes(ERR_CACHE_MISS_2) || result.includes(ERR_CACHE_MISS_3) || result.includes(ERR_CACHE_MISS_4)) { return OCRResult.TO_REFRESH @@ -100,8 +106,6 @@ class OCRChecker { return OCRResult.RECHECK } else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4)) { return OCRResult.SLIDING_CAPTCHA - } else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2)) { - return OCRResult.FILL_FIELD } else if (result.includes(WELCOME_MESSAGE_FR)) { return OCRResult.NEED_TO_CLICK_LATE_BTN } else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {