From 183b4fc68b40a22bae624e514bb5e1a357d3576f Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 30 Jan 2023 16:36:43 +0100 Subject: [PATCH 01/25] try to add scheduler btn --- index.html | 16 +++++++++++++--- renderer.js | 7 +++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 15523f4..fc0df77 100644 --- a/index.html +++ b/index.html @@ -44,13 +44,23 @@
-
连接的手机
+
连接的设备

+
+
+ +
+ +
+ + +
+
-
diff --git a/renderer.js b/renderer.js index bd04efc..ebfb1b0 100644 --- a/renderer.js +++ b/renderer.js @@ -5,14 +5,17 @@ let selectedStore = 'random'; window.addEventListener('load', () => { window.appointment.scanDevices().then((deviceList) => { // Make the list - let listElement = document.getElementById('device_list'); + let deviceListSection = document.getElementById('device_list'); + let deviceNumberInfo = document.createElement("div") + deviceNumberInfo.innerHTML = "连接的设备数:" + deviceList.length; + deviceListSection.appendChild(deviceNumberInfo); for (i = 0; i < deviceList.length; ++i) { // Create an item for each one let listItem = document.createElement('li'); // Add the item text listItem.innerHTML = deviceList[i].join(" : "); // Add listItem to the listElement - listElement.appendChild(listItem); + deviceListSection.appendChild(listItem); } }) document.getElementById("start_book_btn").addEventListener('click', () => { From 957aba82e1a6add9950d026bad829662e327400b Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 31 Jan 2023 09:46:47 +0100 Subject: [PATCH 02/25] add scheduler btn --- main.js | 19 +++++++++++++++++- preload.js | 9 ++++++++- renderer.js | 6 ++++++ src/appointment.js | 49 +++++++++++++++++++++++++++------------------- 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/main.js b/main.js index 5f481f0..436ebb6 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,6 @@ const {app, BrowserWindow, ipcMain} = require('electron') const {_android: android} = require('playwright'); -const startBookWithNumbers = require('./src/appointment') +const {startBookWithNumbers, scheduleBookWithNumbers} = require('./src/appointment') const path = require("path"); const homedir = require('os').homedir(); const loadIniFile = require('read-ini-file') @@ -22,6 +22,9 @@ const createWindow = () => { ipcMain.on('start-book', (event, startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => { startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) }) + ipcMain.on('schedule-book', (event, startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => { + scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) + }) ipcMain.on('clearAllBrowsers', (event) => { clearAllBrowsers() }) @@ -83,6 +86,20 @@ function startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBee }) } +function scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) { + console.log("scheduleBook: " + startNumber); + console.log("endNumber: " + endNumber); + console.log("selectedStore: " + selectedStore); + console.log("audioAnalyse: " + audioAnalyse); + //load config.ini file + let config = loadIniFile.sync(configFilePath); + console.log(config); + let contactExcelFilePath = config.DEFAULT.contact_list_file; + scheduleBookWithNumbers(startNumber, endNumber, selectedStore, contactExcelFilePath, audioAnalyse, alertBeep).then(() => { + console.log("stop") + }) +} + async function scanDevices() { exec("adb devices ", (error, stdout, stderr) => { if (error) { diff --git a/preload.js b/preload.js index 565c766..bd4f43a 100644 --- a/preload.js +++ b/preload.js @@ -2,6 +2,13 @@ const {contextBridge, ipcRenderer} = require('electron') contextBridge.exposeInMainWorld('appointment', { startBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('start-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep), + scheduleBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('schedule-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep), clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'), scanDevices: () => ipcRenderer.invoke('scan-devices') -}) \ No newline at end of file +}) + +// contextBridge.exposeInMainWorld('appointment', { +// startBook: (startNumber, endNumber, selectedStore, audioAnalyse, alertBeep) => ipcRenderer.send('schedule-book', startNumber, endNumber, selectedStore, audioAnalyse, alertBeep), +// clearAllBrowsers: () => ipcRenderer.send('clearAllBrowsers'), +// scanDevices: () => ipcRenderer.invoke('scan-devices') +// }) \ No newline at end of file diff --git a/renderer.js b/renderer.js index ebfb1b0..2ad6c3c 100644 --- a/renderer.js +++ b/renderer.js @@ -24,6 +24,12 @@ window.addEventListener('load', () => { window.appointment.startBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep); }) + document.getElementById("scheduler_book_btn").addEventListener('click', () => { + let audioAnalyse = document.getElementById("audio_analyse").checked; + let alertBeep = document.getElementById("alert_beep").checked; + window.appointment.scheduleBook(startNumber, endNumber, selectedStore, audioAnalyse, alertBeep); + }) + document.getElementById("clear_all_browsers").addEventListener('click', () => { window.appointment.clearAllBrowsers(); }) diff --git a/src/appointment.js b/src/appointment.js index 2744fb7..796600d 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -3,6 +3,7 @@ const ExcelUtil = require("./excel/ExcelUtil"); const CommandorPage = require("./workers/CommandorPage"); const {MongoManager, formatDate} = require("./workers/mongo_manager"); const alert = require('alert'); +const schedule = require("node-schedule"); const mongoManager = new MongoManager(); const SEVEN_DAYS_IN_S = 3600 * 24 * 7; @@ -132,6 +133,14 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler }, Promise.resolve()); } +async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) { + console.log("scheduleBookWithNumbers() called") + schedule.scheduleJob('45 9 * * *', function () { + console.log("start startBookWithNumbers") + startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse = false, alertBeep = false) + }) +} + async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) { let allContactList = excelUtil.readContacts(pathToExcelFile); let contactList; @@ -145,27 +154,27 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT return } mongoManager.connect().then(r => { - filterAlreadyBookedContacts(contactList).then((listToBook)=>{ + filterAlreadyBookedContacts(contactList).then((listToBook) => { filterAlreadyAccepteddContacts(listToBook).then(notAcceptedContacts => { - filterBlacklistedContacts(notAcceptedContacts).then(listWithoutBlackContact => { - console.log("number of contacts to book:" + listWithoutBlackContact.length) - android.devices().then((devices) => { - if (devices.length === 0) { - alert("未找到连接的设备"); - return - } - let segmentNumber = listWithoutBlackContact.length / devices.length; - console.log("connected device number:" + devices.length) - console.log("segmentNumber:" + segmentNumber) - for (let i = 0; i < devices.length; i++) { - startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep); - } - }) + filterBlacklistedContacts(notAcceptedContacts).then(listWithoutBlackContact => { + console.log("number of contacts to book:" + listWithoutBlackContact.length) + android.devices().then((devices) => { + if (devices.length === 0) { + alert("未找到连接的设备"); + return + } + let segmentNumber = listWithoutBlackContact.length / devices.length; + console.log("connected device number:" + devices.length) + console.log("segmentNumber:" + segmentNumber) + for (let i = 0; i < devices.length; i++) { + startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep); + } }) - } - ) - }) - }); + }) + } + ) + }) + }); } -module.exports = startBookWithNumbers \ No newline at end of file +module.exports = {startBookWithNumbers, scheduleBookWithNumbers} \ No newline at end of file From 1ddb00afc2d845238efd51b7bf3b028b3ea9014c Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 31 Jan 2023 09:49:03 +0100 Subject: [PATCH 03/25] add scheduler btn --- src/appointment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appointment.js b/src/appointment.js index 796600d..96d4bb7 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -135,7 +135,7 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) { console.log("scheduleBookWithNumbers() called") - schedule.scheduleJob('45 9 * * *', function () { + schedule.scheduleJob('30 10 * * *', function () { console.log("start startBookWithNumbers") startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse = false, alertBeep = false) }) From 12ef28e8ce55d72b73f0998cd49674d33febf32d Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 6 Feb 2023 22:03:47 +0100 Subject: [PATCH 04/25] add script for macbook pro 13 --- start_avds_13.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 start_avds_13.sh diff --git a/start_avds_13.sh b/start_avds_13.sh new file mode 100644 index 0000000..2aacf69 --- /dev/null +++ b/start_avds_13.sh @@ -0,0 +1,4 @@ +emulator -avd Pixel_0 & +emulator -avd Pixel_1 & +emulator -avd Pixel_2 & +emulator -avd Pixel_3 & \ No newline at end of file From 35d9ded7e24d544276deadc30c5485f1e2f610bf Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 6 Feb 2023 22:23:01 +0100 Subject: [PATCH 05/25] clear last digit if necessary --- src/workers/GeoCaptchaSolver.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/workers/GeoCaptchaSolver.js b/src/workers/GeoCaptchaSolver.js index 0bb365c..3eaea56 100644 --- a/src/workers/GeoCaptchaSolver.js +++ b/src/workers/GeoCaptchaSolver.js @@ -10,6 +10,7 @@ const CAPTCHA_CONTAINER = "#captcha-container"; const WAV_URL_REGEX = "https:.+.wav"; const re = new RegExp(WAV_URL_REGEX); const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" + // const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" function delay(delayInMs) { @@ -66,6 +67,17 @@ class GeoCaptchaSolver { this.device = device; } + async clearLastDigit(iframeHandler) { + let selector = "#captcha__audio > div.audio-captcha-input-container > input:nth-child(" + 6 + ")" + let lastDigit = await iframeHandler.locator(selector).inputValue() + if (lastDigit !== "") { + console.log(this.device.model() + ":last digit is not empty, clear it") + await iframeHandler.locator(selector).fill("") + } else { + console.log(this.device.model() + ":last digit is empty, do nothing") + } + } + async solve(onResult) { console.log(this.device.model() + ":solve() called.") console.log(this.device.model() + ":play audio") @@ -89,6 +101,9 @@ class GeoCaptchaSolver { // console.log("selector is " + selector) try { await iframeHandler.locator(selector).focus() + if (i === 5) { + await this.clearLastDigit(iframeHandler) + } await iframeHandler.locator(selector).fill("" + number_list[i - 1]) } catch (e) { console.log(e) @@ -100,7 +115,7 @@ class GeoCaptchaSolver { try { let content = await captcha_container.innerHTML() - console.log("inner container is " + content) + console.log(this.device.model() + ":inner container is " + content) try { if (number_list.length === 0) { onResult(false) @@ -132,10 +147,10 @@ class GeoCaptchaSolver { let fileName = crypto.randomUUID() + ".wav"; wget({url: audioUrl, dest: dest_dir + fileName}, async function (error, response, body) { if (error) { - console.log('--- error:'); + console.log(this.device.model() + ':--- error:'); console.log(error); // error encountered } else { - console.log('download the file successfully'); + console.log(this.device.model() + ':download the file successfully'); // send request to get numbers await sendRequest(dest_dir + fileName, callback); } @@ -144,7 +159,7 @@ class GeoCaptchaSolver { } async resetBrowser() { - console.log("will reset browser") + console.log(this.device.model() + ":will reset browser") await this.device.shell("pm clear com.android.chrome") await delay(1000) await this.device.shell("am set-debug-app --persistent com.android.chrome") From 7bd9bf0fe66bd167ca4f679a05e721872833f120 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 6 Feb 2023 23:24:55 +0100 Subject: [PATCH 06/25] audio analyse by default --- src/appointment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/appointment.js b/src/appointment.js index 2744fb7..7a930c5 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -132,7 +132,7 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler }, Promise.resolve()); } -async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) { +async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) { let allContactList = excelUtil.readContacts(pathToExcelFile); let contactList; if (endNumber <= allContactList.length) { From f40b22837603bf5106f08a296ca9542f74655400 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Tue, 7 Feb 2023 12:52:42 +0100 Subject: [PATCH 07/25] correction --- src/workers/GeoCaptchaSolver.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/workers/GeoCaptchaSolver.js b/src/workers/GeoCaptchaSolver.js index 3eaea56..aef08b5 100644 --- a/src/workers/GeoCaptchaSolver.js +++ b/src/workers/GeoCaptchaSolver.js @@ -9,9 +9,9 @@ const AUDIO_CAPTCHA_TRACK = ".audio-captcha-track"; const CAPTCHA_CONTAINER = "#captcha-container"; const WAV_URL_REGEX = "https:.+.wav"; const re = new RegExp(WAV_URL_REGEX); -const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" +// const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" -// const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" +const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" function delay(delayInMs) { return new Promise(resolve => { @@ -147,10 +147,10 @@ class GeoCaptchaSolver { let fileName = crypto.randomUUID() + ".wav"; wget({url: audioUrl, dest: dest_dir + fileName}, async function (error, response, body) { if (error) { - console.log(this.device.model() + ':--- error:'); + console.log('--- error:'); console.log(error); // error encountered } else { - console.log(this.device.model() + ':download the file successfully'); + console.log('download the file successfully'); // send request to get numbers await sendRequest(dest_dir + fileName, callback); } From 2cb45af5b9139f9a694ff2a987d22520e52ca9fa Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 7 Feb 2023 20:30:50 +0100 Subject: [PATCH 08/25] add more devices --- clear_all_devices.js | 50 ++++++++++++++++++++++++ clear_data.sh | 91 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 clear_all_devices.js diff --git a/clear_all_devices.js b/clear_all_devices.js new file mode 100644 index 0000000..875198f --- /dev/null +++ b/clear_all_devices.js @@ -0,0 +1,50 @@ +const {_android: android} = require('playwright'); +const {exec} = require("child_process"); + +function delay(delayInMs) { + return new Promise(resolve => { + setTimeout(() => { + resolve(2); + }, delayInMs); + }); +} + +android.devices().then((devices) => { + devices.forEach((device) => { + console.log(device.serial() + ":will reset browser"); + exec("adb -s " + device.serial() + " shell pm clear com.android.chrome", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); + exec("adb -s " + device.serial() + " shell am set-debug-app --persistent com.android.chrome", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); + exec("adb -s " + device.serial() + " shell am start -n com.android.chrome/com.google.android.apps.chrome.Main", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); + }) + } +) diff --git a/clear_data.sh b/clear_data.sh index 14dd25a..7827296 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -175,4 +175,93 @@ adb -s emulator-5556 shell am start -n com.android.chrome/com.google.android.app #huawei mate 8 adb -s APU7N16321020182 shell pm clear com.android.chrome adb -s APU7N16321020182 shell am set-debug-app --persistent com.android.chrome -adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main +#1 +adb -s 2469c020930c7ece shell pm clear com.android.chrome +adb -s 2469c020930c7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2469c020930c7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#2 +adb -s 2890e299833f7ece shell pm clear com.android.chrome +adb -s 2890e299833f7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2890e299833f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#3 +adb -s 2890e6d52b3f7ece shell pm clear com.android.chrome +adb -s 2890e6d52b3f7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2890e6d52b3f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#4 +adb -s 3058394b4a393498 shell pm clear com.android.chrome +adb -s 3058394b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 3058394b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#5 +adb -s 3131315531523098 shell pm clear com.android.chrome +adb -s 3131315531523098 shell am set-debug-app --persistent com.android.chrome +adb -s 3131315531523098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#6 +adb -s 324d414b4a393498 shell pm clear com.android.chrome +adb -s 324d414b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 324d414b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#7 +adb -s 3452543639393498 shell pm clear com.android.chrome +adb -s 3452543639393498 shell am set-debug-app --persistent com.android.chrome +adb -s 3452543639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#8 +adb -s 34e8475c2e0b7ece shell pm clear com.android.chrome +adb -s 34e8475c2e0b7ece shell am set-debug-app --persistent com.android.chrome +adb -s 34e8475c2e0b7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#9 +adb -s 364f55374c4c3098 shell pm clear com.android.chrome +adb -s 364f55374c4c3098 shell am set-debug-app --persistent com.android.chrome +adb -s 364f55374c4c3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#10 +adb -s 374a4a4b4a393498 shell pm clear com.android.chrome +adb -s 374a4a4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 374a4a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#11 +adb -s 433954544a4a3098 shell pm clear com.android.chrome +adb -s 433954544a4a3098 shell am set-debug-app --persistent com.android.chrome +adb -s 433954544a4a3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#12 +adb -s 4347394655383098 shell pm clear com.android.chrome +adb -s 4347394655383098 shell am set-debug-app --persistent com.android.chrome +adb -s 4347394655383098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#13 +adb -s 4448465253313498 shell pm clear com.android.chrome +adb -s 4448465253313498 shell am set-debug-app --persistent com.android.chrome +adb -s 4448465253313498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#14 +adb -s 4653345154303098 shell pm clear com.android.chrome +adb -s 4653345154303098 shell am set-debug-app --persistent com.android.chrome +adb -s 4653345154303098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#15 +adb -s 4b504b4b4a393498 shell pm clear com.android.chrome +adb -s 4b504b4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 4b504b4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#16 +adb -s 53534a4b4a393498 shell pm clear com.android.chrome +adb -s 53534a4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 53534a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#17 +adb -s 5634563639393498 shell pm clear com.android.chrome +adb -s 5634563639393498 shell am set-debug-app --persistent com.android.chrome +adb -s 5634563639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s 344d395044413098 shell pm clear com.android.chrome +adb -s 344d395044413098 shell am set-debug-app --persistent com.android.chrome +adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From f00ff7f9bf9c6180c0dec9f126c82b2f496b4e29 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 7 Feb 2023 20:32:31 +0100 Subject: [PATCH 09/25] use speetch to text server --- src/workers/GeoCaptchaSolver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workers/GeoCaptchaSolver.js b/src/workers/GeoCaptchaSolver.js index aef08b5..8eba16f 100644 --- a/src/workers/GeoCaptchaSolver.js +++ b/src/workers/GeoCaptchaSolver.js @@ -9,9 +9,9 @@ const AUDIO_CAPTCHA_TRACK = ".audio-captcha-track"; const CAPTCHA_CONTAINER = "#captcha-container"; const WAV_URL_REGEX = "https:.+.wav"; const re = new RegExp(WAV_URL_REGEX); -// const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" +const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" -const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" +// const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" function delay(delayInMs) { return new Promise(resolve => { From 31f462721f01a1e675e2c0be18f7c75f70736458 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 7 Feb 2023 20:43:37 +0100 Subject: [PATCH 10/25] correction on the schedule --- src/appointment.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/appointment.js b/src/appointment.js index 83f5f5f..5992ba3 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -133,15 +133,17 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler }, Promise.resolve()); } -async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = false, alertBeep = false) { +async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) { console.log("scheduleBookWithNumbers() called") schedule.scheduleJob('30 10 * * *', function () { console.log("start startBookWithNumbers") - startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse = false, alertBeep = false) + startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse, alertBeep) }) } async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) { + console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep) + console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse) let allContactList = excelUtil.readContacts(pathToExcelFile); let contactList; if (endNumber <= allContactList.length) { From 4577a50d3456f14907dba7e46b841d9e90e6fee6 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 7 Feb 2023 20:50:35 +0100 Subject: [PATCH 11/25] add info alert --- src/appointment.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/appointment.js b/src/appointment.js index 5992ba3..14e32bf 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -135,6 +135,7 @@ async function startWithList(contacts, device, selectedStore, audioAnalyse, aler async function scheduleBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) { console.log("scheduleBookWithNumbers() called") + alert("定时成功") schedule.scheduleJob('30 10 * * *', function () { console.log("start startBookWithNumbers") startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile, audioAnalyse, alertBeep) From e38adb24bc30a47dffc64f37a4af52c35620b71d Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Fri, 10 Feb 2023 09:17:11 +0100 Subject: [PATCH 12/25] correction on the avds start --- start_avds.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/start_avds.sh b/start_avds.sh index cc95daa..5a927e8 100644 --- a/start_avds.sh +++ b/start_avds.sh @@ -6,4 +6,7 @@ emulator -avd Pixel_2_API_30_4 & emulator -avd Pixel_2_API_30_5 & emulator -avd Pixel_2_API_30_6 & emulator -avd Pixel_2_API_30_7 & -emulator -avd Pixel_2_API_30_8 & \ No newline at end of file +emulator -avd Pixel_2_API_30_8 & +emulator -avd Pixel_2_API_30_9 & +emulator -avd Pixel_2_API_30_10 & +emulator -avd Pixel_2_API_30_11 & \ No newline at end of file From 93b1c1ce8dbac6ddf3ddb0e31a017f10275dc616 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 10 Feb 2023 11:56:22 +0100 Subject: [PATCH 13/25] add more devices to bat --- clear_data.bat | 92 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/clear_data.bat b/clear_data.bat index f4d1012..871ee5e 100644 --- a/clear_data.bat +++ b/clear_data.bat @@ -245,4 +245,94 @@ adb -s 4b99c21 shell am start -n com.android.chrome/com.google.android.apps.chro #huawei mate 8 adb -s APU7N16321020182 shell pm clear com.android.chrome adb -s APU7N16321020182 shell am set-debug-app --persistent com.android.chrome -adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s APU7N16321020182 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#1 +adb -s 2469c020930c7ece shell pm clear com.android.chrome +adb -s 2469c020930c7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2469c020930c7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#2 +adb -s 2890e299833f7ece shell pm clear com.android.chrome +adb -s 2890e299833f7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2890e299833f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#3 +adb -s 2890e6d52b3f7ece shell pm clear com.android.chrome +adb -s 2890e6d52b3f7ece shell am set-debug-app --persistent com.android.chrome +adb -s 2890e6d52b3f7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#4 +adb -s 3058394b4a393498 shell pm clear com.android.chrome +adb -s 3058394b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 3058394b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#5 +adb -s 3131315531523098 shell pm clear com.android.chrome +adb -s 3131315531523098 shell am set-debug-app --persistent com.android.chrome +adb -s 3131315531523098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#6 +adb -s 324d414b4a393498 shell pm clear com.android.chrome +adb -s 324d414b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 324d414b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#7 +adb -s 3452543639393498 shell pm clear com.android.chrome +adb -s 3452543639393498 shell am set-debug-app --persistent com.android.chrome +adb -s 3452543639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#8 +adb -s 34e8475c2e0b7ece shell pm clear com.android.chrome +adb -s 34e8475c2e0b7ece shell am set-debug-app --persistent com.android.chrome +adb -s 34e8475c2e0b7ece shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#9 +adb -s 364f55374c4c3098 shell pm clear com.android.chrome +adb -s 364f55374c4c3098 shell am set-debug-app --persistent com.android.chrome +adb -s 364f55374c4c3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#10 +adb -s 374a4a4b4a393498 shell pm clear com.android.chrome +adb -s 374a4a4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 374a4a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#11 +adb -s 433954544a4a3098 shell pm clear com.android.chrome +adb -s 433954544a4a3098 shell am set-debug-app --persistent com.android.chrome +adb -s 433954544a4a3098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#12 +adb -s 4347394655383098 shell pm clear com.android.chrome +adb -s 4347394655383098 shell am set-debug-app --persistent com.android.chrome +adb -s 4347394655383098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#13 +adb -s 4448465253313498 shell pm clear com.android.chrome +adb -s 4448465253313498 shell am set-debug-app --persistent com.android.chrome +adb -s 4448465253313498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#14 +adb -s 4653345154303098 shell pm clear com.android.chrome +adb -s 4653345154303098 shell am set-debug-app --persistent com.android.chrome +adb -s 4653345154303098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#15 +adb -s 4b504b4b4a393498 shell pm clear com.android.chrome +adb -s 4b504b4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 4b504b4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#16 +adb -s 53534a4b4a393498 shell pm clear com.android.chrome +adb -s 53534a4b4a393498 shell am set-debug-app --persistent com.android.chrome +adb -s 53534a4b4a393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#17 +adb -s 5634563639393498 shell pm clear com.android.chrome +adb -s 5634563639393498 shell am set-debug-app --persistent com.android.chrome +adb -s 5634563639393498 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s 344d395044413098 shell pm clear com.android.chrome +adb -s 344d395044413098 shell am set-debug-app --persistent com.android.chrome +adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From a02db68b32ed0dc13556c9d2e7f0738a80463cf0 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Thu, 16 Feb 2023 10:12:37 +0100 Subject: [PATCH 14/25] add more devices --- clear_data.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clear_data.sh b/clear_data.sh index 7827296..7194a78 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -264,4 +264,15 @@ adb -s 5634563639393498 shell am start -n com.android.chrome/com.google.android. #18 adb -s 344d395044413098 shell pm clear com.android.chrome adb -s 344d395044413098 shell am set-debug-app --persistent com.android.chrome -adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s 344d395044413098 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5562 shell pm clear com.android.chrome +adb -s emulator-5562 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5562 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + + +#18 +adb -s emulator-5558 shell pm clear com.android.chrome +adb -s emulator-5558 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From c48254e98891ac06bc8919fced8f84334477bce6 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Feb 2023 10:43:12 +0100 Subject: [PATCH 15/25] fiter xiaomi and oneplus 6 --- clear_data.sh | 12 +++++++++++- src/appointment.js | 10 ++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/clear_data.sh b/clear_data.sh index 7194a78..2691889 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -275,4 +275,14 @@ adb -s emulator-5562 shell am start -n com.android.chrome/com.google.android.app #18 adb -s emulator-5558 shell pm clear com.android.chrome adb -s emulator-5558 shell am set-debug-app --persistent com.android.chrome -adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s 192.168.0.37:5555 shell pm clear com.android.chrome +adb -s 192.168.0.37:5555 shell am set-debug-app --persistent com.android.chrome +adb -s 192.168.0.37:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s 192.168.0.27:5555 shell pm clear com.android.chrome +adb -s 192.168.0.27:5555 shell am set-debug-app --persistent com.android.chrome +adb -s 192.168.0.27:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file diff --git a/src/appointment.js b/src/appointment.js index 14e32bf..0b902b1 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -10,6 +10,7 @@ const SEVEN_DAYS_IN_S = 3600 * 24 * 7; const THIRTY_DAYS_IN_S = 3600 * 24 * 30; let excelUtil = new ExcelUtil(); let collectionName = formatDate(new Date()) +device_to_excludes = ["47e7e36b", "e30eb015"] async function filterAlreadyBookedContacts(contactList) { let alreadyBookedContacts = await mongoManager.getAllSuccessfulItemsForDay(collectionName); @@ -166,11 +167,12 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT alert("未找到连接的设备"); return } - let segmentNumber = listWithoutBlackContact.length / devices.length; - console.log("connected device number:" + devices.length) + let filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial())) + let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length; + console.log("connected device number:" + filteredDeviceList.length) console.log("segmentNumber:" + segmentNumber) - for (let i = 0; i < devices.length; i++) { - startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), devices[i], selectedStore, audioAnalyse, alertBeep); + for (let i = 0; i < filteredDeviceList.length; i++) { + startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), filteredDeviceList[i], selectedStore, audioAnalyse, alertBeep); } }) }) From fefc021cbc93567973e017257b2b293814740944 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Feb 2023 12:11:00 +0100 Subject: [PATCH 16/25] add en language to search --- 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 16a7199..d657a30 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -95,7 +95,7 @@ class CommandorPage { }) try { const item = searchTexts[Math.floor(Math.random() * searchTexts.length)]; - await this.page.goto("https://www.google.com/search?q=" + item, {timeout: 90 * 1000}); + await this.page.goto("https://www.google.com/search?q=" + item+"&lr=lang_en", {timeout: 90 * 1000}); // await this.page.goto(RDV_URL, {timeout: 90 * 1000}); } catch (e) { log(e) From 48cae0d659d3138ad803a51cc5ee9384ace11a07 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Sat, 18 Feb 2023 12:12:22 +0100 Subject: [PATCH 17/25] more device --- clear_data.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clear_data.sh b/clear_data.sh index 7194a78..f903acb 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -275,4 +275,8 @@ adb -s emulator-5562 shell am start -n com.android.chrome/com.google.android.app #18 adb -s emulator-5558 shell pm clear com.android.chrome adb -s emulator-5558 shell am set-debug-app --persistent com.android.chrome -adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s emulator-5558 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +adb -s emulator-5560 shell pm clear com.android.chrome +adb -s emulator-5560 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file From 645803b09df148df36ed55367084c1a15548b90d Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Feb 2023 13:43:24 +0100 Subject: [PATCH 18/25] try to click on the 3ird btn --- src/workers/CommandorPage.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index d657a30..6eb2781 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -95,22 +95,24 @@ class CommandorPage { }) try { const item = searchTexts[Math.floor(Math.random() * searchTexts.length)]; - await this.page.goto("https://www.google.com/search?q=" + item+"&lr=lang_en", {timeout: 90 * 1000}); + await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 90 * 1000}); // await this.page.goto(RDV_URL, {timeout: 90 * 1000}); } catch (e) { log(e) this.isTerminated = true } try { - this.page.locator('button:has-text("Tout accepter")').click() - } catch (e) { - log(e) - } - try { - this.page.locator('button:has-text("Accept all")').click() + if (this.page.url().includes("google")) + this.page.locator('button >> nth=3').click() + // this.page.locator('button:has-text("Tout accepter")').click() } catch (e) { log(e) } + // try { + // this.page.locator('button:has-text("Accept all")').click() + // } catch (e) { + // log(e) + // } try { this.page.locator(':nth-match(:text("Online Appointment"), 1)').click() } catch (e) { From 3a736e3565e24c4d45a8dea5df9dec9fa2b5e2ba Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Feb 2023 13:49:37 +0100 Subject: [PATCH 19/25] reset browser when blocked by google --- src/workers/CommandorPage.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 6eb2781..a47377e 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -261,7 +261,6 @@ class CommandorPage { log(e); this.isTerminated = true; } - // await page.click(PREFER_STORE); } @@ -359,6 +358,8 @@ class CommandorPage { } } log("发现datadome"); + } else if (currentPage.url().includes("sorry")) { + await this.resetBrowser() } else { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); From 3ffc653f2cf20aa7c3c74b5af8e98c482eb01613 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 18 Feb 2023 13:59:00 +0100 Subject: [PATCH 20/25] specifiy the button --- 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 a47377e..63b16d6 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -114,7 +114,7 @@ class CommandorPage { // log(e) // } try { - this.page.locator(':nth-match(:text("Online Appointment"), 1)').click() + this.page.locator(':nth-match(:text("Paris Online Appointment"), 1)').click() } catch (e) { log(e) this.isTerminated = true From e4693a17b6ff66b1a577a3d577095017e4fc504e Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 20 Feb 2023 13:59:51 +0100 Subject: [PATCH 21/25] reset to "Online Appointment" --- 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 63b16d6..a47377e 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -114,7 +114,7 @@ class CommandorPage { // log(e) // } try { - this.page.locator(':nth-match(:text("Paris Online Appointment"), 1)').click() + this.page.locator(':nth-match(:text("Online Appointment"), 1)').click() } catch (e) { log(e) this.isTerminated = true From 5cae47ea4b315707b80982ad2fd43b57dd5e4c82 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Thu, 23 Feb 2023 11:19:19 +0100 Subject: [PATCH 22/25] wait 90 days for already accepted appointment --- src/appointment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/appointment.js b/src/appointment.js index 0b902b1..dbd69d1 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -7,7 +7,7 @@ const schedule = require("node-schedule"); const mongoManager = new MongoManager(); const SEVEN_DAYS_IN_S = 3600 * 24 * 7; -const THIRTY_DAYS_IN_S = 3600 * 24 * 30; +const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3; let excelUtil = new ExcelUtil(); let collectionName = formatDate(new Date()) device_to_excludes = ["47e7e36b", "e30eb015"] @@ -33,7 +33,7 @@ async function filterAlreadyAccepteddContacts(contactList) { console.log("=====handle already accepted item before booking===="); console.log("accepted_at is " + acceptedItem.accepted_at); console.log("accepted email is " + acceptedItem.email); - needToBook = acceptedItem.accepted_at + THIRTY_DAYS_IN_S <= (new Date()) / 1000; + needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000; if (!needToBook) { console.log("already accepted appointment --> skip"); } @@ -100,7 +100,7 @@ async function needToBook(contact, mongoManager) { console.log("=====handle already accepted item===="); console.log("accepted_at is " + acceptedItem.accepted_at); console.log("accepted email is " + acceptedItem.email); - needToBook = acceptedItem.accepted_at + THIRTY_DAYS_IN_S <= (new Date()) / 1000; + needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000; if (!needToBook) { console.log("already accepted appointment --> skip"); } From 98267286ab8bc1671cf373634390361604a80bc8 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Wed, 1 Mar 2023 09:31:23 +0100 Subject: [PATCH 23/25] improve the search --- clear_data.sh | 7 ++++++- src/workers/CommandorPage.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/clear_data.sh b/clear_data.sh index 2691889..882d583 100644 --- a/clear_data.sh +++ b/clear_data.sh @@ -285,4 +285,9 @@ adb -s 192.168.0.37:5555 shell am start -n com.android.chrome/com.google.android #18 adb -s 192.168.0.27:5555 shell pm clear com.android.chrome adb -s 192.168.0.27:5555 shell am set-debug-app --persistent com.android.chrome -adb -s 192.168.0.27:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file +adb -s 192.168.0.27:5555 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main + +#18 +adb -s emulator-5560 shell pm clear com.android.chrome +adb -s emulator-5560 shell am set-debug-app --persistent com.android.chrome +adb -s emulator-5560 shell am start -n com.android.chrome/com.google.android.apps.chrome.Main \ No newline at end of file diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index a47377e..f9ae6fd 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -36,7 +36,7 @@ const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again" const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué" const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+" const DEFAULT_STORE = 'faubourg'; -const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous', 'online+appointment+hermes', 'hermes+online+appointment'] +const searchTexts = ['hermes+rdv', 'hermes+rendezvous', 'hermes+appointment', 'hermes+appointment+online', 'appointment+hermes', 'hermes+rendez+vous','hermes+rendez+vous+paris', 'online+appointment+hermes', 'hermes+online+appointment', 'paris+hermes+online+appointment'] function delay(delayInMs) { return new Promise(resolve => { From c687b92c1c2a42dc23c02802f59bdbe6f932989f Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 6 Mar 2023 19:53:43 +0100 Subject: [PATCH 24/25] check recaptcha before calling 2captcha --- src/workers/CommandorPage.js | 44 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index f9ae6fd..0bdd8ad 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -7,7 +7,7 @@ const { shell } = require('electron') const GeoCaptchaSolver = require("./GeoCaptchaSolver"); -// const RDV_URL = "http://192.168.0.41:8000/test_appointment.html" +// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html" const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; const BLANK_URL = "about:blank" const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; @@ -312,27 +312,33 @@ class CommandorPage { await this.push_message_to_queue(PublishType.SUCCESS) return } - this.captchaSolver = new SolveCaptcha(page); - await this.captchaSolver.start((solution) => { - log("solution is: " + solution); - if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { - try { - if (!page.isClosed()) { - page.evaluate((solution) => { - let element = document.getElementById("g-recaptcha-response"); - if (element != null) - document.getElementById("g-recaptcha-response").innerHTML = solution; - }, solution) - this.clickValid(); + //check whether there is captcha + let hasCaptcha = await page.isVisible("g-recaptcha-response") + if (hasCaptcha) { + this.captchaSolver = new SolveCaptcha(page); + await this.captchaSolver.start((solution) => { + log("solution is: " + solution); + if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { + try { + if (!page.isClosed()) { + page.evaluate((solution) => { + let element = document.getElementById("g-recaptcha-response"); + if (element != null) + document.getElementById("g-recaptcha-response").innerHTML = solution; + }, solution) + this.clickValid(); + } + } catch (e) { + log(e) + this.isTerminated = true; } - } catch (e) { - log(e) + } else { this.isTerminated = true; } - } else { - this.isTerminated = true; - } - }) + }) + } else { + await this.clickValid(); + } } async isBlocked() { From b0064268678666b93161abd87356a0c150681f15 Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Mon, 6 Mar 2023 20:13:00 +0100 Subject: [PATCH 25/25] check recaptcha before calling 2captcha --- src/workers/CommandorPage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 0bdd8ad..e024bd9 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -7,7 +7,7 @@ const { shell } = require('electron') const GeoCaptchaSolver = require("./GeoCaptchaSolver"); -// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html" +// const RDV_URL = "http://192.168.0.13:8000/test_appointment.html"; const RDV_URL = "https://rendezvousparis.hermes.com/client/register"; const BLANK_URL = "about:blank" const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE"; @@ -313,7 +313,8 @@ class CommandorPage { return } //check whether there is captcha - let hasCaptcha = await page.isVisible("g-recaptcha-response") + let pageContent = await page.content() + let hasCaptcha = pageContent.includes("g-recaptcha-response") if (hasCaptcha) { this.captchaSolver = new SolveCaptcha(page); await this.captchaSolver.start((solution) => {