Huge News!Announcing our $40M Series B led by Abstract Ventures.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.3.1 to 0.3.2

test/frameTree.js

2

lib/Chrome.js

@@ -47,3 +47,3 @@ const Event = require('./Event');

let awaitLoading = new zPromise({ time: 15000, message: '网页加载超时' })
let awaitLoading = new zPromise({ time: 10000, message: `网页加载超时` })

@@ -50,0 +50,0 @@ this.pages.set(targetId, { awaitLoading })

@@ -122,10 +122,10 @@ const debug = require('debug');

// 创建等待页面加载完成Promise
if (!this.page.awaitLoading) {
// if (!this.page.awaitLoading) {
this.page.awaitLoading = new zPromise({ time: 15000, message: '网页加载超时' })
this.page.awaitLoading.catch(info => {
signale.warn(info)
})
// this.page.awaitLoading = new zPromise({ time: 15000, message: `${targetId}网页加载超时` })
// this.page.awaitLoading.catch(info => {
// signale.warn(info)
// })
}
// }

@@ -153,36 +153,11 @@ // 默认仿真配置

*/
async 'Target.targetInfoChanged'({ targetInfo }) {
// async 'Target.targetInfoChanged'({ targetInfo }) {
let { type, targetId } = targetInfo
// let { targetId } = targetInfo
if (type === 'page') {
// if (targetId === this.page.targetId) {
// 获取targetId对应的page实例
let page = this.pages.get(targetId)
// }
if (page) {
// if (page.awaitLoading && page.awaitLoading.state !== 'pending') {
// page.awaitLoading = new zPromise({ time: 1000, message: '网页加载超时' })
// page.awaitLoading.catch(message => {
// signale.warn(message)
// })
// }
if (page.awaitLoading) {
page.awaitLoading = page.awaitLoading.restart()
page.awaitLoading.catch(message => {
signale.warn(message)
})
}
}
}
}
// }
/**

@@ -189,0 +164,0 @@ * Target分离,用于监听关闭标签事件

const debug = require('debug');
const { signale } = require('./helper');
const { signale, zPromise } = require('./helper');

@@ -90,7 +90,13 @@ const debugSendSession = debug('chrome:send:session');

*/
// 'Page.frameNavigated'({ frame }) {
// // if (frame.id === this.targetId) {
// // this.awaitLoading.resolve()
// // }
// }
'Page.frameNavigated'({ frame }) {
if (frame.id === this.targetId) {
if (this.awaitLoading) {
this.awaitLoading = this.awaitLoading.restart()
this.awaitLoading.catch(error => { })
} else {
this.awaitLoading = new zPromise({ time: 10000, message: `网页加载超时` })
this.awaitLoading.catch(error => { })
}
}
}
/**

@@ -103,7 +109,9 @@ * 框架开始加载时触发

/**
* 框架加载完毕时触发
* 框架加载完毕时触发,子框架优先级高于主框架
*/
'Page.frameStoppedLoading'({ frameId }) {
if (frameId === this.targetId) {
this.awaitLoading.resolve()
if (this.awaitLoading) {
this.awaitLoading.resolve()
}
}

@@ -110,0 +118,0 @@ }

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

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

@@ -14,26 +14,20 @@ const autoChrome = require('../../')

let page1 = await chrome.newPage('https://www.so.com/')
let page = await chrome.newPage('https://www.szhkch.com/')
await sleep(1000)
// let page = await chrome.newPage('https://www.so.com/')
let page2 = await chrome.newPage('https://www.baidu.com/')
// await page.awaitLoading.catch(info => {
// signale.warn(info, 999)
// })
await sleep(2000)
// await sleep(2000)
await chrome.page.goto('https://www.szhkch.com/')
// await chrome.mouse.scroll(0, 500)
await sleep(2000)
// await sleep(1000)
await chrome.mouse.scroll(0, 500)
await page.close()
await sleep(1000)
await page2.close()
await sleep(2000)
await page1.close()
await sleep(3000)
await chrome.close()

@@ -43,4 +37,4 @@

run().catch(function(error){
run().catch(function (error) {
console.error(error)
})
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