clear last digit if necessary
This commit is contained in:
@@ -10,6 +10,7 @@ const CAPTCHA_CONTAINER = "#captcha-container";
|
|||||||
const WAV_URL_REGEX = "https:.+.wav";
|
const WAV_URL_REGEX = "https:.+.wav";
|
||||||
const re = new RegExp(WAV_URL_REGEX);
|
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) {
|
function delay(delayInMs) {
|
||||||
@@ -66,6 +67,17 @@ class GeoCaptchaSolver {
|
|||||||
this.device = device;
|
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) {
|
async solve(onResult) {
|
||||||
console.log(this.device.model() + ":solve() called.")
|
console.log(this.device.model() + ":solve() called.")
|
||||||
console.log(this.device.model() + ":play audio")
|
console.log(this.device.model() + ":play audio")
|
||||||
@@ -89,6 +101,9 @@ class GeoCaptchaSolver {
|
|||||||
// console.log("selector is " + selector)
|
// console.log("selector is " + selector)
|
||||||
try {
|
try {
|
||||||
await iframeHandler.locator(selector).focus()
|
await iframeHandler.locator(selector).focus()
|
||||||
|
if (i === 5) {
|
||||||
|
await this.clearLastDigit(iframeHandler)
|
||||||
|
}
|
||||||
await iframeHandler.locator(selector).fill("" + number_list[i - 1])
|
await iframeHandler.locator(selector).fill("" + number_list[i - 1])
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -100,7 +115,7 @@ class GeoCaptchaSolver {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
let content = await captcha_container.innerHTML()
|
let content = await captcha_container.innerHTML()
|
||||||
console.log("inner container is " + content)
|
console.log(this.device.model() + ":inner container is " + content)
|
||||||
try {
|
try {
|
||||||
if (number_list.length === 0) {
|
if (number_list.length === 0) {
|
||||||
onResult(false)
|
onResult(false)
|
||||||
@@ -132,10 +147,10 @@ class GeoCaptchaSolver {
|
|||||||
let fileName = crypto.randomUUID() + ".wav";
|
let fileName = crypto.randomUUID() + ".wav";
|
||||||
wget({url: audioUrl, dest: dest_dir + fileName}, async function (error, response, body) {
|
wget({url: audioUrl, dest: dest_dir + fileName}, async function (error, response, body) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log('--- error:');
|
console.log(this.device.model() + ':--- error:');
|
||||||
console.log(error); // error encountered
|
console.log(error); // error encountered
|
||||||
} else {
|
} else {
|
||||||
console.log('download the file successfully');
|
console.log(this.device.model() + ':download the file successfully');
|
||||||
// send request to get numbers
|
// send request to get numbers
|
||||||
await sendRequest(dest_dir + fileName, callback);
|
await sendRequest(dest_dir + fileName, callback);
|
||||||
}
|
}
|
||||||
@@ -144,7 +159,7 @@ class GeoCaptchaSolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async resetBrowser() {
|
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 this.device.shell("pm clear com.android.chrome")
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
await this.device.shell("am set-debug-app --persistent com.android.chrome")
|
await this.device.shell("am set-debug-app --persistent com.android.chrome")
|
||||||
|
|||||||
Reference in New Issue
Block a user