remove unused comments
This commit is contained in:
@@ -22,5 +22,6 @@ const OCRResult = {
|
||||
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
||||
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
||||
BRAVE_NOTIFICATION: Symbol("BRAVE_NOTIFICATION"),
|
||||
BRAVE_VPN_SKIP: Symbol("BRAVE_VPN_SKIP"),
|
||||
}
|
||||
module.exports = OCRResult
|
||||
@@ -92,6 +92,30 @@ class CommandorPage {
|
||||
this.firstStart = true;
|
||||
}
|
||||
|
||||
async getActivePage(browser, timeout) {
|
||||
const start = new Date().getTime();
|
||||
while (new Date().getTime() - start < timeout) {
|
||||
logWithDevice("get pages", this.device)
|
||||
let pages = await browser.pages();
|
||||
try {
|
||||
pages.forEach((currentPage) => {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
return currentPage;
|
||||
} else {
|
||||
try {
|
||||
currentPage.close()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
this.isTerminated = true;
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
throw "Unable to get active page";
|
||||
}
|
||||
|
||||
async connect_to_browser(ocrResult) {
|
||||
console.log("connect_to_browser() called");
|
||||
@@ -194,7 +218,6 @@ class CommandorPage {
|
||||
}
|
||||
} catch (e) {
|
||||
logWithDevice("failed to connect to device", this.device)
|
||||
|
||||
console.log(e)
|
||||
// await this.resetBrowser()
|
||||
await this.checkResultWithOcr()
|
||||
@@ -215,6 +238,7 @@ class CommandorPage {
|
||||
await this.acceptCookies();
|
||||
await this.enableDisableAirPlanMode();
|
||||
await delay(10 * 1000);
|
||||
// await this.checkResultWithOcr()
|
||||
await this.clickOnlineAppointment();
|
||||
} else {
|
||||
this.isTerminated = true;
|
||||
@@ -263,13 +287,8 @@ class CommandorPage {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
// if (this.page.url() === RDV_URL) {
|
||||
// if (!this.isFillingFields)
|
||||
// await this.fillFields(this.page, false);
|
||||
// }
|
||||
} catch (e) {
|
||||
log(e)
|
||||
console.log(e)
|
||||
await this.checkResultWithOcr();
|
||||
}
|
||||
}
|
||||
@@ -681,10 +700,11 @@ class CommandorPage {
|
||||
try {
|
||||
let content = await this.page.content();
|
||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||
if (content.toString().includes(captcha_url)) {
|
||||
await this.checkResultWithOcr()
|
||||
logWithDevice("发现datadome", this.device);
|
||||
} else if (content.includes("502 Bad Gateway")) {
|
||||
// if (content.toString().includes(captcha_url)) {
|
||||
// await this.checkResultWithOcr()
|
||||
// logWithDevice("发现datadome", this.device);
|
||||
// } else
|
||||
if (content.includes("502 Bad Gateway")) {
|
||||
logWithDevice("502 Bad Gateway found", this.device)
|
||||
await this.page.reload()
|
||||
} else if (this.page.url().includes("sorry")) {
|
||||
@@ -858,9 +878,14 @@ class CommandorPage {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async checkResultWithOcr() {
|
||||
logWithDevice("checkResultWithOcr() called.", this.device)
|
||||
await delay(4000);
|
||||
if (this.device.model() === "M2006C3LG")
|
||||
await delay(6000);
|
||||
else {
|
||||
await delay(4000);
|
||||
}
|
||||
let checkResult = await this.ocrChecker.get_result();
|
||||
console.log(checkResult);
|
||||
while (checkResult === OCRResult.RECHECK || checkResult === OCRResult.NO_INTERNET) {
|
||||
@@ -890,7 +915,6 @@ class CommandorPage {
|
||||
await this.connect_to_browser(checkResult)
|
||||
break;
|
||||
case OCRResult.FILL_FIELD:
|
||||
// console.log("browser.isConnected: " + this.browser.isConnected());
|
||||
if (this.browser === undefined || !this.browser.isConnected()) {
|
||||
logWithDevice("trying to connect to browser", this.device)
|
||||
try {
|
||||
@@ -935,8 +959,6 @@ class CommandorPage {
|
||||
logWithDevice("get pages", this.device)
|
||||
let pages = await this.browser.pages();
|
||||
logWithDevice("get current page", this.device)
|
||||
// let needPages = pages.filter(currentPage => currentPage.url() === RDV_URL)
|
||||
// this.page = needPages[0]
|
||||
try {
|
||||
pages.forEach((currentPage) => {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
@@ -999,10 +1021,11 @@ class CommandorPage {
|
||||
case OCRResult.BRAVE_PRIVACY:
|
||||
if (this.device.model() === "MI 5s") {
|
||||
await this.tapForDevice(this.device, 530, 970)
|
||||
// await this.device.shell("input tap " + 530 + " " + 970)
|
||||
} else if (this.device.model() === "ONEPLUS A6000")
|
||||
} else if (this.device.model() === "ONEPLUS A6000") {
|
||||
await this.device.shell("input tap " + 530 + " " + 1064)
|
||||
else if (this.device.model() === "KB2003" || this.device.model() === "DE2117") {
|
||||
} else if (this.device.model() === "M2006C3LG") {
|
||||
await this.tapForDevice(this.device, 350, 777)
|
||||
} else if (this.device.model() === "KB2003" || this.device.model() === "DE2117") {
|
||||
await this.tapForDevice(this.device, 500, 1200)
|
||||
await this.tapForDevice(this.device, 500, 1120)
|
||||
} else
|
||||
@@ -1035,6 +1058,12 @@ class CommandorPage {
|
||||
await delay(2000);
|
||||
await this.checkResultWithOcr();
|
||||
break;
|
||||
case OCRResult.BRAVE_VPN_SKIP:
|
||||
logWithDevice("BRAVE_VPN_SKIP", this.device)
|
||||
if (this.device.model() === "M2006C3LG") {
|
||||
await this.tapForDevice(this.device, 580, 445)
|
||||
}
|
||||
break;
|
||||
case OCRResult.TO_SKIP
|
||||
:
|
||||
logWithDevice("TO_SKIP", this.device)
|
||||
@@ -1120,6 +1149,8 @@ class CommandorPage {
|
||||
await this.device.shell("input tap " + 558 + " " + 1160)
|
||||
} else if (model === "MI 5s") {
|
||||
await this.tapForDevice(this.device, 530, 1000)
|
||||
} else if (model === "M2006C3LG") {
|
||||
await this.tapForDevice(this.device, 360, 777)
|
||||
} else if (model === "ONEPLUS A6000") {
|
||||
await this.device.shell("input tap " + 530 + " " + 1106)
|
||||
} else {
|
||||
@@ -1262,6 +1293,8 @@ class CommandorPage {
|
||||
await this.tapForDevice(this.device, 411, 2020)
|
||||
} else if (this.browserPackageName.includes("brave") && this.device.model() === "21091116C") {
|
||||
await this.tapForDevice(this.device, 411, 2020)
|
||||
} else if (this.browserPackageName.includes("brave") && this.device.model() === "M2006C3LG") {//redmi 9a
|
||||
await this.tapForDevice(this.device, 411, 1300)
|
||||
} else {
|
||||
await this.tapForDevice(this.device, 411, 2100)
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ const config = {
|
||||
psm: 3,
|
||||
}
|
||||
const NO_INTERNET_FR = "Aucun accés a Internet"
|
||||
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
||||
const MESSAGE_URL_VALIDATION_FR = "envoyé un lien par e-mail."
|
||||
const MESSAGE_URL_VALIDATION_FR_2 = "un lien par e-mail"
|
||||
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
||||
@@ -112,6 +113,10 @@ class OCRChecker {
|
||||
await this.deleteFile(fileName)
|
||||
await this.deleteFile(screenShot)
|
||||
return OCRResult.BRAVE_NOTIFICATION
|
||||
} else if (result.includes(BRAVE_VPN_SKIP)) {
|
||||
await this.deleteFile(fileName)
|
||||
await this.deleteFile(screenShot)
|
||||
return OCRResult.BRAVE_VPN_SKIP
|
||||
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5)) {
|
||||
await this.deleteFile(fileName)
|
||||
await this.deleteFile(screenShot)
|
||||
|
||||
Reference in New Issue
Block a user