diff --git a/src/appointment.js b/src/appointment.js index 3a23906..8a7165b 100644 --- a/src/appointment.js +++ b/src/appointment.js @@ -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"); diff --git a/src/models/ReserveResultPojo.js b/src/models/ReserveResultPojo.js index b1f335c..b44d89e 100644 --- a/src/models/ReserveResultPojo.js +++ b/src/models/ReserveResultPojo.js @@ -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 } } diff --git a/src/workers/CommandorPage.js b/src/workers/CommandorPage.js index 968fe3b..3b0a334 100644 --- a/src/workers/CommandorPage.js +++ b/src/workers/CommandorPage.js @@ -773,11 +773,30 @@ class CommandorPage { if (url === "https://rendezvousparis.hermes.com/client/welcome") { return } + let browserInfo = await this.page.evaluate(() => { + const ua = navigator.userAgent; + return ua + // let tem; + // let M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; + // if (/trident/i.test(M[1])) { + // tem = /\brv[ :]+(\d+)/g.exec(ua) || []; + // return 'IE ' + (tem[1] || ''); + // } + // if (M[1] === 'Chrome') { + // tem = ua.match(/\b(OPR|Edge)\/(\d+)/); + // if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); + // } + // M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; + // if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]); + // return M.join(' '); + }) + 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.currentIp = currentIp reserve.serial = this.device.serial; + reserve.browserInfo = browserInfo; await this.mongoManager.saveReserveToDb(reserve.to_mongo_dict()) if (!this.page.isClosed()) { try { @@ -841,7 +860,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", @@ -893,10 +912,6 @@ class CommandorPage { await this.checkResultWithOcr() } else { await this.checkResultWithOcr() - // if (checkResult === OCRResult.SLIDING_CAPTCHA) { - // checkResult = OCRResult.TERMINAED - // this.isTerminated = true - // } } }) // await delay(5 * 1000)