Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d5d6534cb | |||
| 56347a83f1 | |||
| f44b83375d | |||
| 703ca3d694 | |||
| 7cc4f87e0b | |||
| 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,81 @@
|
|||||||
|
const {exec} = require("child_process");
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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}
|
||||||
+56
-98
@@ -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,20 +5,21 @@ 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 = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fuljaueqguugf6pn", "fmiz5pa6rsx4u4ts"]
|
||||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fmiz5pa6rsx4u4ts"]
|
||||||
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 nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
attributedPorts = []
|
attributedPorts = []
|
||||||
const device_port_info = new Map();
|
const device_port_info = new Map();
|
||||||
startPort = 9000
|
startPort = 9000
|
||||||
@@ -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, 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();
|
||||||
@@ -135,7 +74,7 @@ async function startBook(contactPojo, device, sender, selectedStore, audioAnalys
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, alertBeep, port);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -143,14 +82,14 @@ async function startBook(contactPojo, device, sender, selectedStore, audioAnalys
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startWithList(contacts, device, sender, selectedStore, alertBeep, port) {
|
||||||
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
let duplicatedList = [].concat(contacts).concat(contacts).concat(contacts)
|
||||||
await duplicatedList.reduce(async (promise, contactPojo) => {
|
await duplicatedList.reduce(async (promise, contactPojo) => {
|
||||||
// This line will wait for the last async function to finish.
|
// This line will wait for the last async function to finish.
|
||||||
// The first iteration uses an already resolved Promise
|
// The first iteration uses an already resolved Promise
|
||||||
// so, it will immediately continue.
|
// so, it will immediately continue.
|
||||||
await promise;
|
await promise;
|
||||||
const contents = await startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
const contents = await startBook(contactPojo, device, sender, selectedStore, alertBeep, port);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
@@ -179,9 +118,17 @@ function shuffle(array) {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
|
function getContactListForDevice(device, allContactList) {
|
||||||
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
|
let contactList = [];
|
||||||
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
|
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', bindSerial = true, alertBeep = false) {
|
||||||
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
let allContactList = excelUtil.readContacts(pathToExcelFile);
|
||||||
let contactList;
|
let contactList;
|
||||||
if (endNumber <= allContactList.length) {
|
if (endNumber <= allContactList.length) {
|
||||||
@@ -198,22 +145,20 @@ 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);
|
||||||
}
|
}
|
||||||
// start chrome
|
|
||||||
// device.shell("am start -n com.brave.browser/com.google.android.apps.chrome.Main")
|
|
||||||
return attributedPort
|
return attributedPort
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,33 +171,46 @@ 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 = ["127.0.0.1:6555"]
|
||||||
|
}
|
||||||
|
let filteredDeviceList;
|
||||||
|
if (includeMode === DeviceExcludeMode.ZERO) {
|
||||||
|
filteredDeviceList = devices
|
||||||
|
} else {
|
||||||
|
filteredDeviceList = devices.filter(device => device_to_excludes.includes(device.serial))
|
||||||
}
|
}
|
||||||
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 = []
|
||||||
|
if (bindSerial) {
|
||||||
|
_contactList = getContactListForDevice(device, listWithoutBlackContact)
|
||||||
|
} else {
|
||||||
|
_contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
|
||||||
|
}
|
||||||
|
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
|
||||||
|
startWithList(_contactList, device, sender, selectedStore, 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
|
||||||
@@ -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}`);
|
||||||
|
|||||||
+151
-148
@@ -11,6 +11,7 @@ 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 {page} = require("yarn/lib/cli");
|
||||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
// 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"
|
||||||
@@ -50,6 +51,12 @@ function getRandom() {
|
|||||||
return Math.floor(Math.random() * 3);
|
return Math.floor(Math.random() * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRandomId() {
|
||||||
|
let _list = [PASSPORT_ID, EMAIL_ID, FIRST_NAME, LAST_NAME];
|
||||||
|
let index = Math.floor(Math.random() * _list.length);
|
||||||
|
return _list[index];
|
||||||
|
}
|
||||||
|
|
||||||
function getRandomWaitTime() {
|
function getRandomWaitTime() {
|
||||||
return getRandom() * 1000
|
return getRandom() * 1000
|
||||||
}
|
}
|
||||||
@@ -59,25 +66,25 @@ function log(message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function clearApp(device, packageName) {
|
async function clearApp(device, packageName) {
|
||||||
let cmd = `adb -s ${device.serial()} shell pm clear ${packageName}`
|
let cmd = `adb -s ${device.serial} shell pm clear ${packageName}`
|
||||||
logWithDevice("cmd is " + cmd, device)
|
logWithDevice("cmd is " + cmd, device)
|
||||||
await exec(cmd);
|
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']
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, alertBeep = false, port = 9000, shareCookiesWithRequests = true) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
// to remove this line if we want to use store in contacts
|
// to remove this line if we want to use store in contacts
|
||||||
// this.contact.store = DEFAULT_STORE
|
// this.contact.store = DEFAULT_STORE
|
||||||
@@ -88,9 +95,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 +203,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 +226,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()
|
||||||
@@ -397,15 +405,15 @@ 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(() => {
|
||||||
let field = document.getElementById("surname");
|
// let field = document.getElementById("surname");
|
||||||
if (field) {
|
// if (field) {
|
||||||
field.value = ""
|
// field.value = ""
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
await delay(1000);
|
await delay(1000);
|
||||||
// await page.keyboard.type(this.contact.lastName);
|
// await page.keyboard.type(this.contact.lastName);
|
||||||
await page.evaluate((lastName) => {
|
await page.evaluate((lastName) => {
|
||||||
@@ -421,7 +429,6 @@ class CommandorPage {
|
|||||||
let field = document.getElementById("name");
|
let field = document.getElementById("name");
|
||||||
if (field) {
|
if (field) {
|
||||||
field.value = firstName;
|
field.value = firstName;
|
||||||
// field.value = ""
|
|
||||||
}
|
}
|
||||||
}, this.contact.firstName)
|
}, this.contact.firstName)
|
||||||
// await page.keyboard.type(this.contact.firstName);
|
// await page.keyboard.type(this.contact.firstName);
|
||||||
@@ -504,10 +511,8 @@ class CommandorPage {
|
|||||||
document.querySelector("#cgu").checked = true
|
document.querySelector("#cgu").checked = true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// await page.click(CGU_ID);
|
|
||||||
await delay(getRandomWaitTime());
|
await delay(getRandomWaitTime());
|
||||||
await page.focus(PROCESSING_ID);
|
await page.focus(PROCESSING_ID);
|
||||||
// await page.click(PROCESSING_ID)
|
|
||||||
await page.evaluate(() => {
|
await page.evaluate(() => {
|
||||||
if (!document.querySelector("#processing").checked) {
|
if (!document.querySelector("#processing").checked) {
|
||||||
document.querySelector("#processing").checked = true
|
document.querySelector("#processing").checked = true
|
||||||
@@ -580,9 +585,15 @@ class CommandorPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async clickValid() {
|
async clickValid() {
|
||||||
logWithDevice("clickValid() called.", this.device);
|
logWithDevice("clickValid() called.", this.device);
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
let _id_to_click = getRandomId()
|
||||||
|
await this.page.click(_id_to_click)
|
||||||
await delay(getRandomWaitTime())
|
await delay(getRandomWaitTime())
|
||||||
|
}
|
||||||
|
|
||||||
this.isFillingFields = false
|
this.isFillingFields = false
|
||||||
try {
|
try {
|
||||||
if (!this.page.isClosed()) {
|
if (!this.page.isClosed()) {
|
||||||
@@ -611,7 +622,7 @@ class CommandorPage {
|
|||||||
this.contact.firstName = raw.firstName
|
this.contact.firstName = raw.firstName
|
||||||
}
|
}
|
||||||
await this.page.evaluate(() => {
|
await this.page.evaluate(() => {
|
||||||
document.getElementsByClassName("btn")[0].click();
|
document.getElementsByTagName("button")[1].click();
|
||||||
})
|
})
|
||||||
if (this.firstStart) {
|
if (this.firstStart) {
|
||||||
this.disconnectBrowser();
|
this.disconnectBrowser();
|
||||||
@@ -634,11 +645,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()
|
||||||
@@ -732,14 +738,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)
|
||||||
})
|
})
|
||||||
@@ -778,11 +783,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 {
|
||||||
@@ -846,7 +857,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",
|
||||||
@@ -861,7 +872,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);
|
||||||
@@ -874,25 +885,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;
|
||||||
@@ -904,7 +896,24 @@ class CommandorPage {
|
|||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
break;
|
break;
|
||||||
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
case OCRResult.SLIDING_CAPTCHA_REFRESH:
|
||||||
await this.connect_to_browser(checkResult)
|
this.isTerminated = true;
|
||||||
|
break;
|
||||||
|
case OCRResult.SLIDING_CAPTCHA:
|
||||||
|
this.isAlreadyRefresh = true;
|
||||||
|
// await this.generateRandomActions()
|
||||||
|
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;
|
break;
|
||||||
case OCRResult.FILL_FIELD:
|
case OCRResult.FILL_FIELD:
|
||||||
logWithDevice("FILL_FIELD", this.device)
|
logWithDevice("FILL_FIELD", this.device)
|
||||||
@@ -921,6 +930,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 {
|
||||||
@@ -942,35 +952,6 @@ class CommandorPage {
|
|||||||
await this.resetBrowser()
|
await this.resetBrowser()
|
||||||
// this.isTerminated = true;
|
// this.isTerminated = true;
|
||||||
}
|
}
|
||||||
// try {
|
|
||||||
// for (const currentPage of pages) {
|
|
||||||
// if (currentPage.url() === RDV_URL) {
|
|
||||||
// logWithDevice("get content", this.device)
|
|
||||||
// let pageContent = await currentPage.content()
|
|
||||||
// logWithDevice("content:" + pageContent, this.device)
|
|
||||||
// if (!pageContent.includes("geo.captcha-delivery.com")) {
|
|
||||||
// this.page = currentPage;
|
|
||||||
// break
|
|
||||||
// } else {
|
|
||||||
// try {
|
|
||||||
// await currentPage.close()
|
|
||||||
// } catch (e) {
|
|
||||||
// console.log(e)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// try {
|
|
||||||
// await currentPage.close()
|
|
||||||
// } catch (e) {
|
|
||||||
// console.log(e)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (e) {
|
|
||||||
// this.isTerminated = true;
|
|
||||||
// console.log(e)
|
|
||||||
// }
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
@@ -981,9 +962,20 @@ 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.await
|
|
||||||
await this.fillFields(this.page)
|
await this.fillFields(this.page)
|
||||||
await delay(2 * 1000);
|
await delay(2 * 1000);
|
||||||
}
|
}
|
||||||
@@ -1012,23 +1004,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 {
|
||||||
@@ -1041,9 +1033,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)
|
||||||
@@ -1058,11 +1050,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)
|
||||||
@@ -1079,18 +1071,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
|
||||||
@@ -1141,8 +1136,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
|
||||||
@@ -1319,10 +1314,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)
|
||||||
@@ -1330,7 +1325,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)
|
||||||
@@ -1344,33 +1339,27 @@ 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)
|
|
||||||
await exec(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
async inputForDevice(device, 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);
|
||||||
@@ -1378,35 +1367,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)
|
||||||
@@ -1420,22 +1409,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)
|
||||||
@@ -1450,22 +1444,33 @@ 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 === "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);
|
||||||
@@ -1474,11 +1479,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 {
|
||||||
@@ -1491,27 +1494,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)
|
||||||
@@ -1539,7 +1542,7 @@ 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
|
||||||
|
|||||||
+21
-10
@@ -17,6 +17,7 @@ const NO_INTERNET_FR_2 = "Aucun accès à Internet"
|
|||||||
const BRAVE_VPN_SKIP = "Pare-feu + VPN Brave"
|
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 MESSAGE_URL_VALIDATION_FR_3 = "vous allez recevoir un courriel de notre part"
|
||||||
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 = "Please click on the link we sent by email"
|
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"
|
||||||
@@ -36,6 +37,7 @@ 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 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_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"
|
||||||
@@ -46,9 +48,11 @@ const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
|||||||
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_FR_5 = "email vous sera envoyé pour vous"
|
const MESSAGE_FILL_FIELD_FR_5 = "demande de rendez-vous pour le"
|
||||||
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"
|
||||||
@@ -97,7 +101,10 @@ class OCRChecker {
|
|||||||
try {
|
try {
|
||||||
let result = await findText(fileName)
|
let result = await findText(fileName)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
if (result.includes(MESSAGE_URL_VALIDATION_EN)
|
||||||
|
|| result.includes(MESSAGE_URL_VALIDATION_FR)
|
||||||
|
|| result.toLowerCase().includes(MESSAGE_URL_VALIDATION_FR_3)
|
||||||
|
|| result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.SUCCESS
|
return OCRResult.SUCCESS
|
||||||
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
} else if (result.includes(BRAVE_NOTIFICATION)) {
|
||||||
@@ -118,7 +125,7 @@ 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) || 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)) {
|
} 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.toLowerCase().includes(MESSAGE_FILL_FIELD_FR_5) || 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(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
|
||||||
@@ -145,11 +152,15 @@ class OCRChecker {
|
|||||||
} else {
|
} else {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
}
|
}
|
||||||
// await this.deleteFile(screenShot)
|
|
||||||
// if (result.includes("rac"))
|
|
||||||
// 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)) {
|
||||||
@@ -207,9 +218,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-11.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