From 726e4244dc734fc1783a042e11239ba71b3514bf Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Fri, 16 Sep 2022 23:29:12 +0200 Subject: [PATCH 1/3] set to random store and try catch --- src/workers/CommandorPage.js | 60 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 0127c47..6add8c0 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -192,17 +192,17 @@ class CommandorPage { } async chooseStore(page) { - try { - if (!page.isClosed()) { - await page.locator(PREFER_STORE).focus() - await delay(1000) - await page.click(PREFER_STORE); - await page.selectOption(PREFER_STORE, "faubourg"); - } - } catch (e) { - console.log(e); - this.isTerminated = true; - } + // try { + // if (!page.isClosed()) { + // await page.locator(PREFER_STORE).focus() + // await delay(1000) + // await page.click(PREFER_STORE); + // await page.selectOption(PREFER_STORE, "faubourg"); + // } + // } catch (e) { + // console.log(e); + // this.isTerminated = true; + // } // await page.click(PREFER_STORE); } @@ -272,27 +272,33 @@ class CommandorPage { } async onPageLoad(currentPage) { - let content = await currentPage.content(); - let captcha_url = "geo.captcha-delivery.com/captcha"; + try { - if (content.toString().includes(captcha_url)) { - await this.checkAudioBtn(); - beep(20) - console.log("发现datadome"); - } else { - if (currentPage.url() === RDV_URL) { - await this.fillFields(this.page); - if (this.isFillingFields) - await this.getErrors() + + let content = await currentPage.content(); + let captcha_url = "geo.captcha-delivery.com/captcha"; + + if (content.toString().includes(captcha_url)) { + await this.checkAudioBtn(); + beep(20) + console.log("发现datadome"); } else { - if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { - console.log("successful"); - await this.push_message_to_queue(PublishType.SUCCESS); + if (currentPage.url() === RDV_URL) { + await this.fillFields(this.page); + if (this.isFillingFields) + await this.getErrors() } else { - // try to get errors - await this.getErrors() + if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) { + console.log("successful"); + await this.push_message_to_queue(PublishType.SUCCESS); + } else { + // try to get errors + await this.getErrors() + } } } + } catch (e) { + console.log(e) } } From f822cd455c2b3109ca0bc47247aff1464172bc33 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Sat, 17 Sep 2022 15:35:30 +0200 Subject: [PATCH 2/3] set to random store and try catch --- clear_data.sh | 24 ++++++++++++++++++++++++ src/workers/CommandorPage.js | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/clear_data.sh b/clear_data.sh index 485417d..86f813b 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -40,3 +40,27 @@ adb -s d54e946 shell am start -n com.android.chrome/com.google.android.apps.chro adb -s 926f2061 shell pm clear com.android.chrome adb -s 926f2061 shell am set-debug-app --persistent com.android.chrome adb -s 926f2061 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +#samsung J5 - 2016 +adb -s 4f55c3d4 shell pm clear com.android.chrome +adb -s 4f55c3d4 shell am set-debug-app --persistent com.android.chrome +adb -s 4f55c3d4 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#samsung J5 - 2016 +adb -s 69db59f0 shell pm clear com.android.chrome +adb -s 69db59f0 shell am set-debug-app --persistent com.android.chrome +adb -s 69db59f0 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#samsung J5 - 2016 +adb -s 6c3076e6 shell pm clear com.android.chrome +adb -s 6c3076e6 shell am set-debug-app --persistent com.android.chrome +adb -s 6c3076e6 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#samsung J5 - 2016 +adb -s 774687ff shell pm clear com.android.chrome +adb -s 774687ff shell am set-debug-app --persistent com.android.chrome +adb -s 774687ff shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#samsung J5 - 2016 +adb -s ffa9b2bc shell pm clear com.android.chrome +adb -s ffa9b2bc shell am set-debug-app --persistent com.android.chrome +adb -s ffa9b2bc shell am start -n com.android.chrome/com.google.android.apps.chrome.Main diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 6add8c0..314da99 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -229,7 +229,9 @@ class CommandorPage { try { if (!this.page.isClosed()) { this.page.evaluate(() => { - document.getElementsByClassName("btn")[0].focus(); + let element = document.getElementsByClassName("btn")[0]; + if (typeof element !== 'undefined') + document.getElementsByClassName("btn")[0].focus(); }) await delay(getRandomWaitTime()) if (!this.page.isClosed()) { From 02a62c3b753538be1f79959a1a4358dc5667c74d Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 17 Sep 2022 15:39:53 +0200 Subject: [PATCH 3/3] reduce the random wait time --- src/workers/CommandorPage.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 314da99..5129a0f 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -41,7 +41,7 @@ function delay(delayInms) { } function getRandom() { - return Math.floor(Math.random() * 5); + return Math.floor(Math.random() * 3); } function getRandomWaitTime() { @@ -235,9 +235,13 @@ class CommandorPage { }) await delay(getRandomWaitTime()) if (!this.page.isClosed()) { - this.page.evaluate(() => { - document.getElementsByClassName("btn")[0].click(); - }) + try { + this.page.evaluate(() => { + document.getElementsByClassName("btn")[0].click(); + }) + } catch (e) { + console.log(e) + } } } } catch (e) {