remove playwright
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
"node-tesseract-ocr": "^2.2.1",
|
||||
"node-wget": "^0.4.3",
|
||||
"node-xlsx": "^0.21.0",
|
||||
"playwright": "^1.39.0",
|
||||
"puppeteer": "^15.2.0",
|
||||
"read-ini-file": "^3.0.1",
|
||||
"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}
|
||||
+8
-68
@@ -6,6 +6,7 @@ const alert = require('alert');
|
||||
const schedule = require("node-schedule");
|
||||
const DeviceExcludeMode = require("./models/DeviceExcludeMode");
|
||||
const {Sender} = require("./queue/Sender");
|
||||
const {devices} = require("./android/adb");
|
||||
const mongoManager = new MongoManager();
|
||||
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
|
||||
// const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
|
||||
@@ -36,58 +37,10 @@ async function filterAlreadyBookedContacts(contactList) {
|
||||
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) {
|
||||
console.log("check contact with email " + contact.mail)
|
||||
// let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
// let blackListItems = await mongoManager.getAllBlackedListItems();
|
||||
let blackListItems = [];
|
||||
// let alreadyAcceptedItems = await mongoManager.getAllAcceptedAppointments();
|
||||
let needToBook = true;
|
||||
await alreadyBooked.forEach((bookedItem) => {
|
||||
if (bookedItem.email === contact.mail) {
|
||||
@@ -108,25 +61,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
|
||||
}
|
||||
|
||||
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||
console.log(`model: ${device.model()}`);
|
||||
console.log(`serial: ${device.serial()}`);
|
||||
console.log(`model: ${device.model}`);
|
||||
console.log(`serial: ${device.serial}`);
|
||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||
const d = new Date();
|
||||
let hour = d.getHours();
|
||||
@@ -198,16 +138,16 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
console.log("startForwordingForDevice() called")
|
||||
const execSync = require('child_process').execSync;
|
||||
// get attributed port
|
||||
let attributedPort = device_port_info[device.serial()]
|
||||
let attributedPort = device_port_info[device.serial]
|
||||
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);
|
||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||
console.log('Output was:\n', output);
|
||||
} else {
|
||||
attributedPort = 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);
|
||||
const output = execSync(cmd, {encoding: 'utf-8'}); // the default is 'buffer'
|
||||
console.log('Output was:\n', output);
|
||||
@@ -226,7 +166,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
filterAlreadyBookedContacts(contactList).then((listWithoutBlackContact) => {
|
||||
console.log("will call filterAlreadyAcceptedContacts")
|
||||
console.log("number of contacts to book:" + listWithoutBlackContact.length)
|
||||
android.devices().then((devices) => {
|
||||
devices().then((devices) => {
|
||||
if (devices.length === 0) {
|
||||
alert("未找到连接的设备");
|
||||
return
|
||||
@@ -245,7 +185,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
||||
} else if (excludeMode === DeviceExcludeMode.ZERO) {
|
||||
device_to_excludes = []
|
||||
}
|
||||
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;
|
||||
console.log("connected device number:" + filteredDeviceList.length)
|
||||
console.log("segmentNumber:" + segmentNumber)
|
||||
|
||||
@@ -37,8 +37,8 @@ function cmdExecute(command) {
|
||||
|
||||
async function openUrlWithAdb(url, device) {
|
||||
// do not continue if device is blocked
|
||||
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
|
||||
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
|
||||
try {
|
||||
let output = await cmdExecute(cmd);
|
||||
console.log(`stdout: ${output}`);
|
||||
|
||||
@@ -59,19 +59,19 @@ function log(message) {
|
||||
}
|
||||
|
||||
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)
|
||||
await exec(cmd);
|
||||
}
|
||||
|
||||
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)
|
||||
await exec(cmd);
|
||||
}
|
||||
|
||||
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']
|
||||
@@ -195,9 +195,9 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
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 {
|
||||
// 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 delay(1 * 1000);
|
||||
// await this.startPage(this.device, this.browserPackageName + "/com.google.android.apps.chrome.Main")
|
||||
@@ -218,7 +218,7 @@ class CommandorPage {
|
||||
let cancel
|
||||
const intervalTask = setInterval(async () => {
|
||||
if (this.isTerminated) {
|
||||
log(this.device.model() + ":request terminated, send cancel()");
|
||||
logWithDevice(":request terminated, send cancel()", this.device)
|
||||
try {
|
||||
if (this.page !== undefined && !this.page.isClosed()) {
|
||||
await this.page.close()
|
||||
@@ -634,11 +634,6 @@ class CommandorPage {
|
||||
|
||||
async resolveCaptcha(page) {
|
||||
logWithDevice("resolveCaptcha", this.device)
|
||||
if (RDV_URL.includes("192")) {
|
||||
// await this.push_message_to_queue(PublishType.SUCCESS)
|
||||
await delay(100000)
|
||||
return
|
||||
}
|
||||
try {
|
||||
//check whether there is captcha
|
||||
let pageContent = await page.content()
|
||||
@@ -733,8 +728,8 @@ class CommandorPage {
|
||||
|
||||
async slidingCaptcha(onResult) {
|
||||
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") {
|
||||
let cmd = `adb -s ${this.device.serial()} shell input touchscreen swipe 900 495 900 195`
|
||||
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`
|
||||
await exec(cmd);
|
||||
await delay(5000);
|
||||
}
|
||||
@@ -781,9 +776,9 @@ class CommandorPage {
|
||||
}
|
||||
// save to mongoDb
|
||||
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.serial = this.device.serial();
|
||||
reserve.serial = this.device.serial;
|
||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||
if (!this.page.isClosed()) {
|
||||
try {
|
||||
@@ -862,7 +857,7 @@ class CommandorPage {
|
||||
|
||||
async checkResultWithOcr() {
|
||||
logWithDevice("checkResultWithOcr() called.", this.device)
|
||||
if (this.device.model() === "M2006C3LG")
|
||||
if (this.device.model === "M2006C3LG")
|
||||
await delay(6000);
|
||||
else {
|
||||
await delay(4000);
|
||||
@@ -999,23 +994,23 @@ class CommandorPage {
|
||||
await this.checkResultWithOcr();
|
||||
break;
|
||||
case OCRResult.BRAVE_PRIVACY:
|
||||
let model = this.device.model()
|
||||
if (model === "MI 5s" || this.device.model() === "SM-G965U1" || this.device.model() === "ASUS_Z012D") {
|
||||
let model = this.device.model
|
||||
if (model === "MI 5s" || this.device.model === "SM-G965U1" || this.device.model === "ASUS_Z012D") {
|
||||
await this.tapForDevice(this.device, 530, 970)
|
||||
} else if (model === "HUAWEI NXT-TL00") {
|
||||
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)
|
||||
} else if (this.device.model() === "moto g51 5G") {
|
||||
} else if (this.device.model === "moto g51 5G") {
|
||||
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)
|
||||
} 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)
|
||||
} 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, 1120)
|
||||
} else if (this.device.model() === "DE2117") {
|
||||
} else if (this.device.model === "DE2117") {
|
||||
await this.tapForDevice(this.device, 545, 1130)
|
||||
} else
|
||||
try {
|
||||
@@ -1028,9 +1023,9 @@ class CommandorPage {
|
||||
await this.checkResultWithOcr();
|
||||
break;
|
||||
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)
|
||||
} else if (this.device.model() === "HUAWEI NXT-TL00") {
|
||||
} else if (this.device.model === "HUAWEI NXT-TL00") {
|
||||
await this.tapForDevice(this.device, 530, 950)
|
||||
} else
|
||||
await this.tapForDevice(this.device, 455, 1920)
|
||||
@@ -1045,11 +1040,11 @@ class CommandorPage {
|
||||
break
|
||||
case OCRResult.BRAVE_NOTIFICATION:
|
||||
logWithDevice("BRAVE_NOTIFICATION", this.device)
|
||||
if (this.device.model() === "21091116C") {
|
||||
if (this.device.model === "21091116C") {
|
||||
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)
|
||||
} else if (this.device.model() === "CPH2469") {
|
||||
} else if (this.device.model === "CPH2469") {
|
||||
await this.tapForDevice(this.device, 322, 1146)
|
||||
} else
|
||||
await this.tapForDevice(this.device, 500, 1680)
|
||||
@@ -1066,14 +1061,14 @@ class CommandorPage {
|
||||
break;
|
||||
case OCRResult.BRAVE_VPN_SKIP:
|
||||
logWithDevice("BRAVE_VPN_SKIP", this.device)
|
||||
if (this.device.model() === "M2006C3LG") {
|
||||
if (this.device.model === "M2006C3LG") {
|
||||
await this.tapForDevice(this.device, 580, 445)
|
||||
}
|
||||
break;
|
||||
case OCRResult.TO_SKIP
|
||||
:
|
||||
logWithDevice("TO_SKIP", this.device)
|
||||
if (this.device.model() === "21091116C" || this.device.model() === "22041219PG") {
|
||||
if (this.device.model === "21091116C" || this.device.model === "22041219PG") {
|
||||
await this.tapForDevice(this.device, 530, 1742)
|
||||
await delay(1000);
|
||||
await this.tapForDevice(this.device, 530, 1742)
|
||||
@@ -1309,7 +1304,7 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async handleBraveSkipBtn() {
|
||||
let model = this.device.model()
|
||||
let model = this.device.model
|
||||
if (model === "CPH2219") {
|
||||
await this.tapForDevice(this.device, 558, 1160)
|
||||
} else if (model === "MI 5s" || model === "ASUS_Z012D") {
|
||||
@@ -1334,32 +1329,32 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
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)
|
||||
await exec(cmd);
|
||||
}
|
||||
|
||||
async swipeForDevice(device, x0, y0, x1, y1) {
|
||||
// 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}`
|
||||
let cmd = `adb -s ${device.serial} shell input text ${text}`
|
||||
logWithDevice("cmd is " + cmd, this.device)
|
||||
await exec(cmd);
|
||||
}
|
||||
|
||||
async clickOnConfirmBtn() {
|
||||
if (this.device.model() === "CPH2219") {
|
||||
if (this.device.model === "CPH2219") {
|
||||
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)
|
||||
} else if (this.device.model() === "22041219PG") {
|
||||
} else if (this.device.model === "22041219PG") {
|
||||
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)
|
||||
} else
|
||||
this.device.shell("input tap " + 933 + " " + 1538)
|
||||
@@ -1368,35 +1363,35 @@ class CommandorPage {
|
||||
|
||||
async clickOnHomeBtn() {
|
||||
// await this.enableDisableAirPlanMode()
|
||||
if (this.device.model() === "22041219PG") {
|
||||
if (this.device.model === "22041219PG") {
|
||||
await this.tapForDevice(this.device, 110, 2208)
|
||||
await delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
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 delay(2000);
|
||||
await openUrlWithAdb(RDV_URL, this.device)
|
||||
@@ -1410,7 +1405,7 @@ class CommandorPage {
|
||||
|
||||
async skipOptimizationPage() {
|
||||
logWithDevice("skipOptimizationPage", this.device)
|
||||
let model = this.device.model();
|
||||
let model = this.device.model;
|
||||
if (model === "ASUS_X00QD") {
|
||||
this.device.shell("input tap " + 800 + " " + 2100)
|
||||
await delay(2000);
|
||||
@@ -1440,7 +1435,7 @@ class CommandorPage {
|
||||
|
||||
async tapLaterBtn() {
|
||||
logWithDevice("tapLaterBtn", this.device)
|
||||
let model = this.device.model();
|
||||
let model = this.device.model;
|
||||
log("model is " + model);
|
||||
if (model === "CPH2219") {
|
||||
this.device.shell("input tap " + 385 + " " + 1930)
|
||||
@@ -1488,27 +1483,27 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async tapGoogleDisconnectBtn() {
|
||||
if (this.device.model() === "MI 5s") {
|
||||
if (this.device.model === "MI 5s") {
|
||||
if (this.browserPackageName.includes("brave")) {
|
||||
await this.tapForDevice(this.device, 535, 1629)
|
||||
} else
|
||||
await this.device.shell("input tap " + 550 + " " + 1740)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} 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)
|
||||
} else {
|
||||
await this.tapForDevice(this.device, 411, 2100)
|
||||
@@ -1536,7 +1531,7 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async handleBravePushNotification() {
|
||||
let model = this.device.model()
|
||||
let model = this.device.model
|
||||
if (model === "KB2003" || model === "22041219PG" || model === "DE2117" || model === "21091116C") {
|
||||
await this.tapForDevice(this.device, 545, 1448)
|
||||
} else
|
||||
|
||||
@@ -210,9 +210,9 @@ class OCRChecker {
|
||||
|
||||
async take_screen_shot() {
|
||||
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)
|
||||
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);
|
||||
console.log(`stdout: ${stdout1}`);
|
||||
return name
|
||||
|
||||
@@ -32,8 +32,8 @@ class SlidingCaptchaSolver {
|
||||
}
|
||||
|
||||
async take_screen_shot(name, device) {
|
||||
console.log("will take screenshot for " + device.model() + ":" + device.serial())
|
||||
let stdout1 = await exec("adb -s " + device.serial() + " exec-out screencap -p > " + name)
|
||||
console.log("will take screenshot for " + device.model + ":" + device.serial)
|
||||
let stdout1 = await exec("adb -s " + device.serial + " exec-out screencap -p > " + name)
|
||||
// await delay(5000);
|
||||
console.log(`stdout: ${stdout1}`);
|
||||
await delay(5000);
|
||||
@@ -49,7 +49,7 @@ class SlidingCaptchaSolver {
|
||||
//get resolution of screen
|
||||
console.log("sliding_captcha.sendRequest:" + blockedImageFileName)
|
||||
await this.sendRequest(blockedImageFileName, async (detectedPositionList) => {
|
||||
console.log("detectedPosition: " + device.model() + ":" + detectedPositionList);
|
||||
console.log("detectedPosition: " + device.model + ":" + detectedPositionList);
|
||||
if (detectedPositionList.length >= 2) {
|
||||
// #xiaomi
|
||||
let startPosition = detectedPositionList.filter((positionInfo) => {
|
||||
@@ -65,7 +65,7 @@ class SlidingCaptchaSolver {
|
||||
let x1 = (targetPosition.x2 + targetPosition.x1) / 2.0;
|
||||
let width = targetPosition.x2 - targetPosition.x1;
|
||||
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);
|
||||
console.log("cmd is " + cmd);
|
||||
console.log("will slide captcha");
|
||||
@@ -74,11 +74,11 @@ class SlidingCaptchaSolver {
|
||||
await this.deleteFile(blockedImageFileName)
|
||||
onResult(true)
|
||||
} else {
|
||||
console.log("startPosition not found for " + device.model())
|
||||
console.log("startPosition not found for " + device.model)
|
||||
onResult(false)
|
||||
}
|
||||
} else {
|
||||
console.log("startPosition not found for " + device.model())
|
||||
console.log("startPosition not found for " + device.model)
|
||||
onResult(false)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user