From a578ca8a4d967b933a2f0f3b1383b5afd6f36793 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Sat, 10 Sep 2022 11:47:15 +0200 Subject: [PATCH] beep when datadome --- package.json | 1 + src/workers/CommandorPage.js | 38 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 234145b..1fdac37 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ }, "dependencies": { "axios": "^0.27.2", + "beepbeep": "^1.3.0", "mongodb": "^4.9.1", "mongoose": "^6.5.4", "node-xlsx": "^0.21.0", diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 45c621c..b4f9aad 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -1,5 +1,4 @@ const {_android: android, devices} = require("playwright"); - const {SolveCaptcha, TWO_CAPTCHA_CONNECTION_FAILED} = require("./SolveCaptcha"); const ReserveResultPojo = require("../models/ReserveResultPojo"); const PublishType = require("../models/PublishType"); @@ -174,14 +173,15 @@ class CommandorPage { async clickValid(page) { await delay(getRandomWaitTime()) try { - if (!this.page.isClosed()){ - this.page.evaluate(() => { - document.getElementsByClassName("btn")[0].focus(); - }) - await delay(getRandomWaitTime()) - this.page.evaluate(() => { - document.getElementsByClassName("btn")[0].click(); - })} + if (!this.page.isClosed()) { + this.page.evaluate(() => { + document.getElementsByClassName("btn")[0].focus(); + }) + await delay(getRandomWaitTime()) + this.page.evaluate(() => { + document.getElementsByClassName("btn")[0].click(); + }) + } } catch (e) { console.log(e) } @@ -195,13 +195,14 @@ class CommandorPage { this.captchaSolver = new SolveCaptcha(page); await this.captchaSolver.start((solution) => { console.log("solution is: " + solution); - if (solution !== ERROR_CAPTCHA_UNSOLVABLE&&solution!==TWO_CAPTCHA_CONNECTION_FAILED) { + if (solution !== ERROR_CAPTCHA_UNSOLVABLE && solution !== TWO_CAPTCHA_CONNECTION_FAILED) { try { - if (!page.isClosed()){ - page.evaluate((solution) => { - document.getElementById("g-recaptcha-response").innerHTML = solution; - }, solution) - this.clickValid();} + if (!page.isClosed()) { + page.evaluate((solution) => { + document.getElementById("g-recaptcha-response").innerHTML = solution; + }, solution) + this.clickValid(); + } } catch (e) { console.log(e) this.isTerminated = true; @@ -218,19 +219,20 @@ class CommandorPage { if (content.toString().includes(captcha_url)) { await this.checkAudioBtn(); + beep(20) console.log("发现datadome"); } else { if (currentPage.url() === RDV_URL) { await this.fillFields(this.page); if (this.isFillingFields) - await this.getErrors() + await this.getErrors() } else { if (content.includes(MESSAGE_URL_VALIDATION_FR)) { console.log("successful"); await this.push_message_to_queue(PublishType.SUCCESS); } else { // try to get errors - await this.getErrors() + await this.getErrors() } } } @@ -284,7 +286,7 @@ class CommandorPage { } - async getErrors() { + async getErrors() { if (this.page.url() === BLANK_URL) { this.isTerminated = true; } else {