From 1f408cecdd27e212800fc7fa108f18fa9e5fa961 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 30 Jan 2023 16:37:55 +0100 Subject: [PATCH 1/8] add script to kill avds --- kill-avds.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 kill-avds.sh diff --git a/kill-avds.sh b/kill-avds.sh new file mode 100644 index 0000000..890cc5e --- /dev/null +++ b/kill-avds.sh @@ -0,0 +1 @@ +adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done \ No newline at end of file From bd77801e6a741c6d050e5c31681e354cc1f3d831 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Fri, 3 Feb 2023 12:17:22 +0100 Subject: [PATCH 2/8] user 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 fad9b43..0bb365c 100644 --- a/src/workers/GeoCaptchaSolver.js +++ b/src/workers/GeoCaptchaSolver.js @@ -9,8 +9,8 @@ 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://127.0.0.1:8000" +const SPEECH_TO_TEXT_HOST = "http://appointment.lpaconsulting.fr:8000" +// const SPEECH_TO_TEXT_HOST = "http://127.0.0.1:8000" function delay(delayInMs) { return new Promise(resolve => { From 12ef28e8ce55d72b73f0998cd49674d33febf32d Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Mon, 6 Feb 2023 22:03:47 +0100 Subject: [PATCH 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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 => {