27 Commits

Author SHA1 Message Date
panleicim 703ca3d694 change include mode 2024-12-04 10:59:45 +01:00
panleicim 7cc4f87e0b stop when need to refresh captcha 2024-11-15 22:20:03 +01:00
panleicim 5a2b88139e add appointment mode 2024-11-12 00:22:51 +01:00
panleicim 6ce3a56ce2 support Mi note 10 2024-11-06 14:06:37 +01:00
panleicim f3a7188b31 Merge branch 'master' of bitbucket.org:panleicim/puppeteerjs 2024-10-11 09:33:06 +02:00
panleicim 24f95842ba add shuffle before booking 2024-10-11 09:32:22 +02:00
panleicim 9657007a5b Merge branch 'feature/list_according_serail' 2024-10-05 16:49:15 +02:00
panleicim 9d70bf7097 do not need to bind contact list with mobiles 2024-10-05 16:48:25 +02:00
Lei PAN 9cfa650b31 correction for moto 2024-10-05 08:35:18 +02:00
panleicim b78c0de0ce support Oneplus 6 2024-10-02 19:19:43 +02:00
Lei PAN 87eca37d8b Merge branch 'feature/custom_adb' into feature/list_according_serail 2024-10-01 23:29:00 +02:00
Lei PAN a04ec8373d support moto 2024-10-01 23:28:09 +02:00
panleicim 842f87c784 bind contact list with phone serial 2024-10-01 22:58:32 +02:00
panleicim 9eb582a6e8 support mi 5s 2024-10-01 17:08:12 +02:00
panleicim f67b6a3383 support moto 2024-09-27 17:25:23 +02:00
panleicim f677febb3f support RMX3151 2024-09-26 00:09:20 +02:00
panleicim 538be86599 save browser ua 2024-09-25 14:56:42 +02:00
panleicim 4ee264c650 try to fix sliding probleme 2024-09-24 16:01:41 +02:00
panleicim 1c35cd1831 Merge branch 'master' into feature/custom_adb 2024-09-24 14:04:23 +02:00
Lei PAN 9adea7e9fa use same SlidingCaptchaSolver instance 2024-09-24 14:02:32 +02:00
panleicim 32f8b9812d remove playwright 2024-09-24 13:59:18 +02:00
Lei PAN 0115ad7139 use server captcha 2024-09-24 12:00:18 +02:00
panleicim ac60977177 support chrome 2024-09-22 23:29:23 +02:00
panleicim 87910a6524 support chrome 2024-09-21 19:00:47 +02:00
panleicim ff9c9bc07d support chrome 2024-09-21 12:48:23 +02:00
panleicim 6a0e37c166 Merge branch 'feature/brave_v1_65_133' of bitbucket.org:panleicim/puppeteerjs into feature/brave_v1_65_133 2024-09-20 20:39:36 +02:00
panleicim 56f85bee2d add sliding server of conflans 2024-09-20 20:38:26 +02:00
12 changed files with 294 additions and 245 deletions
-1
View File
@@ -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",
+81
View File
@@ -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}
+46 -90
View File
@@ -1,4 +1,3 @@
const {_android: android} = require('playwright');
const ExcelUtil = require("./excel/ExcelUtil");
const CommandorPage = require("./workers/CommandorPage");
const {MongoManager, formatDate} = require("./workers/mongo_manager");
@@ -6,20 +5,21 @@ 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;
const NINETY_DAYS_IN_S = 30 * 3;
let excelUtil = new ExcelUtil();
let collectionName = formatDate(new Date())
let excludeMode = DeviceExcludeMode.ZERO
let includeMode = DeviceExcludeMode.ZERO
// let includeMode = DeviceExcludeMode.APPOINTMENT
let three_to_excludes = ["e30eb015"]
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
let three_to_include = []
let four_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "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 nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
// let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fuljaueqguugf6pn", "fmiz5pa6rsx4u4ts"]
let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fmiz5pa6rsx4u4ts"]
let nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
attributedPorts = []
const device_port_info = new Map();
startPort = 9000
@@ -36,58 +36,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 +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
}
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();
@@ -179,9 +118,17 @@ function shuffle(array) {
return array;
}
function getContactListForDevice(device, allContactList) {
let contactList = [];
allContactList.forEach((contact) => {
if (contact.serial === device.serial) {
contactList.push(contact)
}
})
return contactList;
}
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
let allContactList = excelUtil.readContacts(pathToExcelFile);
let contactList;
if (endNumber <= allContactList.length) {
@@ -198,16 +145,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,33 +173,42 @@ 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
}
let device_to_excludes = three_to_excludes;
if (excludeMode === DeviceExcludeMode.FOUR) {
device_to_excludes = four_to_excludes;
} else if (excludeMode === DeviceExcludeMode.THREE) {
device_to_excludes = three_to_excludes;
} else if (excludeMode === DeviceExcludeMode.NINE) {
device_to_excludes = nine_to_excludes;
} else if (excludeMode === DeviceExcludeMode.SEVEN) {
let device_to_excludes = three_to_include;
if (includeMode === DeviceExcludeMode.FOUR) {
device_to_excludes = four_to_include;
} else if (includeMode === DeviceExcludeMode.THREE) {
device_to_excludes = three_to_include;
} else if (includeMode === DeviceExcludeMode.NINE) {
device_to_excludes = nine_to_include;
} else if (includeMode === DeviceExcludeMode.SEVEN) {
device_to_excludes = seven_to_excludes
} else if (excludeMode === DeviceExcludeMode.SIX) {
device_to_excludes = six_to_excludes
} else if (excludeMode === DeviceExcludeMode.ZERO) {
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
device_to_excludes = appointment_to_include
} else if (includeMode === DeviceExcludeMode.ZERO) {
device_to_excludes = []
}
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial()))
let filteredDeviceList;
if (includeMode === DeviceExcludeMode.ZERO) {
filteredDeviceList = devices
} else {
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)
listWithoutBlackContact = shuffle(listWithoutBlackContact)
for (let i = 0; i < filteredDeviceList.length; i++) {
let device = filteredDeviceList[i];
let port = startForwordingForDevice(device)
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
let _contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
// let _contactList = getContactListForDevice(device, listWithoutBlackContact)
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
startWithList(_contactList, device, sender, selectedStore, audioAnalyse, alertBeep, port);
}
})
+3 -2
View File
@@ -19,11 +19,12 @@ class ExcelUtil {
if (store === undefined || store.length === 0) {
store = "random"
}
let ipCountry = info[5];
let serial = info[5];
let ipCountry = info[6];
if (ipCountry === undefined || ipCountry.length === 0) {
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);
}
}
+2 -1
View File
@@ -1,6 +1,6 @@
class ContactPojo {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry, serial) {
this.phoneNumber = phoneNumber;
this.passportNumber = passportNumber;
this.lastName = lastName;
@@ -8,6 +8,7 @@ class ContactPojo {
this.mail = mail;
this.store = store;
this.ipCountry = ipCountry;
this.serial = serial;
}
}
+3 -2
View File
@@ -1,9 +1,10 @@
const DeviceExcludeMode = {
const DeviceIncludeMode = {
ZERO: Symbol("ZERO"),
NINE: Symbol("NINE"),
THREE: Symbol("THREE"),
SIX: Symbol("SIX"),
SEVEN: Symbol("SEVEN"),
APPOINTMENT: Symbol("APPOINTMENT"),
FOUR: Symbol("FOUR")
}
module.exports = DeviceExcludeMode
module.exports = DeviceIncludeMode
+3 -1
View File
@@ -19,6 +19,7 @@ class ReserveResultPojo {
this.hostName = hostName
this.currentIp = ""
this.created_at = new Date().toLocaleString()
this.browserInfo = ""
}
to_mongo_dict() {
@@ -35,7 +36,8 @@ class ReserveResultPojo {
serial: this.serial,
created_at: this.created_at,
hostName: this.hostName,
current_ip: this.currentIp
current_ip: this.currentIp,
browserInfo: this.browserInfo
}
}
+2 -2
View File
@@ -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}`);
+129 -130
View File
@@ -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']
@@ -88,9 +88,10 @@ class CommandorPage {
this.shareCookiesWithRequests = shareCookiesWithRequests;
this.port = port;
this.sender = sender;
this.slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
this.ocrChecker = new OCRChecker(this.device, this.contact);
this.browserPackageName = "com.brave.browser";
// this.browserPackageName = "com.android.chrome";
// this.browserPackageName = "com.brave.browser";
this.browserPackageName = "com.android.chrome";
this.isFillingFields = false;
this.isTerminated = false;
this.cguChecked = false;
@@ -195,9 +196,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 +219,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()
@@ -397,7 +398,7 @@ class CommandorPage {
logWithDevice("input name called with this.isNameInput=" + this.isNameInput, this.device)
if (this.browser.isConnected() && !this.isTerminated && !this.page.isClosed()) {
if (!this.isNameInput) {
await page.focus(LAST_NAME);
// await page.focus(LAST_NAME);
await delay(getRandomWaitTime());
console.log("will clear surname field");
await page.evaluate(() => {
@@ -634,11 +635,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()
@@ -732,14 +728,13 @@ 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);
}
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
console.log("check isAlwaysBlocked")
await this.slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
logWithDevice("check isAlwaysBlocked", this.device)
this.isFillingFields = false
onResult(isSuccessful)
})
@@ -778,11 +773,17 @@ class CommandorPage {
if (url === "https://rendezvousparis.hermes.com/client/welcome") {
return
}
let browserInfo = await this.page.evaluate(() => {
const ua = navigator.userAgent;
return ua
})
console.log(browserInfo); // outputs: `Chrome 62`
// 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;
reserve.browserInfo = browserInfo;
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
if (!this.page.isClosed()) {
try {
@@ -846,7 +847,7 @@ class CommandorPage {
}
async connectBrowserIfNecessary() {
if (this.browser == undefined || !this.browser.isConnected()) {
if (this.browser === undefined || !this.browser.isConnected()) {
try {
this.browser = await puppeteer.connect({
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
@@ -861,7 +862,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);
@@ -874,25 +875,6 @@ class CommandorPage {
logWithDevice("will recheck OCR", this.device)
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) {
case OCRResult.SLIDING_CAPTCHA_LOADING:
this.isTerminated = true;
@@ -904,7 +886,22 @@ class CommandorPage {
this.isTerminated = true;
break;
case OCRResult.SLIDING_CAPTCHA_REFRESH:
await this.connect_to_browser(checkResult)
this.isTerminated = true;
break;
case OCRResult.SLIDING_CAPTCHA:
logWithDevice("will call this.slidingCaptcha()", this.device)
await this.slidingCaptcha(async (isSuccessful) => {
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
console.log(checkResult);
if (isSuccessful) {
await delay(5 * 1000)
// checkResult = await this.ocrChecker.get_result();
await this.checkResultWithOcr()
} else {
await this.checkResultWithOcr()
}
})
// await delay(5 * 1000)
break;
case OCRResult.FILL_FIELD:
logWithDevice("FILL_FIELD", this.device)
@@ -921,6 +918,7 @@ class CommandorPage {
// add listeners
let pages = await timeout(this.browser.pages(), 5 * 1000);
pages.forEach((currentPage) => {
logWithDevice("current url is " + currentPage.url(), this.device)
if (currentPage.url() === RDV_URL) {
this.page = currentPage;
} else {
@@ -942,35 +940,6 @@ class CommandorPage {
await this.resetBrowser()
// 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) {
console.log(e)
this.isTerminated = true
@@ -981,6 +950,19 @@ class CommandorPage {
if (this.browser.isConnected()) {
logWithDevice("will use old page", 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();
// this.page = pages;
// this.page.await
@@ -1012,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 {
@@ -1041,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)
@@ -1058,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)
@@ -1079,18 +1061,21 @@ 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")
await this.device.shell("input tap " + 530 + " " + 1742)
else
await this.device.shell("input tap " + 488 + " " + 1848)
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)
} else
await this.tapForDevice(this.device, 488, 1848)
await delay(2000);
await this.checkResultWithOcr();
break;
case
OCRResult.TO_REFRESH
@@ -1141,8 +1126,8 @@ class CommandorPage {
OCRResult.NEED_TO_CLICK_LATE_BTN
:
await this.tapLaterBtn()
this.firstStart = true;
await this.loadPage()
await delay(5000)
await this.checkResultWithOcr();
break;
case
OCRResult.CLOSED
@@ -1319,10 +1304,10 @@ 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") {
} else if (model === "MI_5s" || model === "ASUS_Z012D") {
await this.tapForDevice(this.device, 530, 1000)
} else if (model === "SM-G965U1") {
await this.tapForDevice(this.device, 530, 1000)
@@ -1330,7 +1315,7 @@ class CommandorPage {
await this.tapForDevice(this.device, 530, 950)
} else if (model === "M2006C3LG" || model === "220233L2G") {
await this.tapForDevice(this.device, 360, 777)
} else if (model === "ONEPLUS A6000") {
} else if (model === "ONEPLUS_A6000") {
await this.tapForDevice(this.device, 530, 1045)
} else if (model === "CPH2469") {
await this.tapForDevice(this.device, 360, 820)
@@ -1344,33 +1329,33 @@ 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") {
await this.tapForDevice(this.device, 950, 1434)
} else if (this.device.model === "moto_g51_5G") {
this.device.shell("input tap " + 950 + " " + 1434)
} else
this.device.shell("input tap " + 933 + " " + 1538)
await delay(2000);
@@ -1378,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)
@@ -1420,22 +1405,27 @@ 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);
this.device.shell("input tap " + 800 + " " + 2100)
await delay(1000);
} else if (model === "ONEPLUS A6000") {
} else if (model === "ONEPLUS_A6000") {
this.device.shell("input tap " + 818 + " " + 2140)
await delay(2000);
this.device.shell("input tap " + 818 + " " + 2140)
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") {
this.device.shell("input tap " + 772 + " " + 2146)
await delay(2000);
this.device.shell("input tap " + 772 + " " + 2146)
} else if (model === "MI 5s") {
} else if (model === "MI_5s") {
this.device.shell("input tap " + 786 + " " + 1780)
await delay(2000);
this.device.shell("input tap " + 790 + " " + 1807)
@@ -1450,22 +1440,33 @@ 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)
} else if (model === "ASUS_X00QD") {
this.device.shell("input tap " + 490 + " " + 1910)
} else if (model === "RMX3151") {
this.device.shell("input tap " + 492 + " " + 1960)
} else if (model === "Mi Note 10") {
this.device.shell("input tap " + 550 + " " + 1920)
} else if (model === "ONEPLUS A6000") {
this.device.shell("input tap " + 535 + " " + 1945)
} else if (model === "ONEPLUS_A6000") {
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") {
this.device.shell("input tap " + 540 + " " + 1985)
} else if (model === "21091116C") {
this.device.shell("input tap " + 510 + " " + 1975)
} else if (model === "MI 5s") {
} else if (model === "MI_5s") {
this.device.shell("input tap " + 510 + " " + 1615)
} else if (model === "Mi_Note_10") {
await this.tapForDevice(this.device, 498, 1910)
} else
this.device.shell("input tap " + 385 + " " + 2050)
await delay(1000);
@@ -1474,11 +1475,9 @@ class CommandorPage {
async enableDisableAirPlanMode() {
logWithDevice("will enable/disable airplane mode", this.device)
try {
// await this.device.shell("cmd connectivity airplane-mode enable")
await exceutShellCmd(this.device, "cmd connectivity airplane-mode enable")
await delay(1000)
await exceutShellCmd(this.device, "cmd connectivity airplane-mode disable")
// await this.device.shell("cmd connectivity airplane-mode disable")
await delay(2000)
} catch (e) {
try {
@@ -1491,27 +1490,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)
@@ -1539,7 +1538,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
+14 -7
View File
@@ -36,6 +36,7 @@ const ERR_CACHE_MISS_4 = "renvoyer les données"
const ERR_EMPTY_RESPONSE = "ERR_EMPTY_RESPONSE"
const ERR_SSL_PROTOCOL = "SSL_PROTOCOL_ERROR"
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
const SLIDING_CAPTCHA_RETRY_FR = "RÉESSAYER"
const SLIDING_CAPTCHA_LOADING_FR = "Chargement."
const SLIDING_CAPTCHA_FR_2 = "Glissez vers la droite pour"
const SLIDING_CAPTCHA_FR_3 = "la droite pour completer le puzzle"
@@ -49,6 +50,8 @@ 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_6 = "Prénom* Téléphone*"
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_6 = "Vous pouvez changer davis a tout moment"
const PAGE_OPTIMIZATION_CHROME_FR_2 = "Vous pouvez modifier vos options a tout moment"
@@ -145,11 +148,15 @@ class OCRChecker {
} else {
await this.deleteFile(fileName)
}
// await this.deleteFile(screenShot)
// if (result.includes("rac"))
// return OCRResult.SLIDING_CAPTCHA_REFRESH
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)
return OCRResult.NEED_TO_CLICK_LATE_BTN
} else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {
@@ -207,9 +214,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("name is " + name)
let stdout1 = await exec("adb -s " + this.device.serial() + " exec-out screencap -p > " + name)
console.log("will take screenshot for " + this.device.model + ":" + this.device.serial)
console.log("OCRChecker.name is " + name)
let stdout1 = await exec("adb -s " + this.device.serial + " exec-out screencap -p > " + name)
await delay(5000);
console.log(`stdout: ${stdout1}`);
return name
+10 -8
View File
@@ -5,8 +5,10 @@ const axios = require("axios");
const {v4: uuidv4} = require('uuid');
const OCRResult = require("../models/OCRResult");
const DEEPLEARNING_CAPTCHA_HOST = "http://appointment.lpaconsulting.fr:9000"
// const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.0.36:9000"
const DEEPLEARNING_CAPTCHA_HOST = "http://appointment.lpaconsulting.fr:9000"
// const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.1.200:9000"
//const DEEPLEARNING_CAPTCHA_HOST = "http://192.168.0.35:9000"
function delay(delayInMs) {
return new Promise(resolve => {
@@ -30,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);
@@ -47,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) => {
@@ -63,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");
@@ -72,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)
}
})
+1 -1
View File
@@ -2,6 +2,6 @@ const {startBookWithNumbers} = require('./src/appointment')
const {homedir} = require("os");
homeDir = homedir()
//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)
})