auto-chrome
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -73,17 +73,9 @@ const Event = require('./Event'); | ||
*/ | ||
close() { | ||
async close() { | ||
this.isClose = true | ||
return this.send('Browser.close') | ||
return await this.send('Browser.close') | ||
} | ||
/** | ||
* 获取当前活跃状态的page | ||
*/ | ||
getPage() { | ||
return this.page | ||
} | ||
/** | ||
@@ -90,0 +82,0 @@ * 初始化标签页 |
@@ -125,2 +125,3 @@ const debug = require('debug'); | ||
'Page.frameStoppedLoading'({ frameId }) { | ||
if (frameId === this.targetId) { | ||
@@ -131,2 +132,3 @@ if (this.awaitLoading) { | ||
} | ||
} | ||
@@ -140,3 +142,2 @@ /** | ||
'DOM.getContentQuads'() { | ||
console.log('DOM.getContentQuads') | ||
} | ||
@@ -143,0 +144,0 @@ } |
@@ -15,2 +15,3 @@ const Message = require('./Message'); | ||
this.document = new Element(this) | ||
this.keyboard = new Keyboard(this) | ||
@@ -66,3 +67,3 @@ this.mouse = new Mouse(this) | ||
} | ||
/** | ||
@@ -81,10 +82,6 @@ * 注入包含参数的JS函数,并获取返回值 | ||
// 相比Runtime.evaluate,Runtime.callFunctionOn是转为函数而设计 | ||
let { result } = await this.send('Runtime.callFunctionOn', { | ||
executionContextId: this.contextId, | ||
functionDeclaration: func, | ||
arguments: args, | ||
returnByValue: true, | ||
awaitPromise: true, | ||
userGesture: true | ||
let result = await this.document.evaluate({ | ||
func, | ||
args, | ||
returnByValue: true | ||
}) | ||
@@ -108,8 +105,6 @@ | ||
let element = new Element(this) | ||
let element = await this.document.$(selector) | ||
let el = await element.$(selector) | ||
if (el) { | ||
return el | ||
if (element) { | ||
return element | ||
} | ||
@@ -124,8 +119,6 @@ | ||
let element = new Element(this) | ||
let element = await this.document.$$(selector) | ||
let el = element.$$(selector) | ||
if (el) { | ||
return el | ||
if (element) { | ||
return element | ||
} | ||
@@ -140,15 +133,8 @@ | ||
let value = await this.evaluate(function (selector) { | ||
let element = await this.document.$(selector) | ||
let element = document.querySelector(selector) | ||
if (element) { | ||
let bounding = element.getBoundingClientRect() | ||
let { x, y, width, height } = bounding | ||
return { x, y, width, height } | ||
} | ||
if (element) { | ||
return await element.getBoundingRect() | ||
} | ||
}, selector) | ||
return value | ||
} | ||
@@ -160,3 +146,3 @@ /** | ||
return await this.evaluate(() => document.title) | ||
return await this.evaluate(document => document.title) | ||
@@ -191,14 +177,7 @@ } | ||
let taget = await this.evaluate(async function (selector) { | ||
let element = document.querySelector(selector) | ||
if (element) { | ||
let { y, height } = element.getBoundingClientRect(); | ||
let { innerHeight } = window | ||
return { innerHeight, y, height } | ||
} | ||
}, selector); | ||
let bounding = await this.getBoundingRect(selector) | ||
if (taget) { | ||
if (bounding) { | ||
let { innerHeight, y, height } = taget | ||
let { innerHeight, y, height } = bounding | ||
@@ -211,2 +190,4 @@ let centreY = (height + innerHeight) / 2 | ||
return bounding | ||
} | ||
@@ -221,14 +202,7 @@ | ||
let taget = await this.evaluate(async function (selector) { | ||
let element = document.querySelector(selector) | ||
if (element) { | ||
let { y, height } = element.getBoundingClientRect(); | ||
let { innerHeight } = window | ||
return { innerHeight, y, height } | ||
} | ||
}, selector); | ||
let bounding = await this.getBoundingRect(selector) | ||
if (taget) { | ||
if (bounding) { | ||
let { innerHeight, y, height } = taget | ||
let { innerHeight, y, height } = bounding | ||
@@ -241,2 +215,4 @@ let centreY = (height + innerHeight) / 2 | ||
return bounding | ||
} | ||
@@ -284,5 +260,5 @@ | ||
*/ | ||
close() { | ||
async close() { | ||
return this.send('Target.closeTarget', { targetId: this.targetId }) | ||
return await this.send('Target.closeTarget', { targetId: this.targetId }) | ||
@@ -289,0 +265,0 @@ } |
{ | ||
"name": "auto-chrome", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128
569138
2841