Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e03bc59ca | |||
| 3e374f10fa | |||
| 1aec686c0b | |||
| 5a2b88139e | |||
| 6ce3a56ce2 | |||
| f3a7188b31 | |||
| 24f95842ba | |||
| 9657007a5b | |||
| 9d70bf7097 | |||
| 9cfa650b31 | |||
| b78c0de0ce | |||
| 87eca37d8b | |||
| a04ec8373d | |||
| 842f87c784 | |||
| 9eb582a6e8 | |||
| f67b6a3383 | |||
| f677febb3f | |||
| 538be86599 | |||
| 4ee264c650 | |||
| 1c35cd1831 | |||
| 9adea7e9fa | |||
| 32f8b9812d | |||
| 0115ad7139 | |||
| ac60977177 | |||
| 87910a6524 | |||
| ff9c9bc07d | |||
| 6a0e37c166 | |||
| 56f85bee2d |
@@ -20,7 +20,6 @@
|
|||||||
"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.39.0",
|
|
||||||
"puppeteer": "^15.2.0",
|
"puppeteer": "^15.2.0",
|
||||||
"read-ini-file": "^3.0.1",
|
"read-ini-file": "^3.0.1",
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
const {exec} = require("child_process");
|
||||||
|
|
||||||
|
// DEVICE_REGEX = "(^[a-z0-9A-Z]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
DEVICE_REGEX = "(^[a-z0-9A-Z-.:]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
|
||||||
|
// DEVICE_REGEX = "(^[a-z0-9A-Z-]*) .* model:([a-z0-9A-Z_]+)"
|
||||||
|
|
||||||
|
|
||||||
|
async function devices() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec("adb devices -l", (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.log(`error: ${error.message}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.log(`stderr: ${stderr}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
let lines = stdout.split("\n");
|
||||||
|
let result = [];
|
||||||
|
for (let i = 1; i < lines.length; i++) {
|
||||||
|
currentLine = lines[i]
|
||||||
|
console.log("currentLine is " + currentLine)
|
||||||
|
if (currentLine.length > 0) {
|
||||||
|
const o = currentLine.split('\t')
|
||||||
|
findResult = currentLine.match(DEVICE_REGEX)
|
||||||
|
console.log(findResult)
|
||||||
|
try {
|
||||||
|
result.push(new AndroidDevice(findResult[1], findResult[2]));
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
console.log(result[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
class AndroidDevice {
|
||||||
|
constructor(serial, model) {
|
||||||
|
this.serial = serial
|
||||||
|
this.model = model
|
||||||
|
}
|
||||||
|
|
||||||
|
async swipeForDevice(x0, y0, x1, y1) {
|
||||||
|
let cmd = `input swipe ${x0} ${y0} ${x1} ${y1}`
|
||||||
|
await this.shell(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
async tapForDevice(x, y) {
|
||||||
|
let cmd = `input tap ${x} ${y}`
|
||||||
|
console.log("cmd is " + cmd)
|
||||||
|
try {
|
||||||
|
await this.shell(cmd);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async clearApp(packageName) {
|
||||||
|
let cmd = `adb -s ${this.serial} shell pm clear ${packageName}`
|
||||||
|
console.log("cmd is " + cmd)
|
||||||
|
await exec(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
shell(cmd) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec("adb -s " + this.serial + " shell " + cmd, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
console.log(`error: ${error.message}`);
|
||||||
|
reject(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (stderr) {
|
||||||
|
console.log(`stderr: ${stderr}`);
|
||||||
|
reject(stderr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`stdout: ${stdout}`);
|
||||||
|
resolve(stdout);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {AndroidDevice, devices}
|
||||||
+43
-87
@@ -1,4 +1,3 @@
|
|||||||
const {_android: android} = require('playwright');
|
|
||||||
const ExcelUtil = require("./excel/ExcelUtil");
|
const ExcelUtil = require("./excel/ExcelUtil");
|
||||||
const CommandorPage = require("./workers/CommandorPage");
|
const CommandorPage = require("./workers/CommandorPage");
|
||||||
const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
||||||
@@ -6,19 +5,20 @@ const alert = require('alert');
|
|||||||
const schedule = require("node-schedule");
|
const schedule = require("node-schedule");
|
||||||
const DeviceExcludeMode = require("./models/DeviceExcludeMode");
|
const DeviceExcludeMode = require("./models/DeviceExcludeMode");
|
||||||
const {Sender} = require("./queue/Sender");
|
const {Sender} = require("./queue/Sender");
|
||||||
|
const {devices} = require("./android/adb");
|
||||||
const mongoManager = new MongoManager();
|
const mongoManager = new MongoManager();
|
||||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||||
// const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
|
||||||
const NINETY_DAYS_IN_S = 30 * 3;
|
const NINETY_DAYS_IN_S = 30 * 3;
|
||||||
let excelUtil = new ExcelUtil();
|
let excelUtil = new ExcelUtil();
|
||||||
let collectionName = formatDate(new Date())
|
let collectionName = formatDate(new Date())
|
||||||
let excludeMode = DeviceExcludeMode.ZERO
|
let includeMode = DeviceExcludeMode.ZERO
|
||||||
|
// let includeMode = DeviceExcludeMode.APPOINTMENT
|
||||||
|
|
||||||
let three_to_excludes = ["e30eb015"]
|
let three_to_include = []
|
||||||
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
let four_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||||
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "07fbd156", "NFD669QK8XNFSCNN", "6X494TTWQGFALB79", "71a0371d", "YP6HVKLFE67T598L"]
|
let appointment_to_include = ["bec11752", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ZY32GLBN5P", "ZY32GVW4NC", "becb6e99", "b41c1b72"]
|
||||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "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", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
||||||
attributedPorts = []
|
attributedPorts = []
|
||||||
const device_port_info = new Map();
|
const device_port_info = new Map();
|
||||||
@@ -36,58 +36,10 @@ async function filterAlreadyBookedContacts(contactList) {
|
|||||||
return contactsToBook;
|
return contactsToBook;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function filterAlreadyAcceptedContacts(contactList) {
|
|
||||||
let alreadyBookedContacts = await mongoManager.getAllAcceptedAppointments();
|
|
||||||
let contactsToBook = [];
|
|
||||||
contactList.forEach((contact) => {
|
|
||||||
let needToBook = true;
|
|
||||||
alreadyBookedContacts.forEach((acceptedItem) => {
|
|
||||||
if (acceptedItem.email === contact.mail) {
|
|
||||||
console.log("=====handle already accepted item before booking====");
|
|
||||||
console.log("accepted_at is " + acceptedItem.accepted_at);
|
|
||||||
console.log("accepted email is " + acceptedItem.email);
|
|
||||||
needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
|
||||||
if (!needToBook) {
|
|
||||||
console.log("already accepted appointment --> skip");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (needToBook) {
|
|
||||||
contactsToBook.push(contact)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return contactsToBook;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function filterBlacklistedContacts(contactList) {
|
|
||||||
let blackListedContacts = await mongoManager.getAllBlackedListItems();
|
|
||||||
let contactsToBook = [];
|
|
||||||
contactList.forEach((contact) => {
|
|
||||||
let needToBook = true;
|
|
||||||
blackListedContacts.forEach((blackListItem) => {
|
|
||||||
if (blackListItem.mail === contact.mail) {
|
|
||||||
console.log("=====handle blacklist item before booking=====");
|
|
||||||
console.log("update_at_s is " + blackListItem.update_at_in_s)
|
|
||||||
console.log("black list email is " + blackListItem.mail)
|
|
||||||
needToBook = blackListItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000;
|
|
||||||
if (!needToBook) {
|
|
||||||
console.log("contact in blacklist -->skip");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (needToBook) {
|
|
||||||
contactsToBook.push(contact)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return contactsToBook;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function needToBook(contact, mongoManager, alreadyBooked) {
|
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 blackListItems = await mongoManager.getAllBlackedListItems();
|
|
||||||
let blackListItems = [];
|
let blackListItems = [];
|
||||||
// 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) {
|
||||||
@@ -108,25 +60,12 @@ async function needToBook(contact, mongoManager, alreadyBooked) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// if (needToBook) {
|
|
||||||
// await alreadyAcceptedItems.forEach((acceptedItem) => {
|
|
||||||
// if (acceptedItem.email === contact.mail) {
|
|
||||||
// console.log("=====handle already accepted item====");
|
|
||||||
// console.log("accepted_at is " + acceptedItem.accepted_at);
|
|
||||||
// console.log("accepted email is " + acceptedItem.email);
|
|
||||||
// needToBook = acceptedItem.accepted_at + NINETY_DAYS_IN_S <= (new Date()) / 1000;
|
|
||||||
// if (!needToBook) {
|
|
||||||
// console.log("already accepted appointment --> skip");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
return needToBook
|
return needToBook
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||||
console.log(`model: ${device.model()}`);
|
console.log(`model: ${device.model}`);
|
||||||
console.log(`serial: ${device.serial()}`);
|
console.log(`serial: ${device.serial}`);
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
let hour = d.getHours();
|
let hour = d.getHours();
|
||||||
@@ -179,6 +118,16 @@ function shuffle(array) {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getContactListForDevice(device, allContactList) {
|
||||||
|
let contactList = [];
|
||||||
|
allContactList.forEach((contact) => {
|
||||||
|
if (contact.serial === device.serial) {
|
||||||
|
contactList.push(contact)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return contactList;
|
||||||
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
||||||
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
|
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
|
||||||
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
|
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
|
||||||
@@ -198,16 +147,16 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
console.log("startForwordingForDevice() called")
|
console.log("startForwordingForDevice() called")
|
||||||
const execSync = require('child_process').execSync;
|
const execSync = require('child_process').execSync;
|
||||||
// get attributed port
|
// get attributed port
|
||||||
let attributedPort = device_port_info[device.serial()]
|
let attributedPort = device_port_info[device.serial]
|
||||||
if (attributedPort) {
|
if (attributedPort) {
|
||||||
let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
let cmd = 'adb -s ' + device.serial + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||||
console.log("cmd is " + cmd);
|
console.log("cmd is " + cmd);
|
||||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||||
console.log('Output was:\n', output);
|
console.log('Output was:\n', output);
|
||||||
} else {
|
} else {
|
||||||
attributedPort = startPort;
|
attributedPort = startPort;
|
||||||
startPort++;
|
startPort++;
|
||||||
let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
let cmd = 'adb -s \"' + device.serial + "\" forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||||
console.log("cmd is " + cmd);
|
console.log("cmd is " + cmd);
|
||||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||||
console.log('Output was:\n', output);
|
console.log('Output was:\n', output);
|
||||||
@@ -226,33 +175,40 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
filterAlreadyBookedContacts(contactList).then((listWithoutBlackContact) => {
|
filterAlreadyBookedContacts(contactList).then((listWithoutBlackContact) => {
|
||||||
console.log("will call filterAlreadyAcceptedContacts")
|
console.log("will call filterAlreadyAcceptedContacts")
|
||||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||||
android.devices().then((devices) => {
|
devices().then((devices) => {
|
||||||
if (devices.length === 0) {
|
if (devices.length === 0) {
|
||||||
alert("未找到连接的设备");
|
alert("未找到连接的设备");
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let device_to_excludes = three_to_excludes;
|
let device_to_excludes = three_to_include;
|
||||||
if (excludeMode === DeviceExcludeMode.FOUR) {
|
if (includeMode === DeviceExcludeMode.FOUR) {
|
||||||
device_to_excludes = four_to_excludes;
|
device_to_excludes = four_to_include;
|
||||||
} else if (excludeMode === DeviceExcludeMode.THREE) {
|
} else if (includeMode === DeviceExcludeMode.THREE) {
|
||||||
device_to_excludes = three_to_excludes;
|
device_to_excludes = three_to_include;
|
||||||
} else if (excludeMode === DeviceExcludeMode.NINE) {
|
} else if (includeMode === DeviceExcludeMode.NINE) {
|
||||||
device_to_excludes = nine_to_excludes;
|
device_to_excludes = nine_to_include;
|
||||||
} else if (excludeMode === DeviceExcludeMode.SEVEN) {
|
} else if (includeMode === DeviceExcludeMode.SEVEN) {
|
||||||
device_to_excludes = seven_to_excludes
|
device_to_excludes = seven_to_excludes
|
||||||
} else if (excludeMode === DeviceExcludeMode.SIX) {
|
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
|
||||||
device_to_excludes = six_to_excludes
|
device_to_excludes = appointment_to_include
|
||||||
} else if (excludeMode === DeviceExcludeMode.ZERO) {
|
} else if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
device_to_excludes = []
|
device_to_excludes = []
|
||||||
}
|
}
|
||||||
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
|
if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
|
filteredDeviceList = devices
|
||||||
|
} else
|
||||||
|
filteredDeviceList = devices.filter(device => device_to_excludes.includes(device.serial))
|
||||||
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
|
||||||
console.log("connected device number:" + filteredDeviceList.length)
|
console.log("connected device number:" + filteredDeviceList.length)
|
||||||
console.log("segmentNumber:" + segmentNumber)
|
console.log("segmentNumber:" + segmentNumber)
|
||||||
|
listWithoutBlackContact = shuffle(listWithoutBlackContact)
|
||||||
for (let i = 0; i < filteredDeviceList.length; i++) {
|
for (let i = 0; i < filteredDeviceList.length; i++) {
|
||||||
let device = filteredDeviceList[i];
|
let device = filteredDeviceList[i];
|
||||||
let port = startForwordingForDevice(device)
|
let port = startForwordingForDevice(device)
|
||||||
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
let _contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
||||||
|
// let _contactList = getContactListForDevice(device, listWithoutBlackContact)
|
||||||
|
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
||||||
|
startWithList(_contactList, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ class ExcelUtil {
|
|||||||
if (store === undefined || store.length === 0) {
|
if (store === undefined || store.length === 0) {
|
||||||
store = "random"
|
store = "random"
|
||||||
}
|
}
|
||||||
let ipCountry = info[5];
|
let serial = info[5];
|
||||||
|
let ipCountry = info[6];
|
||||||
if (ipCountry === undefined || ipCountry.length === 0) {
|
if (ipCountry === undefined || ipCountry.length === 0) {
|
||||||
ipCountry = "FR"
|
ipCountry = "FR"
|
||||||
}
|
}
|
||||||
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry);
|
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry, serial);
|
||||||
contactList.push(newContact);
|
contactList.push(newContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class ContactPojo {
|
class ContactPojo {
|
||||||
|
|
||||||
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
|
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry, serial) {
|
||||||
this.phoneNumber = phoneNumber;
|
this.phoneNumber = phoneNumber;
|
||||||
this.passportNumber = passportNumber;
|
this.passportNumber = passportNumber;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
@@ -8,6 +8,7 @@ class ContactPojo {
|
|||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
this.store = store;
|
this.store = store;
|
||||||
this.ipCountry = ipCountry;
|
this.ipCountry = ipCountry;
|
||||||
|
this.serial = serial;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
const DeviceExcludeMode = {
|
const DeviceIncludeMode = {
|
||||||
ZERO: Symbol("ZERO"),
|
ZERO: Symbol("ZERO"),
|
||||||
NINE: Symbol("NINE"),
|
NINE: Symbol("NINE"),
|
||||||
THREE: Symbol("THREE"),
|
THREE: Symbol("THREE"),
|
||||||
SIX: Symbol("SIX"),
|
SIX: Symbol("SIX"),
|
||||||
SEVEN: Symbol("SEVEN"),
|
SEVEN: Symbol("SEVEN"),
|
||||||
|
APPOINTMENT: Symbol("APPOINTMENT"),
|
||||||
FOUR: Symbol("FOUR")
|
FOUR: Symbol("FOUR")
|
||||||
}
|
}
|
||||||
module.exports = DeviceExcludeMode
|
module.exports = DeviceIncludeMode
|
||||||
@@ -8,7 +8,6 @@ const OCRResult = {
|
|||||||
SLIDING_CAPTCHA_LOADING: Symbol("SLIDING_CAPTCHA_LOADING"),
|
SLIDING_CAPTCHA_LOADING: Symbol("SLIDING_CAPTCHA_LOADING"),
|
||||||
SLIDING_CAPTCHA_REFRESH: Symbol("SLIDING_CAPTCHA_REFRESH"),
|
SLIDING_CAPTCHA_REFRESH: Symbol("SLIDING_CAPTCHA_REFRESH"),
|
||||||
FILL_FIELD: Symbol("FILL_FIELD"),
|
FILL_FIELD: Symbol("FILL_FIELD"),
|
||||||
FILL_FIELD_EN: Symbol("FILL_FIELD_EN"),
|
|
||||||
NEED_TO_CLICK_LATE_BTN: Symbol("NEED_TO_CLICK_LATE_BTN"),
|
NEED_TO_CLICK_LATE_BTN: Symbol("NEED_TO_CLICK_LATE_BTN"),
|
||||||
ONLINE_APPOINTMENT: Symbol("Online Appointment"),
|
ONLINE_APPOINTMENT: Symbol("Online Appointment"),
|
||||||
PAGE_OPTIMIZATION: Symbol("PAGE_OPTIMIZATION"),
|
PAGE_OPTIMIZATION: Symbol("PAGE_OPTIMIZATION"),
|
||||||
@@ -22,6 +21,7 @@ const OCRResult = {
|
|||||||
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"),
|
||||||
|
CHROME_NOTIFICATION: Symbol("CHROME_NOTIFICATION"),
|
||||||
BRAVE_SKIP: Symbol("BRAVE_SKIP"),
|
BRAVE_SKIP: Symbol("BRAVE_SKIP"),
|
||||||
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
BRAVE_PRIVACY: Symbol("BRAVE_PRIVACY"),
|
||||||
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
BRAVE_PRIVACY_PUB: Symbol("BRAVE_PRIVACY_PUB"),
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class ReserveResultPojo {
|
|||||||
this.hostName = hostName
|
this.hostName = hostName
|
||||||
this.currentIp = ""
|
this.currentIp = ""
|
||||||
this.created_at = new Date().toLocaleString()
|
this.created_at = new Date().toLocaleString()
|
||||||
|
this.browserInfo = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
to_mongo_dict() {
|
to_mongo_dict() {
|
||||||
@@ -35,7 +36,8 @@ class ReserveResultPojo {
|
|||||||
serial: this.serial,
|
serial: this.serial,
|
||||||
created_at: this.created_at,
|
created_at: this.created_at,
|
||||||
hostName: this.hostName,
|
hostName: this.hostName,
|
||||||
current_ip: this.currentIp
|
current_ip: this.currentIp,
|
||||||
|
browserInfo: this.browserInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ function cmdExecute(command) {
|
|||||||
|
|
||||||
async function openUrlWithAdb(url, device) {
|
async function openUrlWithAdb(url, device) {
|
||||||
// do not continue if device is blocked
|
// do not continue if device is blocked
|
||||||
console.log("load url on device " + device.model() + " url=" + url)
|
console.log("load url on device " + device.model + " url=" + url)
|
||||||
let cmd = "adb -s " + device.serial() + " shell am start -a android.intent.action.VIEW -d " + url
|
let cmd = "adb -s " + device.serial + " shell am start -a android.intent.action.VIEW -d " + url
|
||||||
try {
|
try {
|
||||||
let output = await cmdExecute(cmd);
|
let output = await cmdExecute(cmd);
|
||||||
console.log(`stdout: ${output}`);
|
console.log(`stdout: ${output}`);
|
||||||
|
|||||||
+149
-117
@@ -11,7 +11,6 @@ const {exec} = require("child_process");
|
|||||||
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
const {openUrlWithAdb} = require("../utiles/CmdUtils");
|
||||||
const RequestDataPojo = require("../models/RequestDataPojo");
|
const RequestDataPojo = require("../models/RequestDataPojo");
|
||||||
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
const {REQUEST_DATA_OBJECT, TEST_QUEUE} = require("../queue/Sender");
|
||||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
|
||||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||||
const BLANK_URL = "about:blank"
|
const BLANK_URL = "about:blank"
|
||||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||||
@@ -58,20 +57,14 @@ 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) {
|
async function exceutShellCmd(device, cmdToExecut) {
|
||||||
let cmd = `adb -s ${device.serial()} shell ${cmdToExecut}`
|
let cmd = `adb -s ${device.serial} shell ${cmdToExecut}`
|
||||||
logWithDevice("cmd is " + cmd, device)
|
logWithDevice("cmd is " + cmd, device)
|
||||||
await exec(cmd);
|
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})
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
const searchTexts = ['hermes+rdv+online+paris', 'hermes+rdv+enligne+paris', 'hermes+rdv+en+ligne+paris', 'hermes+rendezvous+en+ligne+paris', 'hermes+appointment+online+paris', 'hermes+appointment+online+paris', 'appointment+hermes+paris+on+line', 'hermes+rendez+vous+online+paris', 'hermes+rendez+vous+paris+en+ligne', 'hermes+rendez+vous+paris+enligne', 'hermes+rendez+vous+paris+online', 'online+appointment+hermes+paris', 'hermes+online+appointment+paris', 'paris+hermes+online+appointment']
|
||||||
@@ -88,9 +81,10 @@ class CommandorPage {
|
|||||||
this.shareCookiesWithRequests = shareCookiesWithRequests;
|
this.shareCookiesWithRequests = shareCookiesWithRequests;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
this.slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
|
||||||
this.ocrChecker = new OCRChecker(this.device, this.contact);
|
this.ocrChecker = new OCRChecker(this.device, this.contact);
|
||||||
this.browserPackageName = "com.brave.browser";
|
// this.browserPackageName = "com.brave.browser";
|
||||||
// this.browserPackageName = "com.android.chrome";
|
this.browserPackageName = "com.android.chrome";
|
||||||
this.isFillingFields = false;
|
this.isFillingFields = false;
|
||||||
this.isTerminated = false;
|
this.isTerminated = false;
|
||||||
this.cguChecked = false;
|
this.cguChecked = false;
|
||||||
@@ -195,9 +189,9 @@ 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 {
|
||||||
// let cmd = 'adb -s ' + device.serial() + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
// let cmd = 'adb -s ' + device.serial + " forward tcp:" + attributedPort + " localabstract:chrome_devtools_remote";
|
||||||
await exceutShellCmd(this.device, " forward tcp:" + this.port + " localabstract:chrome_devtools_remote")
|
await exceutShellCmd(this.device, " forward tcp:" + this.port + " localabstract:chrome_devtools_remote")
|
||||||
await delay(1 * 1000);
|
await delay(1 * 1000);
|
||||||
// await this.startPage(this.device, this.browserPackageName + "/com.google.android.apps.chrome.Main")
|
// await this.startPage(this.device, this.browserPackageName + "/com.google.android.apps.chrome.Main")
|
||||||
@@ -218,7 +212,7 @@ class CommandorPage {
|
|||||||
let cancel
|
let cancel
|
||||||
const intervalTask = setInterval(async () => {
|
const intervalTask = setInterval(async () => {
|
||||||
if (this.isTerminated) {
|
if (this.isTerminated) {
|
||||||
log(this.device.model() + ":request terminated, send cancel()");
|
logWithDevice(":request terminated, send cancel()", this.device)
|
||||||
try {
|
try {
|
||||||
if (this.page !== undefined && !this.page.isClosed()) {
|
if (this.page !== undefined && !this.page.isClosed()) {
|
||||||
await this.page.close()
|
await this.page.close()
|
||||||
@@ -315,9 +309,7 @@ class CommandorPage {
|
|||||||
// await delay(getRandomWaitTime())
|
// await delay(getRandomWaitTime())
|
||||||
// await page.click(COUNTRY_ID);
|
// await page.click(COUNTRY_ID);
|
||||||
// await delay(getRandomWaitTime())
|
// await delay(getRandomWaitTime())
|
||||||
await page.evaluate(() => {
|
await page.select(COUNTRY_ID, 'FR');
|
||||||
document.getElementById("phone_country").value = "FR"
|
|
||||||
})
|
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
this.isCountryChoosen = true;
|
this.isCountryChoosen = true;
|
||||||
}
|
}
|
||||||
@@ -399,7 +391,7 @@ class CommandorPage {
|
|||||||
logWithDevice("input name called with this.isNameInput=" + this.isNameInput, this.device)
|
logWithDevice("input name called with this.isNameInput=" + this.isNameInput, this.device)
|
||||||
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
|
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
|
||||||
if (!this.isNameInput) {
|
if (!this.isNameInput) {
|
||||||
await page.focus(LAST_NAME);
|
// await page.focus(LAST_NAME);
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
console.log("will clear surname field");
|
console.log("will clear surname field");
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
@@ -550,7 +542,7 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fillFields(page, checkResult) {
|
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);
|
logWithDevice("this.isTerminated: " + this.isTerminated, this.device);
|
||||||
@@ -558,9 +550,7 @@ class CommandorPage {
|
|||||||
this.isFillingFields = true;
|
this.isFillingFields = true;
|
||||||
await this.chooseStore(page);
|
await this.chooseStore(page);
|
||||||
await this.inputName(page);
|
await this.inputName(page);
|
||||||
// if (checkResult === OCRResult.FILL_FIELD_EN) {
|
// await this.chooseCountry(page);
|
||||||
await this.chooseCountry(page);
|
|
||||||
// }
|
|
||||||
await this.inputPhoneNumber(page)
|
await this.inputPhoneNumber(page)
|
||||||
await this.fillEmail(page)
|
await this.fillEmail(page)
|
||||||
await this.inputPassportId(page)
|
await this.inputPassportId(page)
|
||||||
@@ -638,11 +628,6 @@ class CommandorPage {
|
|||||||
|
|
||||||
async resolveCaptcha(page) {
|
async resolveCaptcha(page) {
|
||||||
logWithDevice("resolveCaptcha", this.device)
|
logWithDevice("resolveCaptcha", this.device)
|
||||||
if (RDV_URL.includes("192")) {
|
|
||||||
// await this.push_message_to_queue(PublishType.SUCCESS)
|
|
||||||
await delay(100000)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
//check whether there is captcha
|
//check whether there is captcha
|
||||||
let pageContent = await page.content()
|
let pageContent = await page.content()
|
||||||
@@ -736,14 +721,13 @@ class CommandorPage {
|
|||||||
|
|
||||||
async slidingCaptcha(onResult) {
|
async slidingCaptcha(onResult) {
|
||||||
logWithDevice("slidingCaptcha", this.device);
|
logWithDevice("slidingCaptcha", this.device);
|
||||||
if (this.device.model() === "MI 5s" || this.device.model() === "ASUS_X00QD" || this.device.model() === "ASUS_Z012D" || this.device.model() === "HUAWEI NXT-TL00") {
|
if (this.device.model === "MI_5s" || this.device.model === "ASUS_X00QD" || this.device.model === "ASUS_Z012D" || this.device.model === "HUAWEI NXT-TL00") {
|
||||||
let cmd = `adb -s ${this.device.serial()} shell input touchscreen swipe 900 495 900 195`
|
let cmd = `adb -s ${this.device.serial} shell input touchscreen swipe 900 495 900 195`
|
||||||
await exec(cmd);
|
await exec(cmd);
|
||||||
await delay(5000);
|
await delay(5000);
|
||||||
}
|
}
|
||||||
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
|
await this.slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
|
||||||
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
|
logWithDevice("check isAlwaysBlocked", this.device)
|
||||||
console.log("check isAlwaysBlocked")
|
|
||||||
this.isFillingFields = false
|
this.isFillingFields = false
|
||||||
onResult(isSuccessful)
|
onResult(isSuccessful)
|
||||||
})
|
})
|
||||||
@@ -782,11 +766,17 @@ class CommandorPage {
|
|||||||
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
|
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let browserInfo = await this.page.evaluate(() => {
|
||||||
|
const ua = navigator.userAgent;
|
||||||
|
return ua
|
||||||
|
})
|
||||||
|
console.log(browserInfo); // outputs: `Chrome 62`
|
||||||
// save to mongoDb
|
// save to mongoDb
|
||||||
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
|
let reserve = ReserveResultPojo.create_from_contact(this.contact, id, url, this.choosedStore, publishType);
|
||||||
reserve.source_from = this.device.model();
|
reserve.source_from = this.device.model;
|
||||||
reserve.currentIp = currentIp
|
reserve.currentIp = currentIp
|
||||||
reserve.serial = this.device.serial();
|
reserve.serial = this.device.serial;
|
||||||
|
reserve.browserInfo = browserInfo;
|
||||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||||
if (!this.page.isClosed()) {
|
if (!this.page.isClosed()) {
|
||||||
try {
|
try {
|
||||||
@@ -830,11 +820,11 @@ class CommandorPage {
|
|||||||
this.isCountryChoosen = false;
|
this.isCountryChoosen = false;
|
||||||
this.isPhoneInput = false;
|
this.isPhoneInput = false;
|
||||||
this.isPasspordInput = false;
|
this.isPasspordInput = false;
|
||||||
await clearApp(this.device, this.browserPackageName)
|
await this.device.clearApp(this.browserPackageName)
|
||||||
|
// await clearApp(this.device, this.browserPackageName)
|
||||||
// await this.device.shell("pm clear " + 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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -850,7 +840,7 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connectBrowserIfNecessary() {
|
async connectBrowserIfNecessary() {
|
||||||
if (this.browser == undefined || !this.browser.isConnected()) {
|
if (this.browser === undefined || !this.browser.isConnected()) {
|
||||||
try {
|
try {
|
||||||
this.browser = await puppeteer.connect({
|
this.browser = await puppeteer.connect({
|
||||||
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
|
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
|
||||||
@@ -865,7 +855,7 @@ class CommandorPage {
|
|||||||
|
|
||||||
async checkResultWithOcr() {
|
async checkResultWithOcr() {
|
||||||
logWithDevice("checkResultWithOcr() called.", this.device)
|
logWithDevice("checkResultWithOcr() called.", this.device)
|
||||||
if (this.device.model() === "M2006C3LG")
|
if (this.device.model === "M2006C3LG")
|
||||||
await delay(6000);
|
await delay(6000);
|
||||||
else {
|
else {
|
||||||
await delay(4000);
|
await delay(4000);
|
||||||
@@ -878,25 +868,6 @@ class CommandorPage {
|
|||||||
logWithDevice("will recheck OCR", this.device)
|
logWithDevice("will recheck OCR", this.device)
|
||||||
checkResult = await this.ocrChecker.get_result();
|
checkResult = await this.ocrChecker.get_result();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (checkResult === OCRResult.SLIDING_CAPTCHA) {
|
|
||||||
logWithDevice("will call this.slidingCaptcha()", this.device)
|
|
||||||
await this.slidingCaptcha(async (isSuccessful) => {
|
|
||||||
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
|
||||||
console.log(checkResult);
|
|
||||||
if (isSuccessful) {
|
|
||||||
await delay(5 * 1000)
|
|
||||||
checkResult = await this.ocrChecker.get_result();
|
|
||||||
// await this.checkResultWithOcr()
|
|
||||||
} else {
|
|
||||||
if (checkResult === OCRResult.SLIDING_CAPTCHA) {
|
|
||||||
checkResult = OCRResult.TERMINAED
|
|
||||||
this.isTerminated = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
await delay(10 * 1000)
|
|
||||||
}
|
|
||||||
switch (checkResult) {
|
switch (checkResult) {
|
||||||
case OCRResult.SLIDING_CAPTCHA_LOADING:
|
case OCRResult.SLIDING_CAPTCHA_LOADING:
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
@@ -910,8 +881,26 @@ class CommandorPage {
|
|||||||
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
||||||
await this.connect_to_browser(checkResult)
|
await this.connect_to_browser(checkResult)
|
||||||
break;
|
break;
|
||||||
|
case OCRResult.CHROME_NOTIFICATION:
|
||||||
|
await this.handleChromeNotification()
|
||||||
|
await this.checkResultWithOcr();
|
||||||
|
break;
|
||||||
|
case OCRResult.SLIDING_CAPTCHA:
|
||||||
|
logWithDevice("will call this.slidingCaptcha()", this.device)
|
||||||
|
await this.slidingCaptcha(async (isSuccessful) => {
|
||||||
|
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
||||||
|
console.log(checkResult);
|
||||||
|
if (isSuccessful) {
|
||||||
|
await delay(5 * 1000)
|
||||||
|
// checkResult = await this.ocrChecker.get_result();
|
||||||
|
await this.checkResultWithOcr()
|
||||||
|
} else {
|
||||||
|
await this.checkResultWithOcr()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// await delay(5 * 1000)
|
||||||
|
break;
|
||||||
case OCRResult.FILL_FIELD:
|
case OCRResult.FILL_FIELD:
|
||||||
case OCRResult.FILL_FIELD_EN:
|
|
||||||
logWithDevice("FILL_FIELD", this.device)
|
logWithDevice("FILL_FIELD", this.device)
|
||||||
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)
|
||||||
@@ -926,6 +915,7 @@ class CommandorPage {
|
|||||||
// add listeners
|
// add listeners
|
||||||
let pages = await timeout(this.browser.pages(), 5 * 1000);
|
let pages = await timeout(this.browser.pages(), 5 * 1000);
|
||||||
pages.forEach((currentPage) => {
|
pages.forEach((currentPage) => {
|
||||||
|
logWithDevice("current url is " + currentPage.url(), this.device)
|
||||||
if (currentPage.url() === RDV_URL) {
|
if (currentPage.url() === RDV_URL) {
|
||||||
this.page = currentPage;
|
this.page = currentPage;
|
||||||
} else {
|
} else {
|
||||||
@@ -940,7 +930,7 @@ class CommandorPage {
|
|||||||
logWithDevice("this.page.bringToFront();", this.device)
|
logWithDevice("this.page.bringToFront();", this.device)
|
||||||
// await this.sendCookiesToQueue();
|
// await this.sendCookiesToQueue();
|
||||||
await this.page.bringToFront();
|
await this.page.bringToFront();
|
||||||
await this.fillFields(this.page, checkResult)
|
await this.fillFields(this.page)
|
||||||
await delay(2 * 1000);
|
await delay(2 * 1000);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -957,6 +947,19 @@ class CommandorPage {
|
|||||||
if (this.browser.isConnected()) {
|
if (this.browser.isConnected()) {
|
||||||
logWithDevice("will use old page", this.device)
|
logWithDevice("will use old page", this.device)
|
||||||
logWithDevice("this.page.bringToFront();", this.device)
|
logWithDevice("this.page.bringToFront();", this.device)
|
||||||
|
let pages = await timeout(this.browser.pages(), 5 * 1000);
|
||||||
|
pages.forEach((currentPage) => {
|
||||||
|
if (currentPage.url() === RDV_URL) {
|
||||||
|
this.page = currentPage;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
if (!this.isTerminated)
|
||||||
|
currentPage.close()
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
await this.page.bringToFront();
|
await this.page.bringToFront();
|
||||||
// this.page = pages;
|
// this.page = pages;
|
||||||
// this.page.await
|
// this.page.await
|
||||||
@@ -988,23 +991,23 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_PRIVACY:
|
case OCRResult.BRAVE_PRIVACY:
|
||||||
let model = this.device.model()
|
let model = this.device.model
|
||||||
if (model === "MI 5s" || this.device.model() === "SM-G965U1" || this.device.model() === "ASUS_Z012D") {
|
if (model === "MI_5s" || this.device.model === "SM-G965U1" || this.device.model === "ASUS_Z012D") {
|
||||||
await this.tapForDevice(this.device, 530, 970)
|
await this.tapForDevice(this.device, 530, 970)
|
||||||
} else if (model === "HUAWEI NXT-TL00") {
|
} else if (model === "HUAWEI NXT-TL00") {
|
||||||
await this.tapForDevice(this.device, 530, 950)
|
await this.tapForDevice(this.device, 530, 950)
|
||||||
} else if (this.device.model() === "ONEPLUS A6000") {
|
} else if (this.device.model === "ONEPLUS_A6000") {
|
||||||
await this.tapForDevice(this.device, 530, 1064)
|
await this.tapForDevice(this.device, 530, 1064)
|
||||||
} else if (this.device.model() === "moto g51 5G") {
|
} else if (this.device.model === "moto g51 5G") {
|
||||||
await this.tapForDevice(this.device, 500, 1080)
|
await this.tapForDevice(this.device, 500, 1080)
|
||||||
} else if (this.device.model() === "CPH2469") {
|
} else if (this.device.model === "CPH2469") {
|
||||||
await this.tapForDevice(this.device, 360, 820)
|
await this.tapForDevice(this.device, 360, 820)
|
||||||
} else if (this.device.model() === "M2006C3LG" || this.device.model() === "220233L2G") {
|
} else if (this.device.model === "M2006C3LG" || this.device.model === "220233L2G") {
|
||||||
await this.tapForDevice(this.device, 350, 777)
|
await this.tapForDevice(this.device, 350, 777)
|
||||||
} else if (this.device.model() === "KB2003") {
|
} else if (this.device.model === "KB2003") {
|
||||||
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 if (this.device.model() === "DE2117") {
|
} else if (this.device.model === "DE2117") {
|
||||||
await this.tapForDevice(this.device, 545, 1130)
|
await this.tapForDevice(this.device, 545, 1130)
|
||||||
} else
|
} else
|
||||||
try {
|
try {
|
||||||
@@ -1017,9 +1020,9 @@ 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" || this.device.model() === "ASUS_Z012D") {
|
if (this.device.model === "MI_5s" || this.device.model === "ASUS_Z012D") {
|
||||||
await this.tapForDevice(this.device, 60, 1400)
|
await this.tapForDevice(this.device, 60, 1400)
|
||||||
} else if (this.device.model() === "HUAWEI NXT-TL00") {
|
} else if (this.device.model === "HUAWEI NXT-TL00") {
|
||||||
await this.tapForDevice(this.device, 530, 950)
|
await this.tapForDevice(this.device, 530, 950)
|
||||||
} else
|
} else
|
||||||
await this.tapForDevice(this.device, 455, 1920)
|
await this.tapForDevice(this.device, 455, 1920)
|
||||||
@@ -1034,11 +1037,11 @@ class CommandorPage {
|
|||||||
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.tapForDevice(this.device, 540, 1611)
|
await this.tapForDevice(this.device, 540, 1611)
|
||||||
} else if (this.device.model() === "22041219PG") {
|
} else if (this.device.model === "22041219PG") {
|
||||||
await this.tapForDevice(this.device, 530, 1600)
|
await this.tapForDevice(this.device, 530, 1600)
|
||||||
} else if (this.device.model() === "CPH2469") {
|
} else if (this.device.model === "CPH2469") {
|
||||||
await this.tapForDevice(this.device, 322, 1146)
|
await this.tapForDevice(this.device, 322, 1146)
|
||||||
} else
|
} else
|
||||||
await this.tapForDevice(this.device, 500, 1680)
|
await this.tapForDevice(this.device, 500, 1680)
|
||||||
@@ -1055,18 +1058,21 @@ class CommandorPage {
|
|||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_VPN_SKIP:
|
case OCRResult.BRAVE_VPN_SKIP:
|
||||||
logWithDevice("BRAVE_VPN_SKIP", this.device)
|
logWithDevice("BRAVE_VPN_SKIP", this.device)
|
||||||
if (this.device.model() === "M2006C3LG") {
|
if (this.device.model === "M2006C3LG") {
|
||||||
await this.tapForDevice(this.device, 580, 445)
|
await this.tapForDevice(this.device, 580, 445)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OCRResult.TO_SKIP
|
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.model === "22041219PG") {
|
||||||
await this.device.shell("input tap " + 530 + " " + 1742)
|
await this.tapForDevice(this.device, 530, 1742)
|
||||||
else
|
await delay(1000);
|
||||||
await this.device.shell("input tap " + 488 + " " + 1848)
|
await this.tapForDevice(this.device, 530, 1742)
|
||||||
|
} else
|
||||||
|
await this.tapForDevice(this.device, 488, 1848)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.TO_REFRESH
|
OCRResult.TO_REFRESH
|
||||||
@@ -1117,8 +1123,8 @@ class CommandorPage {
|
|||||||
OCRResult.NEED_TO_CLICK_LATE_BTN
|
OCRResult.NEED_TO_CLICK_LATE_BTN
|
||||||
:
|
:
|
||||||
await this.tapLaterBtn()
|
await this.tapLaterBtn()
|
||||||
this.firstStart = true;
|
await delay(5000)
|
||||||
await this.loadPage()
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.CLOSED
|
OCRResult.CLOSED
|
||||||
@@ -1295,10 +1301,10 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleBraveSkipBtn() {
|
async handleBraveSkipBtn() {
|
||||||
let model = this.device.model()
|
let model = this.device.model
|
||||||
if (model === "CPH2219") {
|
if (model === "CPH2219") {
|
||||||
await this.tapForDevice(this.device, 558, 1160)
|
await this.tapForDevice(this.device, 558, 1160)
|
||||||
} else if (model === "MI 5s" || model === "ASUS_Z012D") {
|
} else if (model === "MI_5s" || model === "ASUS_Z012D") {
|
||||||
await this.tapForDevice(this.device, 530, 1000)
|
await this.tapForDevice(this.device, 530, 1000)
|
||||||
} else if (model === "SM-G965U1") {
|
} else if (model === "SM-G965U1") {
|
||||||
await this.tapForDevice(this.device, 530, 1000)
|
await this.tapForDevice(this.device, 530, 1000)
|
||||||
@@ -1306,7 +1312,7 @@ class CommandorPage {
|
|||||||
await this.tapForDevice(this.device, 530, 950)
|
await this.tapForDevice(this.device, 530, 950)
|
||||||
} else if (model === "M2006C3LG" || model === "220233L2G") {
|
} else if (model === "M2006C3LG" || model === "220233L2G") {
|
||||||
await this.tapForDevice(this.device, 360, 777)
|
await this.tapForDevice(this.device, 360, 777)
|
||||||
} else if (model === "ONEPLUS A6000") {
|
} else if (model === "ONEPLUS_A6000") {
|
||||||
await this.tapForDevice(this.device, 530, 1045)
|
await this.tapForDevice(this.device, 530, 1045)
|
||||||
} else if (model === "CPH2469") {
|
} else if (model === "CPH2469") {
|
||||||
await this.tapForDevice(this.device, 360, 820)
|
await this.tapForDevice(this.device, 360, 820)
|
||||||
@@ -1320,33 +1326,33 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tapForDevice(device, x, y) {
|
async tapForDevice(device, x, y) {
|
||||||
let cmd = `adb -s ${device.serial()} shell input tap ${x} ${y}`
|
let cmd = `adb -s ${device.serial} shell input tap ${x} ${y}`
|
||||||
logWithDevice("cmd is " + cmd, this.device)
|
logWithDevice("cmd is " + cmd, this.device)
|
||||||
await exec(cmd);
|
await exec(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
async swipeForDevice(device, x0, y0, x1, y1) {
|
async swipeForDevice(device, x0, y0, x1, y1) {
|
||||||
// let swipCmd = "input swipe " + x + " " + y0 + " " + x + " 1522"
|
// let swipCmd = "input swipe " + x + " " + y0 + " " + x + " 1522"
|
||||||
let cmd = `adb -s ${device.serial()} shell input swipe ${x0} ${y0} ${x1} ${y1}`
|
let cmd = `adb -s ${device.serial} shell input swipe ${x0} ${y0} ${x1} ${y1}`
|
||||||
logWithDevice("cmd is " + cmd, this.device)
|
logWithDevice("cmd is " + cmd, this.device)
|
||||||
await exec(cmd);
|
await exec(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
async inputForDevice(device, text) {
|
async inputForDevice(device, text) {
|
||||||
let cmd = `adb -s ${device.serial()} shell input text ${text}`
|
let cmd = `adb -s ${device.serial} shell input text ${text}`
|
||||||
logWithDevice("cmd is " + cmd, this.device)
|
logWithDevice("cmd is " + cmd, this.device)
|
||||||
await exec(cmd);
|
await exec(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
} else if (this.device.model() === "MI 5s") {
|
} else if (this.device.model === "MI_5s") {
|
||||||
this.device.shell("input tap " + 925 + " " + 1325)
|
this.device.shell("input tap " + 925 + " " + 1325)
|
||||||
} else if (this.device.model() === "22041219PG") {
|
} else if (this.device.model === "22041219PG") {
|
||||||
this.device.shell("input tap " + 925 + " " + 1430)
|
this.device.shell("input tap " + 925 + " " + 1430)
|
||||||
} else if (this.device.model() === "moto g51 5G") {
|
} else if (this.device.model === "moto_g51_5G") {
|
||||||
await this.tapForDevice(this.device, 950, 1434)
|
this.device.shell("input tap " + 950 + " " + 1434)
|
||||||
} else
|
} else
|
||||||
this.device.shell("input tap " + 933 + " " + 1538)
|
this.device.shell("input tap " + 933 + " " + 1538)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
@@ -1354,35 +1360,35 @@ class CommandorPage {
|
|||||||
|
|
||||||
async clickOnHomeBtn() {
|
async clickOnHomeBtn() {
|
||||||
// await this.enableDisableAirPlanMode()
|
// await this.enableDisableAirPlanMode()
|
||||||
if (this.device.model() === "22041219PG") {
|
if (this.device.model === "22041219PG") {
|
||||||
await this.tapForDevice(this.device, 110, 2208)
|
await this.tapForDevice(this.device, 110, 2208)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "KB2003") {
|
} else if (this.device.model === "KB2003") {
|
||||||
await this.tapForDevice(this.device, 100, 2289)
|
await this.tapForDevice(this.device, 100, 2289)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "21091116C") {
|
} else if (this.device.model === "21091116C") {
|
||||||
await this.tapForDevice(this.device, 107, 2193)
|
await this.tapForDevice(this.device, 107, 2193)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "MI 5s") {
|
} else if (this.device.model === "MI_5s") {
|
||||||
await this.tapForDevice(this.device, 110, 1842)
|
await this.tapForDevice(this.device, 110, 1842)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "ASUS_X00QD" || this.device.model() === "CPH2219") {
|
} else if (this.device.model === "ASUS_X00QD" || this.device.model === "CPH2219") {
|
||||||
await this.tapForDevice(this.device, 112, 2172)
|
await this.tapForDevice(this.device, 112, 2172)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "moto g51 5G") {
|
} else if (this.device.model === "moto g51 5G") {
|
||||||
await this.tapForDevice(this.device, 103, 2283)
|
await this.tapForDevice(this.device, 103, 2283)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "ONEPLUS A6000") {
|
} else if (this.device.model === "ONEPLUS_A6000") {
|
||||||
await this.tapForDevice(this.device, 122, 2172)
|
await this.tapForDevice(this.device, 122, 2172)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
} else if (this.device.model() === "DE2117") {
|
} else if (this.device.model === "DE2117") {
|
||||||
await this.tapForDevice(this.device, 122, 2172)
|
await this.tapForDevice(this.device, 122, 2172)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
@@ -1396,22 +1402,27 @@ class CommandorPage {
|
|||||||
|
|
||||||
async skipOptimizationPage() {
|
async skipOptimizationPage() {
|
||||||
logWithDevice("skipOptimizationPage", this.device)
|
logWithDevice("skipOptimizationPage", this.device)
|
||||||
let model = this.device.model();
|
let model = this.device.model;
|
||||||
if (model === "ASUS_X00QD") {
|
if (model === "ASUS_X00QD") {
|
||||||
this.device.shell("input tap " + 800 + " " + 2100)
|
this.device.shell("input tap " + 800 + " " + 2100)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
this.device.shell("input tap " + 800 + " " + 2100)
|
this.device.shell("input tap " + 800 + " " + 2100)
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
} else if (model === "ONEPLUS A6000") {
|
} else if (model === "ONEPLUS_A6000") {
|
||||||
this.device.shell("input tap " + 818 + " " + 2140)
|
this.device.shell("input tap " + 818 + " " + 2140)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
this.device.shell("input tap " + 818 + " " + 2140)
|
this.device.shell("input tap " + 818 + " " + 2140)
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
|
} else if (model === "moto_g51_5G") {
|
||||||
|
this.device.shell("input tap " + 806 + " " + 2230)
|
||||||
|
await delay(2000);
|
||||||
|
this.device.shell("input tap " + 800 + " " + 2215)
|
||||||
|
await delay(1000);
|
||||||
} else if (model === "CPH2219") {
|
} else if (model === "CPH2219") {
|
||||||
this.device.shell("input tap " + 772 + " " + 2146)
|
this.device.shell("input tap " + 772 + " " + 2146)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
this.device.shell("input tap " + 772 + " " + 2146)
|
this.device.shell("input tap " + 772 + " " + 2146)
|
||||||
} else if (model === "MI 5s") {
|
} else if (model === "MI_5s") {
|
||||||
this.device.shell("input tap " + 786 + " " + 1780)
|
this.device.shell("input tap " + 786 + " " + 1780)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
this.device.shell("input tap " + 790 + " " + 1807)
|
this.device.shell("input tap " + 790 + " " + 1807)
|
||||||
@@ -1426,22 +1437,35 @@ class CommandorPage {
|
|||||||
|
|
||||||
async tapLaterBtn() {
|
async tapLaterBtn() {
|
||||||
logWithDevice("tapLaterBtn", this.device)
|
logWithDevice("tapLaterBtn", this.device)
|
||||||
let model = this.device.model();
|
let model = this.device.model;
|
||||||
log("model is " + model);
|
log("model is " + model);
|
||||||
if (model === "CPH2219") {
|
if (model === "CPH2219") {
|
||||||
this.device.shell("input tap " + 385 + " " + 1930)
|
this.device.shell("input tap " + 385 + " " + 1930)
|
||||||
} else if (model === "ASUS_X00QD") {
|
} else if (model === "ASUS_X00QD") {
|
||||||
this.device.shell("input tap " + 490 + " " + 1910)
|
this.device.shell("input tap " + 490 + " " + 1910)
|
||||||
|
} else if (model === "RMX3151") {
|
||||||
|
this.device.shell("input tap " + 492 + " " + 1960)
|
||||||
|
} else if (model === "Pixel"||model === "Pixel_2") {
|
||||||
|
this.device.shell("input tap " + 312 + " " + 1490)
|
||||||
} else if (model === "Mi Note 10") {
|
} else if (model === "Mi Note 10") {
|
||||||
this.device.shell("input tap " + 550 + " " + 1920)
|
this.device.shell("input tap " + 550 + " " + 1920)
|
||||||
} else if (model === "ONEPLUS A6000") {
|
} else if (model === "ONEPLUS_A6000") {
|
||||||
this.device.shell("input tap " + 535 + " " + 1945)
|
log("will tap on " + model + ": " + 535 + " " + 1930)
|
||||||
|
this.device.shell("input tap " + 535 + " " + 1930)
|
||||||
|
await delay(1000);
|
||||||
|
this.device.shell("input tap " + 535 + " " + 1930)
|
||||||
|
} else if (model === "DE2117") {
|
||||||
|
await this.tapForDevice(this.device, 529, 2050)
|
||||||
|
await delay(1000)
|
||||||
|
await this.tapForDevice(this.device, 529, 2050)
|
||||||
} else if (model === "22041219PG") {
|
} else if (model === "22041219PG") {
|
||||||
this.device.shell("input tap " + 540 + " " + 1985)
|
this.device.shell("input tap " + 540 + " " + 1985)
|
||||||
} else if (model === "21091116C") {
|
} else if (model === "21091116C") {
|
||||||
this.device.shell("input tap " + 510 + " " + 1975)
|
this.device.shell("input tap " + 510 + " " + 1975)
|
||||||
} else if (model === "MI 5s") {
|
} else if (model === "MI_5s") {
|
||||||
this.device.shell("input tap " + 510 + " " + 1615)
|
this.device.shell("input tap " + 510 + " " + 1615)
|
||||||
|
} else if (model === "Mi_Note_10") {
|
||||||
|
await this.tapForDevice(this.device, 498, 1910)
|
||||||
} else
|
} else
|
||||||
this.device.shell("input tap " + 385 + " " + 2050)
|
this.device.shell("input tap " + 385 + " " + 2050)
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
@@ -1450,11 +1474,9 @@ 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 exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
|
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
|
await exceutShellCmd(this.device, "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 {
|
||||||
@@ -1467,27 +1489,27 @@ 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.tapForDevice(this.device, 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") {
|
||||||
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() === "RMX3151") {
|
} else if (this.browserPackageName.includes("brave") && this.device.model === "RMX3151") {
|
||||||
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") {
|
} else if (this.browserPackageName.includes("brave") && this.device.model === "ASUS_X00QD") {
|
||||||
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() === "22041219PG") {
|
} else if (this.browserPackageName.includes("brave") && this.device.model === "22041219PG") {
|
||||||
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
|
} else if (this.browserPackageName.includes("brave") && this.device.model === "M2006C3LG") {//redmi 9a
|
||||||
await this.tapForDevice(this.device, 411, 1300)
|
await this.tapForDevice(this.device, 411, 1300)
|
||||||
} else if (this.browserPackageName.includes("brave") && this.device.model() === "220233L2G") {//redmi 9a
|
} else if (this.browserPackageName.includes("brave") && this.device.model === "220233L2G") {//redmi 9a
|
||||||
await this.tapForDevice(this.device, 411, 1300)
|
await this.tapForDevice(this.device, 411, 1300)
|
||||||
} else {
|
} else {
|
||||||
await this.tapForDevice(this.device, 411, 2100)
|
await this.tapForDevice(this.device, 411, 2100)
|
||||||
@@ -1515,13 +1537,23 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async handleBravePushNotification() {
|
async handleBravePushNotification() {
|
||||||
let model = this.device.model()
|
let model = this.device.model
|
||||||
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
|
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
|
||||||
await this.tapForDevice(this.device, 545, 1448)
|
await this.tapForDevice(this.device, 545, 1448)
|
||||||
} else
|
} else
|
||||||
await this.tapForDevice(this.device, 100, 400)
|
await this.tapForDevice(this.device, 100, 400)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async handleChromeNotification() {
|
||||||
|
let model = this.device.model
|
||||||
|
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
|
||||||
|
await this.tapForDevice(this.device, 545, 1448)
|
||||||
|
} else if (model === "sdk_gphone64_arm64") {
|
||||||
|
await this.tapForDevice(this.device, 484, 1723)
|
||||||
|
} else
|
||||||
|
await this.tapForDevice(this.device, 100, 400)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module
|
module
|
||||||
|
|||||||
+26
-35
@@ -18,12 +18,12 @@ const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
|||||||
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
||||||
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
||||||
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
||||||
const MESSAGE_URL_VALIDATION_EN = "You will receive an email to validate"
|
const MESSAGE_URL_VALIDATION_EN = "Please click on the link we sent by email"
|
||||||
const WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
const WRONG_PHONE_NUMBER = "Veuillez renseigner vote numéro de téléphone"
|
||||||
const CHOOSE_POSITION_GOOGLE_FR = " Choisir la position pour les résultats de recherche"
|
const CHOOSE_POSITION_GOOGLE_FR = " Choisir la position pour les résultats de recherche"
|
||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
const CAPTCHA_ERROR_MESSAGE_FR = "La vérification du captcha a échoué"
|
||||||
const BLOCKED_MSG_EN = "has been blocked"
|
const BLOCKED_MSG_EN = "have been blocked"
|
||||||
const BLOCKED_MSG_FR = "avez été bloqué"
|
const BLOCKED_MSG_FR = "avez été bloqué"
|
||||||
const BLOCKED_MSG_FR_3 = "a été bloqué"
|
const BLOCKED_MSG_FR_3 = "a été bloqué"
|
||||||
const BLOCKED_MSG_FR_2 = "Pourquoi ce blocage"
|
const BLOCKED_MSG_FR_2 = "Pourquoi ce blocage"
|
||||||
@@ -34,8 +34,9 @@ const ERR_CACHE_MISS_2 = "ERR_CACHE-MISS"
|
|||||||
const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
|
const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
|
||||||
const ERR_CACHE_MISS_4 = "renvoyer les données"
|
const ERR_CACHE_MISS_4 = "renvoyer les données"
|
||||||
const ERR_EMPTY_RESPONSE = "ERR_EMPTY_RESPONSE"
|
const ERR_EMPTY_RESPONSE = "ERR_EMPTY_RESPONSE"
|
||||||
|
const ERR_SSL_PROTOCOL = "SSL_PROTOCOL_ERROR"
|
||||||
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
|
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
|
||||||
const SLIDING_CAPTCHA_EN = "Slide right to complete the puzzle"
|
const SLIDING_CAPTCHA_RETRY_FR = "RÉESSAYER"
|
||||||
const SLIDING_CAPTCHA_LOADING_FR = "Chargement."
|
const SLIDING_CAPTCHA_LOADING_FR = "Chargement."
|
||||||
const SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour"
|
const SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour"
|
||||||
const SLIDING_CAPTCHA_FR_3 = "la droite pour completer le puzzle"
|
const SLIDING_CAPTCHA_FR_3 = "la droite pour completer le puzzle"
|
||||||
@@ -43,14 +44,14 @@ const SLIDING_CAPTCHA_FR_4 = " s'assure qu'on s'adresse bien"
|
|||||||
const SLIDING_CAPTCHA_FR_5 = "On s'assure que c'est"
|
const SLIDING_CAPTCHA_FR_5 = "On s'assure que c'est"
|
||||||
const SLIDING_CAPTCHA_FR_6 = "s'assure que cest bien vous"
|
const SLIDING_CAPTCHA_FR_6 = "s'assure que cest bien vous"
|
||||||
const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
||||||
const MESSAGE_FILL_FIELD_EN = "Appointment request for"
|
|
||||||
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
const MESSAGE_FILL_FIELD_FR_2 = "des champs de données doivent étre complétés"
|
||||||
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
const MESSAGE_FILL_FIELD_FR_3 = "Sans préféré"
|
||||||
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
const MESSAGE_FILL_FIELD_FR_4 = "Magasin préféré"
|
||||||
const MESSAGE_FILL_FIELD_EN_4 = "Favorite store"
|
|
||||||
const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous"
|
const MESSAGE_FILL_FIELD_FR_5 = "email vous sera envoyé pour vous"
|
||||||
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
const MESSAGE_FILL_FIELD_FR_6 = "Prénom* Téléphone*"
|
||||||
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
const WELCOME_MESSAGE_FR = "Bienvenue dans Chrome"
|
||||||
|
const WELCOME_MESSAGE_FR_2 = "Chrome Connectez-vous"
|
||||||
|
const WELCOME_MESSAGE_FR_3 = "Connectez-Vou's pour"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR = "Vous pouvez changer d'avis a tout moment dans"
|
const PAGE_OPTIMIZATION_CHROME_FR = "Vous pouvez changer d'avis a tout moment dans"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_6 = "Vous pouvez changer davis a tout moment"
|
const PAGE_OPTIMIZATION_CHROME_FR_6 = "Vous pouvez changer davis a tout moment"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_2 = "Vous pouvez modifier vos options a tout moment"
|
const PAGE_OPTIMIZATION_CHROME_FR_2 = "Vous pouvez modifier vos options a tout moment"
|
||||||
@@ -59,6 +60,7 @@ const PAGE_OPTIMIZATION_CHROME_FR_4 = "de nouvelles fonctionnalités"
|
|||||||
const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance"
|
const PAGE_OPTIMIZATION_CHROME_FR_5 = "Avec la mesure des performance"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_7 = "Les annonces suggérées par les"
|
const PAGE_OPTIMIZATION_CHROME_FR_7 = "Les annonces suggérées par les"
|
||||||
const PAGE_OPTIMIZATION_CHROME_FR_8 = "Chrome estime vos centres"
|
const PAGE_OPTIMIZATION_CHROME_FR_8 = "Chrome estime vos centres"
|
||||||
|
const CHROME_NOTIFICATION = "Les notifications de Chrome"
|
||||||
const ONLINE_APPOINTMENT = "Online Appointment"
|
const ONLINE_APPOINTMENT = "Online Appointment"
|
||||||
const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi"
|
const CONFIRM_RESEND_FORM_FR = "Confirmer le nouvel envoi"
|
||||||
const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans"
|
const CLOSED_MESSAGE_FR = "Depuis plus de 130 ans"
|
||||||
@@ -75,14 +77,11 @@ const BRAVE_SKIP_PUB_5 = "aucune traceur"
|
|||||||
const BRAVE_SKIP_PUB_4 = "aucune publicité"
|
const BRAVE_SKIP_PUB_4 = "aucune publicité"
|
||||||
const BRAVE_SKIP_DEFAULT_PAGE = "confidentialité de Brave"
|
const BRAVE_SKIP_DEFAULT_PAGE = "confidentialité de Brave"
|
||||||
const BRAVE_SKIP_DEFAULT_PAGE_2 = "définissant Brave"
|
const BRAVE_SKIP_DEFAULT_PAGE_2 = "définissant Brave"
|
||||||
const BRAVE_SKIP_DEFAULT_PAGE_EN = "With Brave as default"
|
|
||||||
const BRAVE_SKIP_PRIVACY_PAGE = "Partagez des informations"
|
const BRAVE_SKIP_PRIVACY_PAGE = "Partagez des informations"
|
||||||
const BRAVE_SKIP_PRIVACY_PAGE_EN = "make Brave better"
|
|
||||||
const BRAVE_SKIP_PRIVACY_PAGE_3 = "Partagez de informations"
|
const BRAVE_SKIP_PRIVACY_PAGE_3 = "Partagez de informations"
|
||||||
const BRAVE_SKIP_PRIVACY_PAGE_2 = "Partagez des renseignements"
|
const BRAVE_SKIP_PRIVACY_PAGE_2 = "Partagez des renseignements"
|
||||||
|
|
||||||
const PUSH_NOTIFICATION_1 = "Brave à vous envoyer des notifications"
|
const PUSH_NOTIFICATION_1 = "Brave à vous envoyer des notifications"
|
||||||
const PUSH_NOTIFICATION_EN_1 = "Brave to send you notifications"
|
|
||||||
|
|
||||||
class OCRChecker {
|
class OCRChecker {
|
||||||
|
|
||||||
@@ -108,9 +107,12 @@ class OCRChecker {
|
|||||||
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_NOTIFICATION
|
return OCRResult.BRAVE_NOTIFICATION
|
||||||
} else if (result.includes(PUSH_NOTIFICATION_1) || result.includes(PUSH_NOTIFICATION_EN_1)) {
|
} else if (result.includes(PUSH_NOTIFICATION_1)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_PUSH_NOTIFICATION
|
return OCRResult.BRAVE_PUSH_NOTIFICATION
|
||||||
|
} else if (result.includes(CHROME_NOTIFICATION)) {
|
||||||
|
await this.deleteFile(fileName)
|
||||||
|
return OCRResult.CHROME_NOTIFICATION
|
||||||
} else if (result.includes(CHOOSE_POSITION_GOOGLE_FR)) {
|
} else if (result.includes(CHOOSE_POSITION_GOOGLE_FR)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.CHOOSE_POSITION
|
return OCRResult.CHOOSE_POSITION
|
||||||
@@ -123,21 +125,9 @@ class OCRChecker {
|
|||||||
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
} else if (result.includes(WRONG_PHONE_NUMBER)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.WRONG_PHONE_NUMBER
|
return OCRResult.WRONG_PHONE_NUMBER
|
||||||
} else if (result.includes(MESSAGE_FILL_FIELD_FR)
|
} 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) || result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
||||||
|| 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_EN_4)
|
|
||||||
|| result.includes(MESSAGE_FILL_FIELD_FR_5)
|
|
||||||
|| result.includes(MESSAGE_FILL_FIELD_EN)
|
|
||||||
|| result.includes(MESSAGE_FILL_FIELD_FR_6)) {
|
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.FILL_FIELD
|
return OCRResult.FILL_FIELD
|
||||||
} else if (result.includes(MESSAGE_FILL_FIELD_EN_4)
|
|
||||||
|| result.includes(MESSAGE_FILL_FIELD_EN)
|
|
||||||
) {
|
|
||||||
await this.deleteFile(fileName)
|
|
||||||
return OCRResult.FILL_FIELD_EN
|
|
||||||
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
||||||
return OCRResult.RECAPTCHA_ERROR
|
return OCRResult.RECAPTCHA_ERROR
|
||||||
} 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) || result.includes(BRAVE_SKIP_PUB_5)) {
|
} 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) || result.includes(BRAVE_SKIP_PUB_5)) {
|
||||||
@@ -156,10 +146,7 @@ class OCRChecker {
|
|||||||
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_NOTIFICATION
|
return OCRResult.BRAVE_NOTIFICATION
|
||||||
} else if (result.includes(SLIDING_CAPTCHA_FR)
|
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5) || result.includes(SLIDING_CAPTCHA_FR_6)) {
|
||||||
|| result.includes(SLIDING_CAPTCHA_EN)
|
|
||||||
|| result.includes(SLIDING_CAPTCHA_FR_2)
|
|
||||||
|| result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5) || result.includes(SLIDING_CAPTCHA_FR_6)) {
|
|
||||||
if (result.includes(SLIDING_CAPTCHA_LOADING_FR)) {
|
if (result.includes(SLIDING_CAPTCHA_LOADING_FR)) {
|
||||||
return OCRResult.SLIDING_CAPTCHA_LOADING
|
return OCRResult.SLIDING_CAPTCHA_LOADING
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +156,14 @@ class OCRChecker {
|
|||||||
// if (result.includes("rac"))
|
// if (result.includes("rac"))
|
||||||
// return OCRResult.SLIDING_CAPTCHA_REFRESH
|
// return OCRResult.SLIDING_CAPTCHA_REFRESH
|
||||||
return OCRResult.SLIDING_CAPTCHA
|
return OCRResult.SLIDING_CAPTCHA
|
||||||
} else if (result.includes(WELCOME_MESSAGE_FR)) {
|
} else if (result.includes(SLIDING_CAPTCHA_RETRY_FR)
|
||||||
|
) {
|
||||||
|
await this.deleteFile(fileName)
|
||||||
|
return OCRResult.TERMINAED
|
||||||
|
} else if (result.includes(WELCOME_MESSAGE_FR)
|
||||||
|
|| result.includes(WELCOME_MESSAGE_FR_2)
|
||||||
|
|| result.includes(WELCOME_MESSAGE_FR_3)
|
||||||
|
) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.NEED_TO_CLICK_LATE_BTN
|
return OCRResult.NEED_TO_CLICK_LATE_BTN
|
||||||
} else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {
|
} else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {
|
||||||
@@ -201,13 +195,10 @@ class OCRChecker {
|
|||||||
} else if (result.includes(NO_INTERNET_FR) || result.includes(NO_INTERNET_FR_2)) {
|
} else if (result.includes(NO_INTERNET_FR) || result.includes(NO_INTERNET_FR_2)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.NO_INTERNET
|
return OCRResult.NO_INTERNET
|
||||||
} else if (result.includes(BRAVE_SKIP_DEFAULT_PAGE) || result.includes(BRAVE_SKIP_DEFAULT_PAGE_EN) || result.includes(BRAVE_SKIP_DEFAULT_PAGE_2)) {
|
} else if (result.includes(BRAVE_SKIP_DEFAULT_PAGE) || result.includes(BRAVE_SKIP_DEFAULT_PAGE_2)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_SKIP
|
return OCRResult.BRAVE_SKIP
|
||||||
} else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE)
|
} else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE) || result.includes(BRAVE_SKIP_PRIVACY_PAGE_2) || result.includes(BRAVE_SKIP_PRIVACY_PAGE_3)) {
|
||||||
|| result.includes(BRAVE_SKIP_PRIVACY_PAGE_2)
|
|
||||||
|| result.includes(BRAVE_SKIP_PRIVACY_PAGE_EN)
|
|
||||||
|| result.includes(BRAVE_SKIP_PRIVACY_PAGE_3)) {
|
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_PRIVACY
|
return OCRResult.BRAVE_PRIVACY
|
||||||
} else {
|
} else {
|
||||||
@@ -230,9 +221,9 @@ class OCRChecker {
|
|||||||
|
|
||||||
async take_screen_shot() {
|
async take_screen_shot() {
|
||||||
let name = this.get_file_name()
|
let name = this.get_file_name()
|
||||||
console.log("will take screenshot for " + this.device.model() + ":" + this.device.serial())
|
console.log("will take screenshot for " + this.device.model + ":" + this.device.serial)
|
||||||
console.log("name is " + name)
|
console.log("OCRChecker.name is " + name)
|
||||||
let stdout1 = await exec("adb -s " + this.device.serial() + " exec-out screencap -p > " + name)
|
let stdout1 = await exec("adb -s " + this.device.serial + " exec-out screencap -p > " + name)
|
||||||
await delay(5000);
|
await delay(5000);
|
||||||
console.log(`stdout: ${stdout1}`);
|
console.log(`stdout: ${stdout1}`);
|
||||||
return name
|
return name
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ const axios = require("axios");
|
|||||||
const {v4: uuidv4} = require('uuid');
|
const {v4: uuidv4} = require('uuid');
|
||||||
const OCRResult = require("../models/OCRResult");
|
const OCRResult = require("../models/OCRResult");
|
||||||
|
|
||||||
const DEEPLEARNING_CAPTCHA_HOST = "http://appointment.lpaconsulting.fr:9000"
|
const DEEPLEARNING_CAPTCHA_HOST = "http://appointment.lpaconsulting.fr:9000"
|
||||||
// const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.0.36:9000"
|
// const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.1.200:9000"
|
||||||
|
//const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.0.35:9000"
|
||||||
|
|
||||||
|
|
||||||
function delay(delayInMs) {
|
function delay(delayInMs) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -30,8 +32,8 @@ class SlidingCaptchaSolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async take_screen_shot(name, device) {
|
async take_screen_shot(name, device) {
|
||||||
console.log("will take screenshot for " + device.model() + ":" + device.serial())
|
console.log("will take screenshot for " + device.model + ":" + device.serial)
|
||||||
let stdout1 = await exec("adb -s " + device.serial() + " exec-out screencap -p > " + name)
|
let stdout1 = await exec("adb -s " + device.serial + " exec-out screencap -p > " + name)
|
||||||
// await delay(5000);
|
// await delay(5000);
|
||||||
console.log(`stdout: ${stdout1}`);
|
console.log(`stdout: ${stdout1}`);
|
||||||
await delay(5000);
|
await delay(5000);
|
||||||
@@ -47,7 +49,7 @@ class SlidingCaptchaSolver {
|
|||||||
//get resolution of screen
|
//get resolution of screen
|
||||||
console.log("sliding_captcha.sendRequest:" + blockedImageFileName)
|
console.log("sliding_captcha.sendRequest:" + blockedImageFileName)
|
||||||
await this.sendRequest(blockedImageFileName, async (detectedPositionList) => {
|
await this.sendRequest(blockedImageFileName, async (detectedPositionList) => {
|
||||||
console.log("detectedPosition: " + device.model() + ":" + detectedPositionList);
|
console.log("detectedPosition: " + device.model + ":" + detectedPositionList);
|
||||||
if (detectedPositionList.length >= 2) {
|
if (detectedPositionList.length >= 2) {
|
||||||
// #xiaomi
|
// #xiaomi
|
||||||
let startPosition = detectedPositionList.filter((positionInfo) => {
|
let startPosition = detectedPositionList.filter((positionInfo) => {
|
||||||
@@ -63,7 +65,7 @@ class SlidingCaptchaSolver {
|
|||||||
let x1 = (targetPosition.x2 + targetPosition.x1) / 2.0;
|
let x1 = (targetPosition.x2 + targetPosition.x1) / 2.0;
|
||||||
let width = targetPosition.x2 - targetPosition.x1;
|
let width = targetPosition.x2 - targetPosition.x1;
|
||||||
let randomTime = randomIntFromInterval(100, 500)
|
let randomTime = randomIntFromInterval(100, 500)
|
||||||
let cmd = `adb -s ${device.serial()} shell input touchscreen swipe ${x0} ${y0} ${x1 + width * 0.5} ${y0} ${600 + randomTime}`
|
let cmd = `adb -s ${device.serial} shell input touchscreen swipe ${x0} ${y0} ${x1 + width * 0.5} ${y0} ${600 + randomTime}`
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
console.log("cmd is " + cmd);
|
console.log("cmd is " + cmd);
|
||||||
console.log("will slide captcha");
|
console.log("will slide captcha");
|
||||||
@@ -72,11 +74,11 @@ class SlidingCaptchaSolver {
|
|||||||
await this.deleteFile(blockedImageFileName)
|
await this.deleteFile(blockedImageFileName)
|
||||||
onResult(true)
|
onResult(true)
|
||||||
} else {
|
} else {
|
||||||
console.log("startPosition not found for " + device.model())
|
console.log("startPosition not found for " + device.model)
|
||||||
onResult(false)
|
onResult(false)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("startPosition not found for " + device.model())
|
console.log("startPosition not found for " + device.model)
|
||||||
onResult(false)
|
onResult(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ const {startBookWithNumbers} = require('./src/appointment')
|
|||||||
const {homedir} = require("os");
|
const {homedir} = require("os");
|
||||||
homeDir = homedir()
|
homeDir = homedir()
|
||||||
//faubourg, random
|
//faubourg, random
|
||||||
startBookWithNumbers(0, 10000, "random", homeDir + "/Desktop/contact_list_2024-09-19.xlsx", true, false).then((r) => {
|
startBookWithNumbers(0, 10000, "random", homeDir + "/Desktop/16_04_to_test.xlsx", true, false).then((r) => {
|
||||||
console.log(r)
|
console.log(r)
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user