can reset browser
This commit is contained in:
@@ -331,7 +331,7 @@ class CommandorPage {
|
|||||||
if (audioBtn) {
|
if (audioBtn) {
|
||||||
log("audioBtn found")
|
log("audioBtn found")
|
||||||
audioBtn.click()
|
audioBtn.click()
|
||||||
let captchaSolver = new GeoCaptchaSolver(this.page)
|
let captchaSolver = new GeoCaptchaSolver(this.page, this.device)
|
||||||
await captchaSolver.solve((isSuccessful) => {
|
await captchaSolver.solve((isSuccessful) => {
|
||||||
if (!isSuccessful) {
|
if (!isSuccessful) {
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
|
|||||||
@@ -51,10 +51,11 @@ async function sendRequest(fileName, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GeoCaptchaSolver {
|
class GeoCaptchaSolver {
|
||||||
constructor(page) {
|
constructor(page, device) {
|
||||||
this.page = page;
|
this.page = page;
|
||||||
|
this.device = device;
|
||||||
}
|
}
|
||||||
|
|
||||||
async solve(onResult) {
|
async solve(onResult) {
|
||||||
console.log("solve() called.")
|
console.log("solve() called.")
|
||||||
console.log("play audio")
|
console.log("play audio")
|
||||||
@@ -65,23 +66,28 @@ class GeoCaptchaSolver {
|
|||||||
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
|
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
|
||||||
let html = await captcha_container.innerHTML()
|
let html = await captcha_container.innerHTML()
|
||||||
console.log("audio_tag: " + html);
|
console.log("audio_tag: " + html);
|
||||||
// find wav from html
|
if (!html.includes("You have been blocked")) {
|
||||||
await this.findTextFromWavFile(html, async (number_list) => {
|
// find wav from html
|
||||||
for (let i = 1; i <= number_list.length; i++) {
|
await this.findTextFromWavFile(html, async (number_list) => {
|
||||||
let selector = "#captcha__audio > div.audio-captcha-input-container > input:nth-child(" + i + ")"
|
for (let i = 1; i <= number_list.length; i++) {
|
||||||
// console.log("selector is " + selector)
|
let selector = "#captcha__audio > div.audio-captcha-input-container > input:nth-child(" + i + ")"
|
||||||
await iframeHandler.locator(selector).focus()
|
// console.log("selector is " + selector)
|
||||||
await iframeHandler.locator(selector).fill("" + number_list[i - 1])
|
await iframeHandler.locator(selector).focus()
|
||||||
// fieldInputs[i].value = number_list[i];
|
await iframeHandler.locator(selector).fill("" + number_list[i - 1])
|
||||||
await delay(2000 + getRandomWaitTime());
|
// fieldInputs[i].value = number_list[i];
|
||||||
|
await delay(2000 + getRandomWaitTime());
|
||||||
|
}
|
||||||
|
if (number_list.isEmpty()) {
|
||||||
|
onResult(false)
|
||||||
|
} else {
|
||||||
|
onResult(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (number_list.isEmpty()) {
|
)
|
||||||
onResult(false)
|
} else {
|
||||||
} else {
|
await this.resetBrowser()
|
||||||
onResult(true)
|
onResult(false)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async findTextFromWavFile(html, callback) {
|
async findTextFromWavFile(html, callback) {
|
||||||
@@ -104,6 +110,16 @@ class GeoCaptchaSolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetBrowser() {
|
||||||
|
console.log("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")
|
||||||
|
await delay(1000)
|
||||||
|
await this.device.shell("pm am start -n com.android.chrome/com.google.android.apps.chrome.Main")
|
||||||
|
await delay(1000)
|
||||||
|
this.isTerminated = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user