|
@@ -339,6 +339,7 @@
|
|
|
// const headless = true;
|
|
|
// const waitUntil = 'networkidle2';
|
|
|
const { ipcRenderer } = require('electron');
|
|
|
+ //const chromePath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";
|
|
|
|
|
|
let separator = '';
|
|
|
if (os.platform == 'linux') {
|
|
@@ -458,6 +459,10 @@
|
|
|
fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-jd');
|
|
|
}
|
|
|
|
|
|
+ if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-local')) {
|
|
|
+ fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-local');
|
|
|
+ }
|
|
|
+
|
|
|
let path = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
let path2 = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
//this.deleteAll(path, false);
|
|
@@ -513,13 +518,33 @@
|
|
|
},
|
|
|
// 实时获取浏览器路径
|
|
|
initPath(){
|
|
|
+ let chromeType = this.$utils.getStorage('chromeType');
|
|
|
let chromePath = puppeteer.executablePath().replace('win32-1', 'win64-1');
|
|
|
- let versionType = this.$utils.getStorage('versionType');
|
|
|
- if(versionType && versionType == 1){
|
|
|
- chromePath = chromePath.replace('chrome-win', 'chrome7');
|
|
|
+ if(chromeType == 1){ // 电脑自带浏览器
|
|
|
+ chromePath = this.$utils.getStorage('chromePath');
|
|
|
+ }else{
|
|
|
+ chromePath = puppeteer.executablePath().replace('win32-1', 'win64-1');
|
|
|
+ let versionType = this.$utils.getStorage('versionType');
|
|
|
+ if(versionType && versionType == 1){
|
|
|
+ chromePath = chromePath.replace('chrome-win', 'chrome7');
|
|
|
+ }
|
|
|
}
|
|
|
return chromePath;
|
|
|
},
|
|
|
+ // 实时获取浏览器数据缓存
|
|
|
+ initDataDir(tag){
|
|
|
+ let chromeType = this.$utils.getStorage('chromeType');
|
|
|
+ let userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
+ if(chromeType == 1){ // 电脑自带浏览器
|
|
|
+ userDataDir = os.tmpdir() + separator + 'chrome-data-capture-local';
|
|
|
+ }else{
|
|
|
+ userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
+ if(tag == 'jd'){
|
|
|
+ userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return userDataDir;
|
|
|
+ },
|
|
|
// 实时获取页面滚动加载时间
|
|
|
initMs(){
|
|
|
let pageMs = this.$utils.getStorage('pageMs');
|
|
@@ -751,10 +776,13 @@
|
|
|
if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-jd')) {
|
|
|
fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-jd');
|
|
|
}
|
|
|
+ if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture-local')) {
|
|
|
+ fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture-local');
|
|
|
+ }
|
|
|
|
|
|
- let userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
+ let userDataDir = this.initDataDir();
|
|
|
if(url.indexOf('.jd.com/') > -1){
|
|
|
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
+ userDataDir = this.initDataDir('jd');
|
|
|
}
|
|
|
|
|
|
puppeteer.use(StealthPlugin());
|
|
@@ -849,10 +877,6 @@
|
|
|
}, 60000);
|
|
|
}
|
|
|
|
|
|
- if (!fs.existsSync(os.tmpdir() + separator + 'chrome-data-capture')) {
|
|
|
- fs.mkdirSync(os.tmpdir() + separator + 'chrome-data-capture');
|
|
|
- }
|
|
|
-
|
|
|
if(this.menuIndex == '1' && !this.skipLogin){ // 阿里巴巴
|
|
|
if(this.alibabaStatus == 1 || this.alibabaStatus == 3){ // 未检测登录状态/或提示未登录状态,开始检测
|
|
|
await this.checkAlibabaLogin().then((data) => {
|
|
@@ -923,9 +947,9 @@
|
|
|
|
|
|
let taskArr = [];
|
|
|
let task = "";
|
|
|
- let userDataDir = os.tmpdir() + separator + 'chrome-data-capture';
|
|
|
+ let userDataDir = this.initDataDir();
|
|
|
if(this.menuIndex == '2'){
|
|
|
- userDataDir = os.tmpdir() + separator + 'chrome-data-capture-jd';
|
|
|
+ userDataDir = this.initDataDir('jd');
|
|
|
}
|
|
|
// 运行不同平台的浏览器
|
|
|
puppeteer.use(StealthPlugin());
|
|
@@ -1028,17 +1052,6 @@
|
|
|
let number = 0;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
- // puppeteer.use(StealthPlugin());
|
|
|
- // const commonBrowser = await puppeteer.launch({
|
|
|
- // executablePath: this.initPath(),
|
|
|
- // userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
- // args: [
|
|
|
- // '--start-maximized',
|
|
|
- // '--no-sandbox',
|
|
|
- // '--disable-setuid-sandbox',
|
|
|
- // '--disable-blink-features=AutomationControlled',
|
|
|
- // ]
|
|
|
- // });
|
|
|
const page = await commonBrowser.newPage();
|
|
|
|
|
|
let titleFlag = true;
|
|
@@ -1171,7 +1184,7 @@
|
|
|
this.loginBrowser = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
args: ['--window-size=1280,800'],
|
|
|
- userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
+ userDataDir: this.initDataDir()
|
|
|
});
|
|
|
const page = await this.loginBrowser.newPage();
|
|
|
await page.setViewport({ width: 1280, height: 800 });
|
|
@@ -1220,11 +1233,6 @@
|
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
- // puppeteer.use(StealthPlugin());
|
|
|
- // const browser = await puppeteer.launch({
|
|
|
- // executablePath: this.initPath(),
|
|
|
- // userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
- // });
|
|
|
const page = await browser.newPage();
|
|
|
|
|
|
let waitUntil = 'networkidle2';
|
|
@@ -1323,7 +1331,7 @@
|
|
|
this.loginBrowser = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
args: ['--window-size=1280,800'],
|
|
|
- userDataDir: os.tmpdir() + separator + 'chrome-data-capture-jd',
|
|
|
+ userDataDir: this.initDataDir('jd'),
|
|
|
args: [
|
|
|
'--start-maximized',
|
|
|
'--no-sandbox',
|
|
@@ -1383,16 +1391,6 @@
|
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
- // puppeteer.use(StealthPlugin());
|
|
|
- // const jdBrowser = await puppeteer.launch({
|
|
|
- // executablePath: this.initPath(),
|
|
|
- // userDataDir: os.tmpdir() + separator + 'chrome-data-capture-jd',
|
|
|
- // args: [
|
|
|
- // '--no-sandbox',
|
|
|
- // '--disable-setuid-sandbox',
|
|
|
- // '--disable-blink-features=AutomationControlled',
|
|
|
- // ]
|
|
|
- // });
|
|
|
const page = await jdBrowser.newPage();
|
|
|
await page.evaluateOnNewDocument(() => {
|
|
|
const newProto = navigator.__proto__;
|
|
@@ -1733,7 +1731,7 @@
|
|
|
this.loginBrowser = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
args: ['--window-size=1280,800'],
|
|
|
- userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
+ userDataDir: this.initDataDir()
|
|
|
});
|
|
|
const page = await this.loginBrowser.newPage();
|
|
|
await page.setViewport({ width: 1280, height: 800 });
|
|
@@ -1781,11 +1779,6 @@
|
|
|
let authority = this.$refs.headerRef.authority.isAuthority;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
- // puppeteer.use(StealthPlugin());
|
|
|
- // const tbBrowser = await puppeteer.launch({
|
|
|
- // executablePath: this.initPath(),
|
|
|
- // userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
- // });
|
|
|
let page = await tbBrowser.newPage();
|
|
|
|
|
|
let responseVideo = [];
|
|
@@ -2367,7 +2360,7 @@
|
|
|
puppeteer.use(StealthPlugin());
|
|
|
this.loginBrowser = await puppeteer.launch({
|
|
|
executablePath: this.initPath(),
|
|
|
- userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
+ userDataDir: this.initDataDir(),
|
|
|
args: [
|
|
|
'--start-maximized',
|
|
|
'--no-sandbox',
|
|
@@ -2410,18 +2403,6 @@
|
|
|
let number = 0;
|
|
|
urlInfo.status = '2';
|
|
|
urlInfo.num = 0;
|
|
|
- // puppeteer.use(StealthPlugin());
|
|
|
- // const redBrowser = await puppeteer.launch({
|
|
|
- // headless: false,
|
|
|
- // executablePath: this.initPath(),
|
|
|
- // userDataDir: os.tmpdir() + separator + 'chrome-data-capture',
|
|
|
- // args: [
|
|
|
- // '--start-maximized',
|
|
|
- // '--no-sandbox',
|
|
|
- // '--disable-setuid-sandbox',
|
|
|
- // '--disable-blink-features=AutomationControlled',
|
|
|
- // ]
|
|
|
- // });
|
|
|
const page = await redBrowser.newPage();
|
|
|
let responseVideo = [];
|
|
|
page.on('response', async(response) => {
|