Merge branch 'master' into feature/macOcr
This commit is contained in:
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
"node-tesseract-ocr": "^2.2.1",
|
"node-tesseract-ocr": "^2.2.1",
|
||||||
"node-wget": "^0.4.3",
|
"node-wget": "^0.4.3",
|
||||||
"node-xlsx": "^0.21.0",
|
"node-xlsx": "^0.21.0",
|
||||||
"playwright": "^1.32.1",
|
"playwright": "^1.39.0",
|
||||||
"puppeteer": "^15.5.0",
|
"puppeteer": "^15.5.0",
|
||||||
"read-ini-file": "^3.0.1",
|
"read-ini-file": "^3.0.1",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
|
|||||||
+19
-18
@@ -16,7 +16,7 @@ let excludeMode = DeviceExcludeMode.SIX
|
|||||||
let three_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
let three_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||||
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518"]
|
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518"]
|
||||||
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h"]
|
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h", "07fbd156"]
|
||||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518", "W8GMFELRHIKZS84T"]
|
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518", "W8GMFELRHIKZS84T"]
|
||||||
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "e30eb015", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "e30eb015", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
||||||
attributedPorts = []
|
attributedPorts = []
|
||||||
@@ -80,12 +80,12 @@ async function filterBlacklistedContacts(contactList) {
|
|||||||
return contactsToBook;
|
return contactsToBook;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function needToBook(contact, mongoManager) {
|
async function needToBook(contact, mongoManager, alreadyBooked) {
|
||||||
console.log("check contact with email " + contact.mail)
|
console.log("check contact with email " + contact.mail)
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
// let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
// let blackListItems = await mongoManager.getAllBlackedListItems();
|
// let blackListItems = await mongoManager.getAllBlackedListItems();
|
||||||
let blackListItems = [];
|
let blackListItems = [];
|
||||||
let alreadyAcceptedItems = await mongoManager.getAllAcceptedAppointments();
|
// let alreadyAcceptedItems = await mongoManager.getAllAcceptedAppointments();
|
||||||
let needToBook = true;
|
let needToBook = true;
|
||||||
await alreadyBooked.forEach((bookedItem) => {
|
await alreadyBooked.forEach((bookedItem) => {
|
||||||
if (bookedItem.email === contact.mail) {
|
if (bookedItem.email === contact.mail) {
|
||||||
@@ -106,26 +106,27 @@ async function needToBook(contact, mongoManager) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (needToBook) {
|
// if (needToBook) {
|
||||||
await alreadyAcceptedItems.forEach((acceptedItem) => {
|
// await alreadyAcceptedItems.forEach((acceptedItem) => {
|
||||||
if (acceptedItem.email === contact.mail) {
|
// if (acceptedItem.email === contact.mail) {
|
||||||
console.log("=====handle already accepted item====");
|
// console.log("=====handle already accepted item====");
|
||||||
console.log("accepted_at is " + acceptedItem.accepted_at);
|
// console.log("accepted_at is " + acceptedItem.accepted_at);
|
||||||
console.log("accepted email is " + acceptedItem.email);
|
// console.log("accepted email is " + acceptedItem.email);
|
||||||
needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
// needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
||||||
if (!needToBook) {
|
// if (!needToBook) {
|
||||||
console.log("already accepted appointment --> skip");
|
// console.log("already accepted appointment --> skip");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
return needToBook
|
return needToBook
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep, port) {
|
||||||
console.log(`model: ${device.model()}`);
|
console.log(`model: ${device.model()}`);
|
||||||
console.log(`serial: ${device.serial()}`);
|
console.log(`serial: ${device.serial()}`);
|
||||||
if (await needToBook(contactPojo, mongoManager)) {
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
|
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
|
|||||||
@@ -54,6 +54,18 @@ function log(message) {
|
|||||||
appointmentLogger.log({level: "info", message: message})
|
appointmentLogger.log({level: "info", message: message})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function clearApp(device, packageName) {
|
||||||
|
let cmd = `adb -s ${device.serial()} shell pm clear ${packageName}`
|
||||||
|
logWithDevice("cmd is " + cmd, device)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function exceutShellCmd(device, cmdToExecut) {
|
||||||
|
let cmd = `adb -s ${device.serial()} shell ${cmdToExecut}`
|
||||||
|
logWithDevice("cmd is " + cmd, device)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
function logWithDevice(message, device) {
|
function logWithDevice(message, device) {
|
||||||
appointmentLogger.log({level: "info", message: device.model() + ":" + device.serial() + ":" + message})
|
appointmentLogger.log({level: "info", message: device.model() + ":" + device.serial() + ":" + message})
|
||||||
}
|
}
|
||||||
@@ -145,8 +157,11 @@ class CommandorPage {
|
|||||||
async loadPage() {
|
async loadPage() {
|
||||||
logWithDevice(this.device.serial() + ":loadPage() called, with port:" + this.port, this.device);
|
logWithDevice(this.device.serial() + ":loadPage() called, with port:" + this.port, this.device);
|
||||||
try {
|
try {
|
||||||
await this.device.shell("am start -n " + this.browserPackageName + "/com.google.android.apps.chrome.Main")
|
// let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||||
await delay(5 * 1000);
|
await exceutShellCmd(this.device, " forward tcp:" + this.port + " localabstract:chrome_devtools_remote")
|
||||||
|
await delay(1 * 1000);
|
||||||
|
await this.startPage(this.device, this.browserPackageName + "/com.google.android.apps.chrome.Main")
|
||||||
|
await delay(4 * 1000);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
@@ -200,9 +215,6 @@ class CommandorPage {
|
|||||||
await this.enableDisableAirPlanMode();
|
await this.enableDisableAirPlanMode();
|
||||||
await delay(10 * 1000);
|
await delay(10 * 1000);
|
||||||
await this.clickOnlineAppointment();
|
await this.clickOnlineAppointment();
|
||||||
// await delay(2000);
|
|
||||||
// if (!this.isTerminated)
|
|
||||||
// await this.clickOnlineAppointment();
|
|
||||||
} else {
|
} else {
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
}
|
}
|
||||||
@@ -812,7 +824,8 @@ class CommandorPage {
|
|||||||
this.isPhoneInput = false;
|
this.isPhoneInput = false;
|
||||||
this.isPasspordInput = false;
|
this.isPasspordInput = false;
|
||||||
// this.disconnectBrowser();
|
// this.disconnectBrowser();
|
||||||
await this.device.shell("pm clear " + this.browserPackageName)
|
await clearApp(this.device, this.browserPackageName)
|
||||||
|
// await this.device.shell("pm clear " + this.browserPackageName)
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
// await this.checkResultWithOcr();
|
// await this.checkResultWithOcr();
|
||||||
@@ -988,9 +1001,10 @@ class CommandorPage {
|
|||||||
// await this.device.shell("input tap " + 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")
|
else if (this.device.model() === "KB2003" || this.device.model() === "DE2117") {
|
||||||
await this.tapForDevice(this.device, 500, 1200)
|
await this.tapForDevice(this.device, 500, 1200)
|
||||||
else
|
await this.tapForDevice(this.device, 500, 1120)
|
||||||
|
} else
|
||||||
try {
|
try {
|
||||||
await this.tapForDevice(this.device, 500, 1120)
|
await this.tapForDevice(this.device, 500, 1120)
|
||||||
// await this.device.shell("input tap " + 500 + " " + 1120)
|
// await this.device.shell("input tap " + 500 + " " + 1120)
|
||||||
@@ -1001,21 +1015,22 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_PRIVACY_PUB:
|
case OCRResult.BRAVE_PRIVACY_PUB:
|
||||||
if (this.device.model() === "MI 5s")
|
if (this.device.model() === "MI 5s") {
|
||||||
await this.device.shell("input tap " + 60 + " " + 1400)
|
await this.tapForDevice(this.device, 60, 1400)
|
||||||
else
|
} else
|
||||||
await this.tapForDevice(this.device, 455, 1920)
|
await this.tapForDevice(this.device, 455, 1920)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_NOTIFICATION:
|
case OCRResult.BRAVE_NOTIFICATION:
|
||||||
logWithDevice("BRAVE_NOTIFICATION", this.device)
|
logWithDevice("BRAVE_NOTIFICATION", this.device)
|
||||||
if (this.device.model() === "21091116C")
|
if (this.device.model() === "21091116C") {
|
||||||
await this.device.shell("input tap " + 540 + " " + 1611)
|
await this.tapForDevice(this.device, 540, 1611)
|
||||||
else if (this.device.model() === "22041219PG")
|
} else if (this.device.model() === "22041219PG") {
|
||||||
await this.device.shell("input tap " + 530 + " " + 1600)
|
await this.tapForDevice(this.device, 530, 1600)
|
||||||
else
|
} else
|
||||||
await this.device.shell("input tap " + 500 + " " + 1680)
|
await this.tapForDevice(this.device, 500, 1680)
|
||||||
|
// await this.device.shell("input tap " + 500 + " " + 1680)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
@@ -1211,11 +1226,11 @@ class CommandorPage {
|
|||||||
async enableDisableAirPlanMode() {
|
async enableDisableAirPlanMode() {
|
||||||
logWithDevice("will enable/disable airplane mode", this.device)
|
logWithDevice("will enable/disable airplane mode", this.device)
|
||||||
try {
|
try {
|
||||||
await this.device.shell("cmd connectivity airplane-mode enable")
|
// await this.device.shell("cmd connectivity airplane-mode enable")
|
||||||
// await this.device.shell("adb shell settings put global airplane_mode_on 1")
|
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
// await this.device.shell("adb shell settings put global airplane_mode_on 0")
|
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
|
||||||
await this.device.shell("cmd connectivity airplane-mode disable")
|
// await this.device.shell("cmd connectivity airplane-mode disable")
|
||||||
await delay(2000)
|
await delay(2000)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
try {
|
try {
|
||||||
@@ -1229,9 +1244,9 @@ class CommandorPage {
|
|||||||
|
|
||||||
async tapGoogleDisconnectBtn() {
|
async tapGoogleDisconnectBtn() {
|
||||||
if (this.device.model() === "MI 5s") {
|
if (this.device.model() === "MI 5s") {
|
||||||
if (this.browserPackageName.includes("brave"))
|
if (this.browserPackageName.includes("brave")) {
|
||||||
await this.device.shell("input tap " + 535 + " " + 1629)
|
await this.tapForDevice(this.device, 535, 1629)
|
||||||
else
|
} else
|
||||||
await this.device.shell("input tap " + 550 + " " + 1740)
|
await this.device.shell("input tap " + 550 + " " + 1740)
|
||||||
} else {
|
} else {
|
||||||
if (this.browserPackageName.includes("brave") && this.device.model() === "CPH2219") {
|
if (this.browserPackageName.includes("brave") && this.device.model() === "CPH2219") {
|
||||||
@@ -1240,13 +1255,25 @@ class CommandorPage {
|
|||||||
await this.device.shell("input tap " + 411 + " " + 1977)
|
await this.device.shell("input tap " + 411 + " " + 1977)
|
||||||
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ONEPLUS A6000") {
|
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ONEPLUS A6000") {
|
||||||
await this.device.shell("input tap " + 411 + " " + 1970)
|
await this.device.shell("input tap " + 411 + " " + 1970)
|
||||||
|
} else if (this.browserPackageName.includes("brave") && this.device.model() === "ASUS_X00QD") {
|
||||||
|
await this.device.shell("input tap " + 411 + " " + 1970)
|
||||||
} else if (this.browserPackageName.includes("brave") && this.device.model() === "22041219PG") {
|
} else if (this.browserPackageName.includes("brave") && this.device.model() === "22041219PG") {
|
||||||
await this.device.shell("input tap " + 411 + " " + 2020)
|
await this.tapForDevice(this.device, 411, 2020)
|
||||||
} else
|
} else if (this.browserPackageName.includes("brave") && this.device.model() === "21091116C") {
|
||||||
await this.device.shell("input tap " + 411 + " " + 2100)
|
await this.tapForDevice(this.device, 411, 2020)
|
||||||
|
} else {
|
||||||
|
await this.tapForDevice(this.device, 411, 2100)
|
||||||
|
}
|
||||||
|
// await this.device.shell("input tap " + 411 + " " + 2100)
|
||||||
}
|
}
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async startPage(device, activity) {
|
||||||
|
let cmd = `adb -s ${device.serial()} shell am start -n ${activity}`
|
||||||
|
logWithDevice("cmd is " + cmd, this.device)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module
|
module
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ class OCRChecker {
|
|||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
// await this.deleteFile(screenShot)
|
// await this.deleteFile(screenShot)
|
||||||
return OCRResult.SUCCESS
|
return OCRResult.SUCCESS
|
||||||
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
|
await this.deleteFile(fileName)
|
||||||
|
await this.deleteFile(screenShot)
|
||||||
|
return OCRResult.BRAVE_NOTIFICATION
|
||||||
} 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)
|
||||||
|
|||||||
@@ -102,11 +102,6 @@ class SlidingCaptchaSolver {
|
|||||||
let result = response.data;
|
let result = response.data;
|
||||||
console.log(result);
|
console.log(result);
|
||||||
await callback(result);
|
await callback(result);
|
||||||
// console.log("will delete png file: " + fileName);
|
|
||||||
// await fs.unlink(fileName, (err) => {
|
|
||||||
// if (err) throw err;
|
|
||||||
// console.log(fileName + ' was deleted');
|
|
||||||
// })
|
|
||||||
} else {
|
} else {
|
||||||
console.log("error");
|
console.log("error");
|
||||||
await callback([]);
|
await callback([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user