New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

auto-chrome

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-chrome - npm Package Compare versions

Comparing version 0.11.2 to 0.11.3

test/browserMore.js

15

index.js
"use strict"
const cluster = require('cluster');
const childProcess = require('child_process')

@@ -15,4 +16,12 @@ const readline = require('readline')

args.push("--remote-debugging-port=9222")
// cluster模式下启用多个不同的端口,避免端口重复
let port
if (cluster.isMaster) {
port = 9222
} else if (cluster.isWorker) {
port = 9222 + cluster.worker.id
}
args.push(`--remote-debugging-port=${port}`)
if (userDataDir) {

@@ -74,3 +83,3 @@ args.push(`--user-data-dir=${userDataDir}`)

chromeProcess.kill()
throw error

@@ -99,2 +108,4 @@

chrome.options = options
return chrome

@@ -101,0 +112,0 @@

"use strict"
const ChromeEvent = require('./ChromeEvent');
const childProcess = require('child_process')

@@ -62,6 +63,6 @@ class Chrome extends ChromeEvent {

*/
async newPage(url = 'about:newtab') {
async newPage(url = 'about:newtab', browserContextId) {
await Promise.all([
this.send('Target.createTarget', { url }),
this.send('Target.createTarget', { url, browserContextId }),
this.autoLoad(2000)

@@ -74,2 +75,19 @@ ])

/**
* 在独立浏览器窗口中打开网页
* @param {String} url 新标签的初始url
*/
async newChromePage(url = 'about:newtab') {
childProcess.spawn(this.options.executablePath, [...this.options.args, url, `--new-window`])
}
/**
* 创建新的浏览器上下文,仅支持隐身模式
*/
async createBrowserContext() {
return await this.send('Target.createBrowserContext')
}
/**
* 通过targetId关闭指定的标签

@@ -76,0 +94,0 @@ * @param {*} targetId

39

lib/ChromeEvent.js

@@ -130,39 +130,39 @@ "use strict"

}
if (loadPromise.state === 'pending') {
await loadPromise
}
// 循环监测
for (let i = 1; i <= (delay / 100); i++) {
await sleep(100)
// 原标签
if (page === this.page) {
if (ctxTime !== page.ctxTime) {
// 为url重定向保留时间
await sleep(800)
await page.loadPromise
return
}
}
// 新标签
else {
await this.autoLoad()
return
}
}
} else {

@@ -200,2 +200,7 @@

}
async getTargets() {
return await this.send('Target.getTargets')
}
/**

@@ -252,2 +257,4 @@ * targetCreated事件,仅在创建page或frame时触发

// console.log(await this.getTargets())
let { type, url, title } = targetInfo

@@ -254,0 +261,0 @@

{
"name": "auto-chrome",
"version": "0.11.2",
"version": "0.11.3",
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,10 @@ "use strict"

await chrome.newChromePage('www.baidu.com')
await chrome.newChromePage('www.so.com')
await chrome.newChromePage('www.sogou.com')
return
let { page } = chrome

@@ -25,0 +33,0 @@

@@ -17,3 +17,3 @@ "use strict"

'--start-maximized',
'--proxy-server=14.157.100.237:21341'
'--proxy-server=113.110.194.28:10306'
],

@@ -20,0 +20,0 @@ emulate: {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc