From d65c1742ff82714e475ee24006d83d9416397cb8 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Sun, 18 Sep 2022 13:35:58 +0200 Subject: [PATCH 1/6] reset to faubourg store --- src/excel/ExcelUtil.js | 2 +- src/workers/CommandorPage.js | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/excel/ExcelUtil.js b/src/excel/ExcelUtil.js index 188e07b..2796d5c 100644 --- a/src/excel/ExcelUtil.js +++ b/src/excel/ExcelUtil.js @@ -4,7 +4,7 @@ const ContactPojo = require("../models/ContactPojo"); class ExcelUtil { readContacts() { - let workSheetsFromFile = xlsx.parse('C:/Users/lei/Desktop/contact_all.xlsx'); + let workSheetsFromFile = xlsx.parse('/Users/panlei/Desktop/contact_all.xlsx'); console.log(workSheetsFromFile); // return a list of contactPojo let contactList = []; diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 5129a0f..e2d5c64 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); } From 6d1543570a1e40b064227d695130615ef417b05b Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 19 Sep 2022 20:57:39 +0200 Subject: [PATCH 2/6] print contact email --- src/appointment.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/appointment.js b/src/appointment.js index b40e6af..2c7a68c 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -64,12 +64,15 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT if (endNumber <= allContactList.length) { contactList = allContactList.slice(startNumber, endNumber); } else { - contactList = allContactList; + contactList = allContactList.slice(startNumber, allContactList.length); } if (contactList.length === 0) { alert("联系人数为0") return } + contactList.forEach((contact) => { + console.log(contact.mail) + }) mongoManager.connect().then(r => { filterAlreadyBookedContacts(contactList).then(listToBook => { console.log("number of contacts to book:" + listToBook.length) From b80385b21d771da073b6c253185a8a20f9e4db21 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 19 Sep 2022 21:24:14 +0200 Subject: [PATCH 3/6] add georgev or faubourg options --- index.html | 1 + src/appointment.js | 3 --- src/workers/CommandorPage.js | 7 +++++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 73d105c..0325943 100644 --- a/index.html +++ b/index.html @@ -29,6 +29,7 @@ diff --git a/src/appointment.js b/src/appointment.js index 2c7a68c..eff562e 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -70,9 +70,6 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT alert("联系人数为0") return } - contactList.forEach((contact) => { - console.log(contact.mail) - }) mongoManager.connect().then(r => { filterAlreadyBookedContacts(contactList).then(listToBook => { console.log("number of contacts to book:" + listToBook.length) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index d4b6795..8af7085 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -61,6 +61,7 @@ class CommandorPage { this.device = device; this.mongoManager = mongoManager; this.selectedStore = selectedStore; + this.choosedStore = selectedStore this.isFillingFields = false; this.isTerminated = false; } @@ -207,7 +208,9 @@ class CommandorPage { await page.locator(PREFER_STORE).focus() await delay(1000) await page.click(PREFER_STORE); - await page.selectOption(PREFER_STORE, this.selectedStore); + let stores = this.selectedStore.split(":") + this.choosedStore = stores[Math.floor(Math.random() * stores.length)] + await page.selectOption(PREFER_STORE, this.choosedStore); } } } catch (e) { @@ -347,7 +350,7 @@ class CommandorPage { return } // save to mongoDb - let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), 1, publishType); + let reserve = ReserveResultPojo.create_from_contact(this.contact, id, this.page.url(), this.choosedStore, publishType); reserve.source_from = this.device.model(); await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict()) this.isTerminated = true From f64f82c3e7046fbd56d658e98716d04e86ac6a99 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 20 Sep 2022 10:43:21 +0200 Subject: [PATCH 4/6] not click audio btn --- src/workers/CommandorPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 8af7085..c5b646e 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -327,7 +327,7 @@ class CommandorPage { let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button"); if (audioBtn) { log("audioBtn found") - audioBtn.click() + // audioBtn.click() } else { log("audioBtn not found") } From 4a342c3cf44c653aa503400a894ea1afaecba4c0 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Wed, 21 Sep 2022 23:39:49 +0200 Subject: [PATCH 5/6] add xiaomi tel --- clear_data.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clear_data.sh b/clear_data.sh index 86f813b..84fd01b 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -64,3 +64,8 @@ adb -s 774687ff shell am start -n com.android.chrome/com.google.android.apps.chr 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 + +#xiao mi +adb -s e08f0a85 shell pm clear com.android.chrome +adb -s e08f0a85 shell am set-debug-app --persistent com.android.chrome +adb -s e08f0a85 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main From 90227865802a5c1c89a9ca241d13181b066c765e Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Thu, 22 Sep 2022 21:58:24 +0200 Subject: [PATCH 6/6] add created_at field for ReserveResultPojo --- src/models/ReserveResultPojo.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/ReserveResultPojo.js b/src/models/ReserveResultPojo.js index b26f824..855a81b 100644 --- a/src/models/ReserveResultPojo.js +++ b/src/models/ReserveResultPojo.js @@ -13,6 +13,7 @@ class ReserveResultPojo { this.email = mail; this.type = type; this.source_from = "" + this.created_at = new Date().toLocaleString() } to_mongo_dict() { @@ -25,7 +26,8 @@ class ReserveResultPojo { passport: this.passportNumber, url: this.url, store_type: this.storeType, - source_from: this.source_from + source_from: this.source_from, + created_at: this.created_at } }