diff --git a/src/models/OCRResult.js b/src/models/OCRResult.js index 44d2550..ab79b74 100644 --- a/src/models/OCRResult.js +++ b/src/models/OCRResult.js @@ -10,11 +10,16 @@ const OCRResult = { CONFIRM_RESEND_FORM: Symbol("CONFIRM_RESEND_FORM"), RECHECK: Symbol("RECHECK"), CLOSED: Symbol("CLOSED"), + CLOSE_PAGE: Symbol("CLOSE_PAGE"), TERMINAED: Symbol("TERMINAED"), GOOGLE_DISCONNECT: Symbol("GOOGLE_DISCONNECT"), TO_SKIP: Symbol("TO_SKIP"), RECAPTCHA_FAILED: Symbol("RECAPTCHA_FAILED"), RECAPTCHA_ERROR: Symbol("RECAPTCHA_ERROR"), NO_INTERNET: Symbol("NO_INTERNET"), + BRAVE_SKIP: Symbol("BRAVE_SKIP"), + BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"), + BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"), + BRAVE_NOTIFICATION: Symbol("BRAVE_NOTIFICATION"), } module.exports = OCRResult \ No newline at end of file diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 46f5daa..1c17373 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -107,6 +107,10 @@ class CommandorPage { // get url and push to server await this.push_message_to_queue(PublishType.SUCCESS) break; + case OCRResult.RECAPTCHA_ERROR: + // get url and push to server + await this.fillFields() + break; case OCRResult.TO_REFRESH: logWithDevice("will reload page", this.device) let cmd = "input swipe 382 682 382 1682" @@ -115,8 +119,6 @@ class CommandorPage { await delay(3000); await this.clickOnConfirmBtn(); await this.checkResultWithOcr(); - // } - // } break; } } @@ -486,14 +488,12 @@ class CommandorPage { } - async fillFields(page, airePlanMode) { + async fillFields(page) { logWithDevice("fillFields called for contact: " + this.contact.mail, this.device) logWithDevice("this.isFillingFields: " + this.isFillingFields, this.device); + logWithDevice("this.isTerminated: " + this.isTerminated, this.device); if (!this.isFillingFields && !this.isTerminated) { this.isFillingFields = true; - if (airePlanMode) { - // await this.enableDisableAirPlanMode(); - } await this.chooseStore(page); await this.inputName(page); await this.chooseCountry(page); @@ -640,9 +640,7 @@ class CommandorPage { await this.page.reload() } else { if (this.page.url() === RDV_URL) { - await this.fillFields(this.page, true); - // if (this.isFillingFields) - // await this.getErrors() + await this.fillFields(this.page); } else { if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { log("successful"); @@ -882,18 +880,37 @@ class CommandorPage { } break; case - OCRResult.RECAPTCHA_ERROR - : + OCRResult.RECAPTCHA_ERROR: this.isTerminated = true; + // await this.connect_to_browser(OCRResult.RECAPTCHA_ERROR) break; case - OCRResult.TO_SKIP + OCRResult.BRAVE_SKIP: + await this.handleBraveSkipBtn(); + await this.checkResultWithOcr(); + break; + case OCRResult.BRAVE_PRIVACY: + await this.device.shell("input tap " + 500 + " " + 1120) + await delay(2000); + await this.checkResultWithOcr(); + break; + case OCRResult.BRAVE_PRIVACY_PUB: + await this.device.shell("input tap " + 455 + " " + 1920) + await delay(2000); + await this.checkResultWithOcr(); + break; + case OCRResult.BRAVE_NOTIFICATION: + await this.device.shell("input tap " + 500 + " " + 1680) + await delay(2000); + await this.checkResultWithOcr(); + break; + case OCRResult.TO_SKIP : logWithDevice("TO_SKIP", this.device) if (this.device.model() === "21091116C") - this.device.shell("input tap " + 530 + " " + 1742) + await this.device.shell("input tap " + 530 + " " + 1742) else - this.device.shell("input tap " + 488 + " " + 1848) + await this.device.shell("input tap " + 488 + " " + 1848) await delay(2000); break; case @@ -928,11 +945,8 @@ class CommandorPage { OCRResult.GOOGLE_DISCONNECT : logWithDevice("GOOGLE_DISCONNECT", this.device) - if (this.device.model() === "MI 5s") { - this.device.shell("input tap " + 550 + " " + 1740) - } else - this.device.shell("input tap " + 411 + " " + 2100) - await delay(2000); + await this.tapGoogleDisconnectBtn() + await this.checkResultWithOcr(); break case @@ -969,6 +983,17 @@ class CommandorPage { } + async handleBraveSkipBtn() { + if (this.device.model() === "CPH2219") { + await this.device.shell("input tap " + 558 + " " + 1160) + } else { + await this.device.shell("input tap " + 470 + " " + 1160) + } + await delay(2000); + await this.device.shell("input tap " + 455 + " " + 1920) + await delay(1000); + } + async clickOnConfirmBtn() { if (this.device.model() === "CPH2219") { this.device.shell("input tap " + 900 + " " + 1532) @@ -1066,6 +1091,18 @@ class CommandorPage { console.log(e) } } + + async tapGoogleDisconnectBtn() { + if (this.device.model() === "MI 5s") { + if (this.browserPackageName.includes("brave")) + await this.device.shell("input tap " + 535 + " " + 1629) + + else + await this.device.shell("input tap " + 550 + " " + 1740) + } else + await this.device.shell("input tap " + 411 + " " + 2100) + await delay(2000); + } } module diff --git a/src/workers/OCRChecker.js b/src/workers/OCRChecker.js index e71f6eb..d0eac42 100644 --- a/src/workers/OCRChecker.js +++ b/src/workers/OCRChecker.js @@ -50,6 +50,14 @@ const DIALOG_TO_SKIP = "facilement les commandes" const ABOUT_BLANK = "about:blank" const GOOGLE_DISCONNECT_FR = "Rester déconnecté" const RECAPTCHA_FAILED_FR = "captcha a échoué" +const BRAVE_NOTIFICATION = "notifications Brave " +const BRAVE_SKIP_PUB = "Appuyez pour voir les boucliers" +const BRAVE_SKIP_PUB_2 = "aucune pubilicite" +const BRAVE_SKIP_PUB_3 = "aucune pubilicité" +const BRAVE_SKIP_PUB_4 = "aucune publicité" +const BRAVE_SKIP_DEFAULT_PAGE = "confidentialité de Brave" +const BRAVE_SKIP_DEFAULT_PAGE_2 = "définissant Brave" +const BRAVE_SKIP_PRIVACY_PAGE = "Partagez des informations" async function convertImageToWhiteBlack(image_path) { const image = await Jimp.read(image_path); @@ -114,8 +122,16 @@ class OCRChecker { return OCRResult.TO_SKIP } else if (result.includes(RECAPTCHA_FAILED_FR)) { return OCRResult.TERMINAED - }else if (result.includes(NO_INTERNET_FR)) { + } else if (result.includes(NO_INTERNET_FR)) { return OCRResult.NO_INTERNET + } else if (result.includes(BRAVE_SKIP_DEFAULT_PAGE) || result.includes(BRAVE_SKIP_DEFAULT_PAGE_2)) { + return OCRResult.BRAVE_SKIP + } else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE)) { + return OCRResult.BRAVE_PRIVACY + } else if (result.includes(BRAVE_NOTIFICATION)) { + return OCRResult.BRAVE_NOTIFICATION + } else if (result.includes(BRAVE_SKIP_PUB) || result.includes(BRAVE_SKIP_PUB_2) || result.includes(BRAVE_SKIP_PUB_3) || result.includes(BRAVE_SKIP_PUB_4)) { + return OCRResult.BRAVE_PRIVACY_PUB } else { return OCRResult.TERMINAED }