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