From 343449b17c5281df87934e490ab744d4a85fda82 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Tue, 18 Jul 2023 16:20:08 +0200 Subject: [PATCH] adapt oppo --- src/workers/CommandorPage.js | 30 ++++++++++++++++-------------- src/workers/OCRChecker.js | 6 ++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 1fa509a..0e7de42 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -707,7 +707,7 @@ class CommandorPage { } // save to mongoDb let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType); - reserve.source_from = this.device.serial(); + reserve.source_from = this.device.model(); await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict()) await this.page.close(); // await this.deleteFromBlackList() @@ -833,11 +833,13 @@ class CommandorPage { logWithDevice("get pages", this.device) let pages = await this.browser.pages(); - pages.forEach((currentPage) => { - if (currentPage.url() === RDV_URL) { - this.page = currentPage; - } - }) + let needPages = pages.filter(currentPage => currentPage.url() === RDV_URL) + this.page = needPages[0] + // pages.forEach((currentPage) => { + // if (currentPage.url() === RDV_URL) { + // this.page = currentPage; + // } + // }) logWithDevice("this.page.bringToFront();", this.device) await this.page.bringToFront(); @@ -856,11 +858,8 @@ class CommandorPage { logWithDevice("get pages", this.device) let pages = await this.browser.pages(); logWithDevice("get current page", this.device) - pages.forEach((currentPage) => { - if (currentPage.url() === RDV_URL) { - this.page = currentPage; - } - }) + let needPages = pages.filter(currentPage => currentPage.url() === RDV_URL) + this.page = needPages[0] logWithDevice("this.page.bringToFront();", this.device) await this.page.bringToFront(); // this.page = pages; @@ -1120,11 +1119,14 @@ class CommandorPage { 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) + } else { + if (this.browserPackageName.includes("brave") && this.device.model() === "CPH2219") { + await this.device.shell("input tap " + 411 + " " + 1977) + } else + await this.device.shell("input tap " + 411 + " " + 2100) + } await delay(2000); } } diff --git a/src/workers/OCRChecker.js b/src/workers/OCRChecker.js index 8579e61..47818a4 100644 --- a/src/workers/OCRChecker.js +++ b/src/workers/OCRChecker.js @@ -32,6 +32,7 @@ const ERR_CACHE_MISS_4 = "renvoyer les données" const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification" 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 WELCOME_MESSAGE_FR = "Bienvenue dans Chrome" @@ -48,6 +49,7 @@ const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi" const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans" const DIALOG_TO_SKIP = "facilement les commandes" const ABOUT_BLANK = "about:blank" +const GOOGLE_DISCONNECT_FR_1 = "Connectez-vous a Google" const GOOGLE_DISCONNECT_FR = "Rester déconnecté" const RECAPTCHA_FAILED_FR = "captcha a échoué" const BRAVE_NOTIFICATION = "notifications Brave " @@ -96,13 +98,13 @@ class OCRChecker { return OCRResult.TO_REFRESH } else if (result.includes(CHECKING_MSG_FR)) { return OCRResult.RECHECK - } else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3)) { + } 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)) { + } else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) { return OCRResult.GOOGLE_DISCONNECT } else if (result.toLowerCase().includes(ONLINE_APPOINTMENT.toLowerCase())) { return OCRResult.ONLINE_APPOINTMENT