From c3284edd21147350b9d8373bb7f1a099dd123f4b Mon Sep 17 00:00:00 2001 From: Lei PAN Date: Sat, 28 Oct 2023 17:27:38 +0200 Subject: [PATCH] rm unused code --- src/workers/CommandorPage.js | 45 ------------------------------------ src/workers/OCRChecker.js | 6 ++--- 2 files changed, 3 insertions(+), 48 deletions(-) diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 2fe5254..a57b493 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -189,50 +189,6 @@ class CommandorPage { console.log(e) this.isTerminated = true; } - - // Connect to the device. - if (this.browser) { - logWithDevice("browser.isConnected is " + this.browser.isConnected(), this.device); - } - try { - // logWithDevice("connecting to browser:" + this.port, this.device); - // while (this.browser === undefined || !this.browser.isConnected()) { - // this.browser = await puppeteer.connect({ - // browserWSEndpoint: "ws://127.0.0.1:" + this.port + "/devtools/browser", - // headless: false, defaultViewport: null - // }) - // // let pages = await this.browser.pages(); - // // this.page = pages[0]; - // this.page = await this.browser.newPage(); - // - // this.page.on("load", (loadedPage) => { - // this.onPageLoad(loadedPage); - // }) - // - // this.page.on("response", (response) => { - // this.onResponse(response) - // }) - // await delay(3 * 1000); - // } - } catch (e) { - logWithDevice("failed to connect to device", this.device) - console.log(e) - // await this.resetBrowser() - await this.checkResultWithOcr() - this.isTerminated = true - } - // if (this.page !== undefined) { - // try { - // logWithDevice("will open google", this.device) - // if (!this.isTerminated) { - // const item = searchTexts[Math.floor(Math.random() * searchTexts.length)]; - // await this.page.goto("https://www.google.com/search?q=" + item + "&lr=lang_en", {timeout: 30 * 1000}); - // } - // // await this.page.goto(RDV_URL, {timeout: 90 * 1000}); - // } catch (e) { - // log(e) - // this.isTerminated = true - // } // await this.acceptCookies(); await this.enableDisableAirPlanMode(); // await delay(10 * 1000); @@ -844,7 +800,6 @@ class CommandorPage { this.isCountryChoosen = false; this.isPhoneInput = false; this.isPasspordInput = false; - // this.disconnectBrowser(); await clearApp(this.device, this.browserPackageName) // await this.device.shell("pm clear " + this.browserPackageName) await delay(1000) diff --git a/src/workers/OCRChecker.js b/src/workers/OCRChecker.js index 9aa0f11..2222acd 100644 --- a/src/workers/OCRChecker.js +++ b/src/workers/OCRChecker.js @@ -113,6 +113,9 @@ class OCRChecker { } else if (result.includes(BRAVE_NOTIFICATION)) { await this.deleteFile(fileName) return OCRResult.BRAVE_NOTIFICATION + } 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) + 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)) { await this.deleteFile(fileName) // await this.deleteFile(screenShot) @@ -156,9 +159,6 @@ class OCRChecker { } else if (result.includes(BRAVE_SKIP_PRIVACY_PAGE) || result.includes(BRAVE_SKIP_PRIVACY_PAGE_2)) { await this.deleteFile(fileName) return OCRResult.BRAVE_PRIVACY - } 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) - return OCRResult.BRAVE_PRIVACY_PUB } else { return OCRResult.TERMINAED }