use brave as browser
This commit is contained in:
@@ -10,11 +10,16 @@ const OCRResult = {
|
|||||||
CONFIRM_RESEND_FORM: Symbol("CONFIRM_RESEND_FORM"),
|
CONFIRM_RESEND_FORM: Symbol("CONFIRM_RESEND_FORM"),
|
||||||
RECHECK: Symbol("RECHECK"),
|
RECHECK: Symbol("RECHECK"),
|
||||||
CLOSED: Symbol("CLOSED"),
|
CLOSED: Symbol("CLOSED"),
|
||||||
|
CLOSE_PAGE: Symbol("CLOSE_PAGE"),
|
||||||
TERMINAED: Symbol("TERMINAED"),
|
TERMINAED: Symbol("TERMINAED"),
|
||||||
GOOGLE_DISCONNECT: Symbol("GOOGLE_DISCONNECT"),
|
GOOGLE_DISCONNECT: Symbol("GOOGLE_DISCONNECT"),
|
||||||
TO_SKIP: Symbol("TO_SKIP"),
|
TO_SKIP: Symbol("TO_SKIP"),
|
||||||
RECAPTCHA_FAILED: Symbol("RECAPTCHA_FAILED"),
|
RECAPTCHA_FAILED: Symbol("RECAPTCHA_FAILED"),
|
||||||
RECAPTCHA_ERROR: Symbol("RECAPTCHA_ERROR"),
|
RECAPTCHA_ERROR: Symbol("RECAPTCHA_ERROR"),
|
||||||
NO_INTERNET: Symbol("NO_INTERNET"),
|
NO_INTERNET: Symbol("NO_INTERNET"),
|
||||||
|
BRAVE_SKIP: Symbol("BRAVE_SKIP"),
|
||||||
|
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
||||||
|
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
||||||
|
BRAVE_NOTIFICATION: Symbol("BRAVE_NOTIFICATION"),
|
||||||
}
|
}
|
||||||
module.exports = OCRResult
|
module.exports = OCRResult
|
||||||
@@ -107,6 +107,10 @@ class CommandorPage {
|
|||||||
// get url and push to server
|
// get url and push to server
|
||||||
await this.push_message_to_queue(PublishType.SUCCESS)
|
await this.push_message_to_queue(PublishType.SUCCESS)
|
||||||
break;
|
break;
|
||||||
|
case OCRResult.RECAPTCHA_ERROR:
|
||||||
|
// get url and push to server
|
||||||
|
await this.fillFields()
|
||||||
|
break;
|
||||||
case OCRResult.TO_REFRESH:
|
case OCRResult.TO_REFRESH:
|
||||||
logWithDevice("will reload page", this.device)
|
logWithDevice("will reload page", this.device)
|
||||||
let cmd = "input swipe 382 682 382 1682"
|
let cmd = "input swipe 382 682 382 1682"
|
||||||
@@ -115,8 +119,6 @@ class CommandorPage {
|
|||||||
await delay(3000);
|
await delay(3000);
|
||||||
await this.clickOnConfirmBtn();
|
await this.clickOnConfirmBtn();
|
||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
// }
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -486,14 +488,12 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fillFields(page, airePlanMode) {
|
async fillFields(page) {
|
||||||
logWithDevice("fillFields called for contact: " + this.contact.mail, this.device)
|
logWithDevice("fillFields called for contact: " + this.contact.mail, this.device)
|
||||||
logWithDevice("this.isFillingFields: " + this.isFillingFields, this.device);
|
logWithDevice("this.isFillingFields: " + this.isFillingFields, this.device);
|
||||||
|
logWithDevice("this.isTerminated: " + this.isTerminated, this.device);
|
||||||
if (!this.isFillingFields && !this.isTerminated) {
|
if (!this.isFillingFields && !this.isTerminated) {
|
||||||
this.isFillingFields = true;
|
this.isFillingFields = true;
|
||||||
if (airePlanMode) {
|
|
||||||
// await this.enableDisableAirPlanMode();
|
|
||||||
}
|
|
||||||
await this.chooseStore(page);
|
await this.chooseStore(page);
|
||||||
await this.inputName(page);
|
await this.inputName(page);
|
||||||
await this.chooseCountry(page);
|
await this.chooseCountry(page);
|
||||||
@@ -640,9 +640,7 @@ class CommandorPage {
|
|||||||
await this.page.reload()
|
await this.page.reload()
|
||||||
} else {
|
} else {
|
||||||
if (this.page.url() === RDV_URL) {
|
if (this.page.url() === RDV_URL) {
|
||||||
await this.fillFields(this.page, true);
|
await this.fillFields(this.page);
|
||||||
// if (this.isFillingFields)
|
|
||||||
// await this.getErrors()
|
|
||||||
} else {
|
} else {
|
||||||
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
||||||
log("successful");
|
log("successful");
|
||||||
@@ -882,18 +880,37 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.RECAPTCHA_ERROR
|
OCRResult.RECAPTCHA_ERROR:
|
||||||
:
|
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
|
// await this.connect_to_browser(OCRResult.RECAPTCHA_ERROR)
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.TO_SKIP
|
OCRResult.BRAVE_SKIP:
|
||||||
|
await this.handleBraveSkipBtn();
|
||||||
|
await this.checkResultWithOcr();
|
||||||
|
break;
|
||||||
|
case OCRResult.BRAVE_PRIVACY:
|
||||||
|
await this.device.shell("input tap " + 500 + " " + 1120)
|
||||||
|
await delay(2000);
|
||||||
|
await this.checkResultWithOcr();
|
||||||
|
break;
|
||||||
|
case OCRResult.BRAVE_PRIVACY_PUB:
|
||||||
|
await this.device.shell("input tap " + 455 + " " + 1920)
|
||||||
|
await delay(2000);
|
||||||
|
await this.checkResultWithOcr();
|
||||||
|
break;
|
||||||
|
case OCRResult.BRAVE_NOTIFICATION:
|
||||||
|
await this.device.shell("input tap " + 500 + " " + 1680)
|
||||||
|
await delay(2000);
|
||||||
|
await this.checkResultWithOcr();
|
||||||
|
break;
|
||||||
|
case OCRResult.TO_SKIP
|
||||||
:
|
:
|
||||||
logWithDevice("TO_SKIP", this.device)
|
logWithDevice("TO_SKIP", this.device)
|
||||||
if (this.device.model() === "21091116C")
|
if (this.device.model() === "21091116C")
|
||||||
this.device.shell("input tap " + 530 + " " + 1742)
|
await this.device.shell("input tap " + 530 + " " + 1742)
|
||||||
else
|
else
|
||||||
this.device.shell("input tap " + 488 + " " + 1848)
|
await this.device.shell("input tap " + 488 + " " + 1848)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
@@ -928,11 +945,8 @@ class CommandorPage {
|
|||||||
OCRResult.GOOGLE_DISCONNECT
|
OCRResult.GOOGLE_DISCONNECT
|
||||||
:
|
:
|
||||||
logWithDevice("GOOGLE_DISCONNECT", this.device)
|
logWithDevice("GOOGLE_DISCONNECT", this.device)
|
||||||
if (this.device.model() === "MI 5s") {
|
await this.tapGoogleDisconnectBtn()
|
||||||
this.device.shell("input tap " + 550 + " " + 1740)
|
|
||||||
} else
|
|
||||||
this.device.shell("input tap " + 411 + " " + 2100)
|
|
||||||
await delay(2000);
|
|
||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break
|
break
|
||||||
case
|
case
|
||||||
@@ -969,6 +983,17 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async handleBraveSkipBtn() {
|
||||||
|
if (this.device.model() === "CPH2219") {
|
||||||
|
await this.device.shell("input tap " + 558 + " " + 1160)
|
||||||
|
} else {
|
||||||
|
await this.device.shell("input tap " + 470 + " " + 1160)
|
||||||
|
}
|
||||||
|
await delay(2000);
|
||||||
|
await this.device.shell("input tap " + 455 + " " + 1920)
|
||||||
|
await delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
async clickOnConfirmBtn() {
|
async clickOnConfirmBtn() {
|
||||||
if (this.device.model() === "CPH2219") {
|
if (this.device.model() === "CPH2219") {
|
||||||
this.device.shell("input tap " + 900 + " " + 1532)
|
this.device.shell("input tap " + 900 + " " + 1532)
|
||||||
@@ -1066,6 +1091,18 @@ class CommandorPage {
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async tapGoogleDisconnectBtn() {
|
||||||
|
if (this.device.model() === "MI 5s") {
|
||||||
|
if (this.browserPackageName.includes("brave"))
|
||||||
|
await this.device.shell("input tap " + 535 + " " + 1629)
|
||||||
|
|
||||||
|
else
|
||||||
|
await this.device.shell("input tap " + 550 + " " + 1740)
|
||||||
|
} else
|
||||||
|
await this.device.shell("input tap " + 411 + " " + 2100)
|
||||||
|
await delay(2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module
|
module
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ const DIALOG_TO_SKIP = "facilement les commandes"
|
|||||||
const ABOUT_BLANK = "about:blank"
|
const ABOUT_BLANK = "about:blank"
|
||||||
const GOOGLE_DISCONNECT_FR = "Rester déconnecté"
|
const GOOGLE_DISCONNECT_FR = "Rester déconnecté"
|
||||||
const RECAPTCHA_FAILED_FR = "captcha a échoué"
|
const RECAPTCHA_FAILED_FR = "captcha a échoué"
|
||||||
|
const BRAVE_NOTIFICATION = "notifications Brave "
|
||||||
|
const BRAVE_SKIP_PUB = "Appuyez pour voir les boucliers"
|
||||||
|
const BRAVE_SKIP_PUB_2 = "aucune pubilicite"
|
||||||
|
const BRAVE_SKIP_PUB_3 = "aucune pubilicité"
|
||||||
|
const BRAVE_SKIP_PUB_4 = "aucune publicité"
|
||||||
|
const BRAVE_SKIP_DEFAULT_PAGE = "confidentialité de Brave"
|
||||||
|
const BRAVE_SKIP_DEFAULT_PAGE_2 = "définissant Brave"
|
||||||
|
const BRAVE_SKIP_PRIVACY_PAGE = "Partagez des informations"
|
||||||
|
|
||||||
async function convertImageToWhiteBlack(image_path) {
|
async function convertImageToWhiteBlack(image_path) {
|
||||||
const image = await Jimp.read(image_path);
|
const image = await Jimp.read(image_path);
|
||||||
@@ -114,8 +122,16 @@ class OCRChecker {
|
|||||||
return OCRResult.TO_SKIP
|
return OCRResult.TO_SKIP
|
||||||
} else if (result.includes(RECAPTCHA_FAILED_FR)) {
|
} else if (result.includes(RECAPTCHA_FAILED_FR)) {
|
||||||
return OCRResult.TERMINAED
|
return OCRResult.TERMINAED
|
||||||
}else if (result.includes(NO_INTERNET_FR)) {
|
} else if (result.includes(NO_INTERNET_FR)) {
|
||||||
return OCRResult.NO_INTERNET
|
return OCRResult.NO_INTERNET
|
||||||
|
} else if (result.includes(BRAVE_SKIP_DEFAULT_PAGE) || result.includes(BRAVE_SKIP_DEFAULT_PAGE_2)) {
|
||||||
|
return OCRResult.BRAVE_SKIP
|
||||||
|
} else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE)) {
|
||||||
|
return OCRResult.BRAVE_PRIVACY
|
||||||
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
|
return OCRResult.BRAVE_NOTIFICATION
|
||||||
|
} else if (result.includes(BRAVE_SKIP_PUB) || result.includes(BRAVE_SKIP_PUB_2) || result.includes(BRAVE_SKIP_PUB_3) || result.includes(BRAVE_SKIP_PUB_4)) {
|
||||||
|
return OCRResult.BRAVE_PRIVACY_PUB
|
||||||
} else {
|
} else {
|
||||||
return OCRResult.TERMINAED
|
return OCRResult.TERMINAED
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user