Merge branch 'master' into feature/gui
This commit is contained in:
@@ -3,8 +3,8 @@ const ReserveResultPojo = require("../models/ReserveResultPojo");
|
||||
const appointmentLogger = require("../utiles/LoggerUtils")
|
||||
const PublishType = require("../models/PublishType");
|
||||
const beep = require('beepbeep')
|
||||
const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
// const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
BLANK_URL = "about:blank"
|
||||
const ERROR_CAPTCHA_UNSOLVABLE = "ERROR_CAPTCHA_UNSOLVABLE";
|
||||
|
||||
@@ -42,7 +42,7 @@ function delay(delayInms) {
|
||||
}
|
||||
|
||||
function getRandom() {
|
||||
return Math.floor(Math.random() * 5);
|
||||
return Math.floor(Math.random() * 3);
|
||||
}
|
||||
|
||||
function getRandomWaitTime() {
|
||||
@@ -67,7 +67,7 @@ class CommandorPage {
|
||||
async loadPage() {
|
||||
// Connect to the device.
|
||||
log("loadPage() called");
|
||||
await this.device.shell('am force-stop com.android.chrome');
|
||||
// await this.device.shell('am force-stop com.android.chrome');
|
||||
const context = await this.device.launchBrowser();
|
||||
// await context.clearCookies()
|
||||
|
||||
@@ -238,13 +238,19 @@ class CommandorPage {
|
||||
try {
|
||||
if (!this.page.isClosed()) {
|
||||
this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].focus();
|
||||
let element = document.getElementsByClassName("btn")[0];
|
||||
if (typeof element !== 'undefined')
|
||||
document.getElementsByClassName("btn")[0].focus();
|
||||
})
|
||||
await delay(getRandomWaitTime())
|
||||
if (!this.page.isClosed()) {
|
||||
this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].click();
|
||||
})
|
||||
try {
|
||||
this.page.evaluate(() => {
|
||||
document.getElementsByClassName("btn")[0].click();
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -281,27 +287,31 @@ class CommandorPage {
|
||||
}
|
||||
|
||||
async onPageLoad(currentPage) {
|
||||
let content = await currentPage.content();
|
||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||
try {
|
||||
let content = await currentPage.content();
|
||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||
|
||||
if (content.toString().includes(captcha_url)) {
|
||||
await this.checkAudioBtn();
|
||||
beep(20)
|
||||
log("发现datadome");
|
||||
} else {
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
await this.fillFields(this.page);
|
||||
if (this.isFillingFields)
|
||||
await this.getErrors()
|
||||
if (content.toString().includes(captcha_url)) {
|
||||
await this.checkAudioBtn();
|
||||
beep(20)
|
||||
console.log("发现datadome");
|
||||
} else {
|
||||
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
||||
log("successful");
|
||||
await this.push_message_to_queue(PublishType.SUCCESS);
|
||||
if (currentPage.url() === RDV_URL) {
|
||||
await this.fillFields(this.page);
|
||||
if (this.isFillingFields)
|
||||
await this.getErrors()
|
||||
} else {
|
||||
// try to get errors
|
||||
await this.getErrors()
|
||||
if (content.includes(MESSAGE_URL_VALIDATION_FR) || content.includes(MESSAGE_URL_VALIDATION_EN)) {
|
||||
console.log("successful");
|
||||
await this.push_message_to_queue(PublishType.SUCCESS);
|
||||
} else {
|
||||
// try to get errors
|
||||
await this.getErrors()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user