diff --git a/clear_data.sh b/clear_data.sh index d0b2881..ac058a4 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -44,3 +44,27 @@ adb -s 926f2061 shell am start -n com.android.chrome/com.google.android.apps.chr adb -s 751005221815 shell pm clear com.android.chrome adb -s 751005221815 shell am set-debug-app --persistent com.android.chrome adb -s 751005221815 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/excel/ExcelUtil.js b/src/excel/ExcelUtil.js index 188e07b..343666e 100644 --- a/src/excel/ExcelUtil.js +++ b/src/excel/ExcelUtil.js @@ -4,9 +4,7 @@ const ContactPojo = require("../models/ContactPojo"); class ExcelUtil { readContacts() { - let workSheetsFromFile = xlsx.parse('C:/Users/lei/Desktop/contact_all.xlsx'); - console.log(workSheetsFromFile); - // return a list of contactPojo + let workSheetsFromFile = xlsx.parse('/Users/lpan/Desktop/contact_all.xlsx'); let contactList = []; workSheetsFromFile[0].data.forEach( (info, index, list) => { diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 8db904c..c28e3d8 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -3,8 +3,8 @@ const ReserveResultPojo = require("../models/ReserveResultPojo"); const appointmentLogger = require("../utiles/LoggerUtils") const PublishType = require("../models/PublishType"); const beep = require('beepbeep') -const RDV_URL = "http://192.168.0.44:8000/test_appointment.html" -// const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; +// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html" +const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; BLANK_URL = "about:blank" const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; @@ -42,7 +42,7 @@ function delay(delayInms) { } function getRandom() { - return Math.floor(Math.random() * 5); + return Math.floor(Math.random() * 3); } function getRandomWaitTime() { @@ -67,7 +67,7 @@ class CommandorPage { async loadPage() { // Connect to the device. log("loadPage() called"); - await this.device.shell('am force-stop com.android.chrome'); + // await this.device.shell('am force-stop com.android.chrome'); const context = await this.device.launchBrowser(); // await context.clearCookies() @@ -238,13 +238,19 @@ 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()) { - this.page.evaluate(() => { - document.getElementsByClassName("btn")[0].click(); - }) + try { + this.page.evaluate(() => { + document.getElementsByClassName("btn")[0].click(); + }) + } catch (e) { + console.log(e) + } } } } catch (e) { @@ -281,27 +287,31 @@ class CommandorPage { } async onPageLoad(currentPage) { - let content = await currentPage.content(); - let captcha_url = "geo.captcha-delivery.com/captcha"; + try { + let content = await currentPage.content(); + let captcha_url = "geo.captcha-delivery.com/captcha"; - if (content.toString().includes(captcha_url)) { - await this.checkAudioBtn(); - beep(20) - log("发现datadome"); - } else { - if (currentPage.url() === RDV_URL) { - await this.fillFields(this.page); - if (this.isFillingFields) - await this.getErrors() + 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)) { - 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) } }