Merge branch 'feature/share_cookies'
This commit is contained in:
+2
-1
@@ -12,6 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nodegui/nodegui": "^0.57.1",
|
"@nodegui/nodegui": "^0.57.1",
|
||||||
"alert": "^5.1.1",
|
"alert": "^5.1.1",
|
||||||
|
"amqplib": "^0.10.3",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"jimp": "^0.22.8",
|
"jimp": "^0.22.8",
|
||||||
"mongodb": "^4.9.1",
|
"mongodb": "^4.9.1",
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
"node-wget": "^0.4.3",
|
"node-wget": "^0.4.3",
|
||||||
"node-xlsx": "^0.21.0",
|
"node-xlsx": "^0.21.0",
|
||||||
"playwright": "^1.39.0",
|
"playwright": "^1.39.0",
|
||||||
"puppeteer": "^15.5.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",
|
||||||
"winston": "^3.8.2",
|
"winston": "^3.8.2",
|
||||||
|
|||||||
+23
-11
@@ -5,19 +5,20 @@ const {MongoManager, formatDate} = require("./workers/mongo_manager");
|
|||||||
const alert = require('alert');
|
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 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 = 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.SIX
|
let excludeMode = DeviceExcludeMode.SIX
|
||||||
let three_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
let three_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||||
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518"]
|
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
|
||||||
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
|
||||||
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "EPHUT20825001518", "bec11752", "fy65eqs4wkvcpf9h", "07fbd156", "NFD669QK8XNFSCNN", "6X494TTWQGFALB79","71a0371d"]
|
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "07fbd156", "NFD669QK8XNFSCNN", "6X494TTWQGFALB79", "71a0371d", "YP6HVKLFE67T598L"]
|
||||||
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "e30eb015", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fy65eqs4wkvcpf9h", "fuljaueqguugf6pn", "EPHUT20825001518", "W8GMFELRHIKZS84T"]
|
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518", "W8GMFELRHIKZS84T"]
|
||||||
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "e30eb015", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
|
||||||
attributedPorts = []
|
attributedPorts = []
|
||||||
const device_port_info = new Map();
|
const device_port_info = new Map();
|
||||||
startPort = 9000
|
startPort = 9000
|
||||||
@@ -121,12 +122,18 @@ async function needToBook(contact, mongoManager, alreadyBooked) {
|
|||||||
return needToBook
|
return needToBook
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startBook(contactPojo, device, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port) {
|
||||||
console.log(`model: ${device.model()}`);
|
console.log(`model: ${device.model()}`);
|
||||||
console.log(`serial: ${device.serial()}`);
|
console.log(`serial: ${device.serial()}`);
|
||||||
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
let alreadyBooked = await mongoManager.getAllSuccessfulItemsForDay(collectionName);
|
||||||
|
const d = new Date();
|
||||||
|
let hour = d.getHours();
|
||||||
|
if (hour >= 19) {
|
||||||
|
console.log("do not continue after 19h")
|
||||||
|
return
|
||||||
|
}
|
||||||
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
if (await needToBook(contactPojo, mongoManager, alreadyBooked)) {
|
||||||
let commandor = new CommandorPage(contactPojo, device, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
let commandor = new CommandorPage(contactPojo, device, sender, mongoManager, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
//read contacts form excel
|
//read contacts form excel
|
||||||
return await commandor.loadPage();
|
return await commandor.loadPage();
|
||||||
} else {
|
} else {
|
||||||
@@ -134,14 +141,14 @@ async function startBook(contactPojo, device, selectedStore, audioAnalyse, alert
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startWithList(contacts, device, selectedStore, audioAnalyse, alertBeep, port) {
|
async function startWithList(contacts, device, sender, selectedStore, audioAnalyse, 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, selectedStore, audioAnalyse, alertBeep, port);
|
const contents = await startBook(contactPojo, device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
}, Promise.resolve());
|
}, Promise.resolve());
|
||||||
}
|
}
|
||||||
@@ -207,6 +214,9 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
return attributedPort
|
return attributedPort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let sender = new Sender()
|
||||||
|
sender.initConnection().then((r) => {
|
||||||
|
console.log("queue connected")
|
||||||
mongoManager.connect().then(r => {
|
mongoManager.connect().then(r => {
|
||||||
filterAlreadyBookedContacts(contactList).then((listToBook) => {
|
filterAlreadyBookedContacts(contactList).then((listToBook) => {
|
||||||
filterAlreadyAcceptedContacts(listToBook).then(notAcceptedContacts => {
|
filterAlreadyAcceptedContacts(listToBook).then(notAcceptedContacts => {
|
||||||
@@ -234,7 +244,7 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
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, selectedStore, audioAnalyse, alertBeep, port);
|
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -242,6 +252,8 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {startBookWithNumbers, scheduleBookWithNumbers}
|
module.exports = {startBookWithNumbers, scheduleBookWithNumbers}
|
||||||
@@ -19,7 +19,11 @@ class ExcelUtil {
|
|||||||
if (store === undefined || store.length === 0) {
|
if (store === undefined || store.length === 0) {
|
||||||
store = "random"
|
store = "random"
|
||||||
}
|
}
|
||||||
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store);
|
let ipCountry = info[5];
|
||||||
|
if (ipCountry === undefined || ipCountry.length === 0) {
|
||||||
|
ipCountry = "FR"
|
||||||
|
}
|
||||||
|
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry);
|
||||||
contactList.push(newContact);
|
contactList.push(newContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
class ContactPojo {
|
class ContactPojo {
|
||||||
|
|
||||||
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store) {
|
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
|
||||||
this.phoneNumber = phoneNumber;
|
this.phoneNumber = phoneNumber;
|
||||||
this.passportNumber = passportNumber;
|
this.passportNumber = passportNumber;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
this.mail = mail;
|
this.mail = mail;
|
||||||
this.store = store;
|
this.store = store;
|
||||||
|
this.ipCountry = ipCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ContactPojo
|
module.exports = ContactPojo
|
||||||
@@ -3,6 +3,8 @@ const OCRResult = {
|
|||||||
TO_REFRESH: Symbol("TO_REFRESH"),
|
TO_REFRESH: Symbol("TO_REFRESH"),
|
||||||
BLOCKED: Symbol("BLOCKED"),
|
BLOCKED: Symbol("BLOCKED"),
|
||||||
SLIDING_CAPTCHA: Symbol("SLIDING_CAPTCHA"),
|
SLIDING_CAPTCHA: Symbol("SLIDING_CAPTCHA"),
|
||||||
|
SSL_CERT_ERROR: Symbol("SSL_CERT_ERROR"),
|
||||||
|
SLIDING_CAPTCHA_LOADING: Symbol("SLIDING_CAPTCHA_LOADING"),
|
||||||
SLIDING_CAPTCHA_REFRESH: Symbol("SLIDING_CAPTCHA_REFRESH"),
|
SLIDING_CAPTCHA_REFRESH: Symbol("SLIDING_CAPTCHA_REFRESH"),
|
||||||
FILL_FIELD: Symbol("FILL_FIELD"),
|
FILL_FIELD: Symbol("FILL_FIELD"),
|
||||||
NEED_TO_CLICK_LATE_BTN: Symbol("NEED_TO_CLICK_LATE_BTN"),
|
NEED_TO_CLICK_LATE_BTN: Symbol("NEED_TO_CLICK_LATE_BTN"),
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
const amqp = require("amqplib");
|
||||||
|
|
||||||
|
const QUEUE_HOST = "amqp://appointment:ZyuhJZ2xEYWhElhpJjy7YEpZGZwNYJz2fHIu@appointment.lpaconsulting.fr:5672"
|
||||||
|
const REQUEST_DATA_QUEUE_FR = 'REQUEST_DATA';
|
||||||
|
const REQUEST_DATA_QUEUE_DE = 'REQUEST_DATA_DE';
|
||||||
|
|
||||||
|
class Sender {
|
||||||
|
channel;
|
||||||
|
connection;
|
||||||
|
|
||||||
|
async initConnection() {
|
||||||
|
this.connection = await amqp.connect(QUEUE_HOST);
|
||||||
|
this.channel = await this.connection.createChannel();
|
||||||
|
await this.channel.assertQueue(REQUEST_DATA_QUEUE_FR, {persistent: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(msg, queue_name = REQUEST_DATA_QUEUE_FR) {
|
||||||
|
this.channel.sendToQueue(queue_name, Buffer.from(msg))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Sender
|
||||||
|
|
||||||
|
// let sender = new Sender()
|
||||||
|
// sender.initConnection().then((r) => {
|
||||||
|
// console.log(r)
|
||||||
|
// sender.sendMessage("test")
|
||||||
|
// })
|
||||||
+117
-104
@@ -32,8 +32,8 @@ const MESSAGE_URL_VALIDATION_FR = "Nous avons envoyé un lien par e-mail."
|
|||||||
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 REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
const REGEX_RDV_URL = "https:\/\/rendezvousparis\.hermes\.com\/client\/register\/[A-Z0-9]+"
|
||||||
const DEFAULT_STORE = 'faubourg';
|
const DEFAULT_STORE = 'faubourg';
|
||||||
|
const timeout = (prom, time) =>
|
||||||
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']
|
Promise.race([prom, new Promise((_r, rej) => setTimeout(rej, time))]);
|
||||||
|
|
||||||
function delay(delayInMs) {
|
function delay(delayInMs) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -72,13 +72,14 @@ function logWithDevice(message, device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CommandorPage {
|
class CommandorPage {
|
||||||
constructor(contact, device, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000) {
|
constructor(contact, device, sender, mongoManager, selectedStore = DEFAULT_STORE, audioAnalyse = false, alertBeep = false, port = 9000) {
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
this.device = device;
|
this.device = device;
|
||||||
this.mongoManager = mongoManager;
|
this.mongoManager = mongoManager;
|
||||||
this.selectedStore = selectedStore;
|
this.selectedStore = selectedStore;
|
||||||
this.choosedStore = selectedStore;
|
this.choosedStore = selectedStore;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
this.sender = sender;
|
||||||
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";
|
||||||
@@ -92,31 +93,6 @@ class CommandorPage {
|
|||||||
this.firstStart = true;
|
this.firstStart = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActivePage(browser, timeout) {
|
|
||||||
const start = new Date().getTime();
|
|
||||||
while (new Date().getTime() - start < timeout) {
|
|
||||||
logWithDevice("get pages", this.device)
|
|
||||||
let pages = await browser.pages();
|
|
||||||
try {
|
|
||||||
pages.forEach((currentPage) => {
|
|
||||||
if (currentPage.url() === RDV_URL) {
|
|
||||||
return currentPage;
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
currentPage.close()
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (e) {
|
|
||||||
this.isTerminated = true;
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw "Unable to get active page";
|
|
||||||
}
|
|
||||||
|
|
||||||
async connect_to_browser(ocrResult) {
|
async connect_to_browser(ocrResult) {
|
||||||
console.log("connect_to_browser() called");
|
console.log("connect_to_browser() called");
|
||||||
if (this.browser === undefined) {
|
if (this.browser === undefined) {
|
||||||
@@ -193,19 +169,17 @@ class CommandorPage {
|
|||||||
await this.enableDisableAirPlanMode();
|
await this.enableDisableAirPlanMode();
|
||||||
// await delay(10 * 1000);
|
// await delay(10 * 1000);
|
||||||
await openUrlWithAdb(RDV_URL, this.device)
|
await openUrlWithAdb(RDV_URL, this.device)
|
||||||
await delay(5000)
|
await delay(10 * 1000)
|
||||||
await this.checkResultWithOcr()
|
await this.checkResultWithOcr()
|
||||||
// await this.clickOnlineAppointment();
|
|
||||||
// } else {
|
|
||||||
// this.isTerminated = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
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()");
|
log(this.device.model() + ":request terminated, send cancel()");
|
||||||
try {
|
try {
|
||||||
|
if (this.page !== undefined) {
|
||||||
await this.page.close()
|
await this.page.close()
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
@@ -698,10 +672,10 @@ 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") {
|
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(1000);
|
await delay(5000);
|
||||||
}
|
}
|
||||||
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
|
let slidingCaptchaSolver = new SlidingCaptchaSolver(this.device);
|
||||||
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
|
await slidingCaptchaSolver.solve(this.page, async (isSuccessful) => {
|
||||||
@@ -742,14 +716,15 @@ class CommandorPage {
|
|||||||
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();
|
||||||
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict())
|
||||||
|
if (!this.page.isClosed()) {
|
||||||
|
try {
|
||||||
await this.page.close();
|
await this.page.close();
|
||||||
// await this.deleteFromBlackList()
|
} catch (e) {
|
||||||
// await this.resetBrowser()
|
console.log(e)
|
||||||
this.isTerminated = true
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
async deleteFromBlackList() {
|
// await this.deleteFromBlackList()
|
||||||
await this.mongoManager.removeFromBlackList(this.contact)
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async getErrors() {
|
async getErrors() {
|
||||||
@@ -757,16 +732,6 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
if (this.page.url() === BLANK_URL) {
|
if (this.page.url() === BLANK_URL) {
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
// let errorItem = this.page.locator("div.alert");
|
|
||||||
// if (errorItem) {
|
|
||||||
// let errorContent = await errorItem.innerHTML();
|
|
||||||
// await this.handleError(errorContent);
|
|
||||||
// }
|
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,7 +753,7 @@ class CommandorPage {
|
|||||||
logWithDevice("resetBrowser", this.device);
|
logWithDevice("resetBrowser", this.device);
|
||||||
this.isFillingFields = false;
|
this.isFillingFields = false;
|
||||||
this.cguChecked = false;
|
this.cguChecked = false;
|
||||||
this.isNameInput = false;
|
this.isNameInputing = false;
|
||||||
this.isEmailFilled = false;
|
this.isEmailFilled = false;
|
||||||
this.isCountryChoosen = false;
|
this.isCountryChoosen = false;
|
||||||
this.isPhoneInput = false;
|
this.isPhoneInput = false;
|
||||||
@@ -826,7 +791,6 @@ 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")
|
||||||
@@ -843,18 +807,30 @@ class CommandorPage {
|
|||||||
checkResult = await this.ocrChecker.get_result();
|
checkResult = await this.ocrChecker.get_result();
|
||||||
}
|
}
|
||||||
while (checkResult === OCRResult.SLIDING_CAPTCHA) {
|
while (checkResult === OCRResult.SLIDING_CAPTCHA) {
|
||||||
|
logWithDevice("will call this.slidingCaptcha()", this.device)
|
||||||
await this.slidingCaptcha(async (isSuccessful) => {
|
await this.slidingCaptcha(async (isSuccessful) => {
|
||||||
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
logWithDevice("SLIDING_CAPTCHA result is " + isSuccessful, this.device)
|
||||||
|
console.log(checkResult);
|
||||||
if (isSuccessful) {
|
if (isSuccessful) {
|
||||||
checkResult = await this.ocrChecker.get_result();
|
await delay(5 * 1000)
|
||||||
|
// checkResult = await this.ocrChecker.get_result();
|
||||||
|
await this.checkResultWithOcr()
|
||||||
} else {
|
} else {
|
||||||
|
if (checkResult === OCRResult.SLIDING_CAPTCHA) {
|
||||||
checkResult = OCRResult.TERMINAED
|
checkResult = OCRResult.TERMINAED
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
await delay(10 * 1000)
|
await delay(10 * 1000)
|
||||||
}
|
}
|
||||||
switch (checkResult) {
|
switch (checkResult) {
|
||||||
|
case OCRResult.SLIDING_CAPTCHA_LOADING:
|
||||||
|
this.isTerminated = true;
|
||||||
|
break;
|
||||||
|
case OCRResult.SSL_CERT_ERROR:
|
||||||
|
await this.resetBrowser()
|
||||||
|
break;
|
||||||
case OCRResult.TERMINAED:
|
case OCRResult.TERMINAED:
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
break;
|
break;
|
||||||
@@ -870,29 +846,74 @@ class CommandorPage {
|
|||||||
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
|
browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser",
|
||||||
headless: false, defaultViewport: null
|
headless: false, defaultViewport: null
|
||||||
})
|
})
|
||||||
logWithDevice("get pages", this.device)
|
|
||||||
let pages = await this.browser.pages();
|
|
||||||
try {
|
try {
|
||||||
|
logWithDevice("get pages", this.device)
|
||||||
|
// add listeners
|
||||||
|
let pages = await timeout(this.browser.pages(), 5 * 1000);
|
||||||
pages.forEach((currentPage) => {
|
pages.forEach((currentPage) => {
|
||||||
if (currentPage.url() === RDV_URL) {
|
if (currentPage.url() === RDV_URL) {
|
||||||
this.page = currentPage;
|
this.page = currentPage;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
if (!this.isTerminated)
|
||||||
currentPage.close()
|
currentPage.close()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
|
||||||
this.isTerminated = true;
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
logWithDevice("this.page.bringToFront();", this.device)
|
logWithDevice("this.page.bringToFront();", this.device)
|
||||||
|
const cookiesSet = await this.page.cookies();
|
||||||
|
let cookiesString = ""
|
||||||
|
cookiesSet.forEach((cookie) => {
|
||||||
|
cookiesString = cookiesString + cookie.name + "=" + cookie.value + ";"
|
||||||
|
})
|
||||||
|
console.log(cookiesString);
|
||||||
|
|
||||||
|
if (this.contact.ipCountry === "DE")
|
||||||
|
this.sender.sendMessage(cookiesString, "REQUEST_DATA_DE")
|
||||||
|
else
|
||||||
|
this.sender.sendMessage(cookiesString)
|
||||||
|
// let content = await this.page.content()
|
||||||
|
// console.log(content)
|
||||||
await this.page.bringToFront();
|
await this.page.bringToFront();
|
||||||
await this.fillFields(this.page)
|
await this.fillFields(this.page)
|
||||||
await delay(2 * 1000);
|
await delay(2 * 1000);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
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) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
this.isTerminated = true
|
this.isTerminated = true
|
||||||
@@ -901,27 +922,7 @@ class CommandorPage {
|
|||||||
logWithDevice("this.browser.isConnected() is " + this.browser.isConnected(), this.device)
|
logWithDevice("this.browser.isConnected() is " + this.browser.isConnected(), this.device)
|
||||||
try {
|
try {
|
||||||
if (this.browser.isConnected()) {
|
if (this.browser.isConnected()) {
|
||||||
// logWithDevice("get pages", this.device)
|
|
||||||
// let pages = await this.browser.pages();
|
|
||||||
logWithDevice("will use old page", this.device)
|
logWithDevice("will use old page", this.device)
|
||||||
// try {
|
|
||||||
// pages.forEach((currentPage) => {
|
|
||||||
// if (currentPage.url() === RDV_URL) {
|
|
||||||
// this.page = currentPage;
|
|
||||||
// } else {
|
|
||||||
// // try {
|
|
||||||
// // if (!currentPage.isClosed()) {
|
|
||||||
// // currentPage.close()
|
|
||||||
// // }
|
|
||||||
// // } catch (e) {
|
|
||||||
// // console.log(e)
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// } catch (e) {
|
|
||||||
// this.isTerminated = true
|
|
||||||
// console.log(e)
|
|
||||||
// }
|
|
||||||
logWithDevice("this.page.bringToFront();", this.device)
|
logWithDevice("this.page.bringToFront();", this.device)
|
||||||
await this.page.bringToFront();
|
await this.page.bringToFront();
|
||||||
// this.page = pages;
|
// this.page = pages;
|
||||||
@@ -951,12 +952,7 @@ class CommandorPage {
|
|||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.RECAPTCHA_ERROR:
|
OCRResult.RECAPTCHA_ERROR:
|
||||||
// if (!this.isFillingFields)
|
|
||||||
this.isTerminated = true;
|
this.isTerminated = true;
|
||||||
// else {
|
|
||||||
// await this.checkResultWithOcr();
|
|
||||||
// }
|
|
||||||
// await this.connect_to_browser(OCRResult.RECAPTCHA_ERROR)
|
|
||||||
break;
|
break;
|
||||||
case
|
case
|
||||||
OCRResult.BRAVE_SKIP:
|
OCRResult.BRAVE_SKIP:
|
||||||
@@ -964,12 +960,17 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_PRIVACY:
|
case OCRResult.BRAVE_PRIVACY:
|
||||||
if (this.device.model() === "MI 5s") {
|
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)
|
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.device.shell("input tap " + 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") {
|
||||||
|
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" || this.device.model() === "DE2117") {
|
} else if (this.device.model() === "KB2003" || this.device.model() === "DE2117") {
|
||||||
@@ -986,8 +987,10 @@ class CommandorPage {
|
|||||||
await this.checkResultWithOcr();
|
await this.checkResultWithOcr();
|
||||||
break;
|
break;
|
||||||
case OCRResult.BRAVE_PRIVACY_PUB:
|
case OCRResult.BRAVE_PRIVACY_PUB:
|
||||||
if (this.device.model() === "MI 5s") {
|
if (this.device.model() === "MI 5s" || 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") {
|
||||||
|
await this.tapForDevice(this.device, 530, 950)
|
||||||
} else
|
} else
|
||||||
await this.tapForDevice(this.device, 455, 1920)
|
await this.tapForDevice(this.device, 455, 1920)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
@@ -999,6 +1002,8 @@ class CommandorPage {
|
|||||||
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") {
|
||||||
|
await this.tapForDevice(this.device, 322, 1146)
|
||||||
} else
|
} else
|
||||||
await this.tapForDevice(this.device, 500, 1680)
|
await this.tapForDevice(this.device, 500, 1680)
|
||||||
// await this.device.shell("input tap " + 500 + " " + 1680)
|
// await this.device.shell("input tap " + 500 + " " + 1680)
|
||||||
@@ -1101,12 +1106,18 @@ class CommandorPage {
|
|||||||
let model = this.device.model()
|
let model = this.device.model()
|
||||||
if (model === "CPH2219") {
|
if (model === "CPH2219") {
|
||||||
await this.device.shell("input tap " + 558 + " " + 1160)
|
await this.device.shell("input tap " + 558 + " " + 1160)
|
||||||
} else if (model === "MI 5s") {
|
} 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") {
|
||||||
|
await this.tapForDevice(this.device, 530, 1000)
|
||||||
|
} else if (model === "HUAWEI NXT-TL00") {
|
||||||
|
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.device.shell("input tap " + 530 + " " + 1106)
|
await this.tapForDevice(this.device, 530, 1045)
|
||||||
|
} else if (model === "CPH2469") {
|
||||||
|
await this.tapForDevice(this.device, 360, 820)
|
||||||
} else {
|
} else {
|
||||||
logWithDevice("handleBraveSkipBtn", this.device)
|
logWithDevice("handleBraveSkipBtn", this.device)
|
||||||
await this.tapForDevice(this.device, 470, 1160)
|
await this.tapForDevice(this.device, 470, 1160)
|
||||||
@@ -1129,6 +1140,8 @@ class CommandorPage {
|
|||||||
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") {
|
||||||
|
await this.tapForDevice(this.device, 950, 1434)
|
||||||
} else
|
} else
|
||||||
this.device.shell("input tap " + 933 + " " + 1538)
|
this.device.shell("input tap " + 933 + " " + 1538)
|
||||||
await delay(2000);
|
await delay(2000);
|
||||||
@@ -1193,21 +1206,21 @@ class CommandorPage {
|
|||||||
|
|
||||||
async enableDisableAirPlanMode() {
|
async enableDisableAirPlanMode() {
|
||||||
logWithDevice("will enable/disable airplane mode", this.device)
|
logWithDevice("will enable/disable airplane mode", this.device)
|
||||||
try {
|
// try {
|
||||||
// await this.device.shell("cmd connectivity airplane-mode enable")
|
// // await this.device.shell("cmd connectivity airplane-mode enable")
|
||||||
await 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)
|
||||||
|
// } catch (e) {
|
||||||
|
// try {
|
||||||
// await this.device.shell("cmd connectivity airplane-mode disable")
|
// await this.device.shell("cmd connectivity airplane-mode disable")
|
||||||
await delay(2000)
|
// } catch (e) {
|
||||||
} catch (e) {
|
// console.log(e)
|
||||||
try {
|
// }
|
||||||
await this.device.shell("cmd connectivity airplane-mode disable")
|
// console.log(e)
|
||||||
} catch (e) {
|
// }
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async tapGoogleDisconnectBtn() {
|
async tapGoogleDisconnectBtn() {
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ function delay(delayInMs) {
|
|||||||
const NO_INTERNET_FR = "Aucun accés a Internet"
|
const NO_INTERNET_FR = "Aucun accés a Internet"
|
||||||
const NO_INTERNET_FR_2 = "Aucun accès à Internet"
|
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 = "envoyé un lien par e-mail."
|
const MESSAGE_URL_VALIDATION_FR = "Vous recevrez un email de validation"
|
||||||
const MESSAGE_URL_VALIDATION_FR_2 = "un lien par e-mail"
|
const MESSAGE_URL_VALIDATION_FR_2 = "Merci de votre intérêt pour notre Maison"
|
||||||
|
const SSL_CERT_ERROR = " Votre connexion n'est pas privée"
|
||||||
const 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 CHOOSE_POSITION_GOOGLE_FR = " Choisir la position pour les résultats de recherche"
|
const CHOOSE_POSITION_GOOGLE_FR = " Choisir la position pour les résultats de recherche"
|
||||||
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
const CAPTCHA_ERROR_MESSAGE = "Error verifying captcha, please try again"
|
||||||
@@ -31,16 +32,21 @@ const ERR_CACHE_MISS = "ERR_CACHE_MISS"
|
|||||||
const ERR_CACHE_MISS_2 = "ERR_CACHE-MISS"
|
const ERR_CACHE_MISS_2 = "ERR_CACHE-MISS"
|
||||||
const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
|
const ERR_CACHE_MISS_3 = "appuyer sur le bouton d'actualisation"
|
||||||
const ERR_CACHE_MISS_4 = "renvoyer les données"
|
const ERR_CACHE_MISS_4 = "renvoyer les données"
|
||||||
|
const ERR_EMPTY_RESPONSE = "ERR_EMPTY_RESPONSE"
|
||||||
|
const ERR_SSL_PROTOCOL = "SSL_PROTOCOL_ERROR"
|
||||||
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
|
const SLIDING_CAPTCHA_FR = "Pourquoi cette vérification"
|
||||||
|
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"
|
||||||
const SLIDING_CAPTCHA_FR_4 = " s'assure qu'on s'adresse bien"
|
const SLIDING_CAPTCHA_FR_4 = " s'assure qu'on s'adresse bien"
|
||||||
const SLIDING_CAPTCHA_FR_5 = "On s'assure que c'est"
|
const SLIDING_CAPTCHA_FR_5 = "On s'assure que c'est"
|
||||||
|
const SLIDING_CAPTCHA_FR_6 = "s'assure que cest bien vous"
|
||||||
const MESSAGE_FILL_FIELD_FR = "Demande de rendez-vous pour"
|
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 = "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 = "Bienvenue dans Chrome"
|
||||||
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"
|
||||||
@@ -100,7 +106,10 @@ class OCRChecker {
|
|||||||
} else if (result.includes(BRAVE_VPN_SKIP)) {
|
} else if (result.includes(BRAVE_VPN_SKIP)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_VPN_SKIP
|
return OCRResult.BRAVE_VPN_SKIP
|
||||||
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5)) {
|
} else if (result.includes(SSL_CERT_ERROR)) {
|
||||||
|
await this.deleteFile(fileName)
|
||||||
|
return OCRResult.SSL_CERT_ERROR
|
||||||
|
} 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)) {
|
||||||
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)) {
|
||||||
@@ -108,7 +117,9 @@ class OCRChecker {
|
|||||||
} else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR) || result.includes(BLOCKED_MSG_FR_2) || result.includes(BLOCKED_MSG_FR_3)) {
|
} else if (result.includes(BLOCKED_MSG_EN) || result.includes(BLOCKED_MSG_FR) || result.includes(BLOCKED_MSG_FR_2) || result.includes(BLOCKED_MSG_FR_3)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BLOCKED
|
return OCRResult.BLOCKED
|
||||||
} else if (result.includes(ERR_CACHE_MISS) || result.includes(ERR_CACHE_MISS_2) || result.includes(ERR_CACHE_MISS_3) || result.includes(ERR_CACHE_MISS_4)) {
|
} else if (result.includes(ERR_CACHE_MISS) || result.includes(ERR_CACHE_MISS_2) || result.includes(ERR_CACHE_MISS_3)
|
||||||
|
|| result.includes(ERR_CACHE_MISS_4) || result.includes(ERR_EMPTY_RESPONSE)) { //|| result.includes(ERR_SSL_PROTOCOL)
|
||||||
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.TO_REFRESH
|
return OCRResult.TO_REFRESH
|
||||||
} else if (result.includes(CHECKING_MSG_FR) || result.includes(CHECKING_MSG_FR_2)) {
|
} else if (result.includes(CHECKING_MSG_FR) || result.includes(CHECKING_MSG_FR_2)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
@@ -119,8 +130,11 @@ class OCRChecker {
|
|||||||
} else if (result.includes(BRAVE_SKIP_PUB) || result.includes(BRAVE_SKIP_PUB_2) || result.includes(BRAVE_SKIP_PUB_3) || result.includes(BRAVE_SKIP_PUB_4) || result.includes(BRAVE_SKIP_PUB_5)) {
|
} else if (result.includes(BRAVE_SKIP_PUB) || result.includes(BRAVE_SKIP_PUB_2) || result.includes(BRAVE_SKIP_PUB_3) || result.includes(BRAVE_SKIP_PUB_4) || result.includes(BRAVE_SKIP_PUB_5)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
return OCRResult.BRAVE_PRIVACY_PUB
|
return OCRResult.BRAVE_PRIVACY_PUB
|
||||||
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5)) {
|
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4) || result.includes(SLIDING_CAPTCHA_FR_5) || result.includes(SLIDING_CAPTCHA_FR_6)) {
|
||||||
await this.deleteFile(fileName)
|
await this.deleteFile(fileName)
|
||||||
|
if (result.includes(SLIDING_CAPTCHA_LOADING_FR)) {
|
||||||
|
return OCRResult.SLIDING_CAPTCHA_LOADING
|
||||||
|
}
|
||||||
// await this.deleteFile(screenShot)
|
// await this.deleteFile(screenShot)
|
||||||
// if (result.includes("rac"))
|
// if (result.includes("rac"))
|
||||||
// return OCRResult.SLIDING_CAPTCHA_REFRESH
|
// return OCRResult.SLIDING_CAPTCHA_REFRESH
|
||||||
@@ -184,6 +198,7 @@ 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)
|
||||||
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}`);
|
||||||
|
|||||||
@@ -34,17 +34,18 @@ class SlidingCaptchaSolver {
|
|||||||
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(1000);
|
await delay(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async sliding_captcha(device, onResult) {
|
async sliding_captcha(device, onResult) {
|
||||||
// take screenshot
|
// take screenshot
|
||||||
console.log("take screenshot")
|
console.log("sliding_captcha.take screenshot")
|
||||||
let blockedFileName = uuidv4();
|
let blockedFileName = uuidv4();
|
||||||
let blockedImageFileName = "blocked_" + blockedFileName + ".png"
|
let blockedImageFileName = "blocked_" + blockedFileName + ".png"
|
||||||
await this.take_screen_shot(blockedImageFileName, device)
|
await this.take_screen_shot(blockedImageFileName, device)
|
||||||
//get resolution of screen
|
//get resolution of screen
|
||||||
|
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) {
|
||||||
@@ -81,6 +82,7 @@ class SlidingCaptchaSolver {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteFile(filename) {
|
async deleteFile(filename) {
|
||||||
try {
|
try {
|
||||||
fs.unlinkSync(filename)
|
fs.unlinkSync(filename)
|
||||||
@@ -89,6 +91,7 @@ class SlidingCaptchaSolver {
|
|||||||
return OCRResult.TERMINAED
|
return OCRResult.TERMINAED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendRequest(fileName, callback) {
|
async sendRequest(fileName, callback) {
|
||||||
const fileStream = fs.createReadStream(fileName);
|
const fileStream = fs.createReadStream(fileName);
|
||||||
let response = await axios.post(DEEPLEARNING_CAPTCHA_HOST, fileStream, {
|
let response = await axios.post(DEEPLEARNING_CAPTCHA_HOST, fileStream, {
|
||||||
|
|||||||
Reference in New Issue
Block a user