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 1.0.1 to 1.0.2

lib/Input.js

2

lib/ChromeEvent.js

@@ -192,3 +192,3 @@ "use strict";

let { type } = targetInfo;
const { type } = targetInfo;

@@ -195,0 +195,0 @@ // target为page类型

@@ -196,7 +196,10 @@ "use strict"

functionDeclaration: element => {
let { x, y, width, height } = element.getBoundingClientRect()
let { innerHeight, innerWidth } = window
let innerText = element.innerText
const { x, y, width, height } = element.getBoundingClientRect();
const { innerHeight, innerWidth } = window;
const innerText = element.innerText;
return {
x, y, width, height,
x,
y,
width,
height,
innerHeight,

@@ -294,3 +297,3 @@ innerWidth,

/**
* 点击元素
* 高仿真点击元素
*/

@@ -306,4 +309,4 @@ async click() {

// 定位到元素中心
x = x + width / 2
y = y + height / 2
x = x + width / 2;
y = y + height / 2;

@@ -318,3 +321,20 @@ await Promise.all([

}
/**
* 低仿真点击元素,仅适用于PC端
*/
async lowClick() {
const { objectId } = this;
const click = this.frame.callFunctionOn({
functionDeclaration: element => { element.click(); },
arguments: [{ objectId }]
})
await Promise.all([
click,
this.page.chrome.autoLoad(2000)
]);
}
/**

@@ -321,0 +341,0 @@ * 标亮元素

@@ -19,3 +19,3 @@ "use strict";

options.functionDeclaration = functionDeclaration.toString();
options.functionDeclaration = String(functionDeclaration);

@@ -22,0 +22,0 @@ const { objectId } = this.page.document;

"use strict";
const logger = require('loggercc');
const { Mouse, Touch } = require('./Clicker.js');
const { Mouse, Touch } = require('./Input.js');
const Keyboard = require('./Keyboard.js');

@@ -93,3 +93,3 @@ const Frame = require('./Frame.js');

return await this.history({ relative: 1 })
return await this.history({ relative: 1 });

@@ -146,3 +146,3 @@ }

return await this.document.$(selector)
return await this.document.$(selector);

@@ -174,3 +174,3 @@ }

let element = await this.document.$(selector)
const element = await this.document.$(selector)

@@ -183,3 +183,3 @@ if (element) {

/**
* 点击元素
* 高仿真点击元素
* @param {String} selector CSS选择器

@@ -189,9 +189,9 @@ */

let element = await this.$(selector)
const element = await this.$(selector);
if (element) {
await element.click()
await element.click();
return element
return element;

@@ -202,2 +202,19 @@ }

/**
* 低仿真点击元素,仅适用于PC端
* @param {String} selector CSS选择器
*/
async lowClick(selector) {
const element = await this.$(selector);
if (element) {
await element.lowClick();
return element;
}
}
/**
* 回车输入

@@ -220,7 +237,7 @@ */

let bounding = await this.getBoundingRect(selector)
const bounding = await this.getBoundingRect(selector);
if (bounding) {
let { innerHeight, y, height } = bounding
let { innerHeight, y, height } = bounding;

@@ -233,3 +250,3 @@ let centreY = (height + innerHeight) / 2

return bounding
return bounding;

@@ -245,9 +262,9 @@ }

let element = await this.$(selector)
const element = await this.$(selector);
if (element) {
await element.click()
await element.click();
return element
return element;

@@ -265,9 +282,9 @@ }

let element = await this.$(selector)
const element = await this.$(selector)
if (element) {
await element.type(text, options)
await element.type(text, options);
return element
return element;

@@ -290,7 +307,5 @@ }

let { value } = await this.frame.evaluate({
expression: "document.title"
})
const { value } = await this.frame.evaluate({ expression: "document.title" })
return value
return value;

@@ -303,7 +318,5 @@ }

let { value } = await this.frame.evaluate({
expression: "window.location.href"
})
const { value } = await this.frame.evaluate({ expression: "window.location.href" })
return value
return value;

@@ -313,2 +326,2 @@ }

module.exports = Page
module.exports = Page;
{
"name": "auto-chrome",
"version": "1.0.1",
"version": "1.0.2",
"description": "使用Node.js操作Chrome或Chromium,高仿真的用户行为模拟器",

@@ -5,0 +5,0 @@ "main": "lib/",

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