Skip to content

browser-vision/cdp-extras

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Browser Vision CDP Extras Examples

Examples for using Browser Vision CDP extras from your own automation code.

Demo

Browser Vision CDP Extras demo

Browser Vision extends the Chrome DevTools Protocol with two user-facing input capabilities:

  • Human Type: Input.typeText, a Human Type text entry command.
  • VirtualMouse: VirtualMouse.create, configure, move, click, and destroy, virtual cursor with human-like movement.

These commands are Browser Vision extensions. They are not available in stock Chromium or Chrome.

Requirements

  • Browser Vision running with remote CDP access exposed.
  • Node.js 18+ for JavaScript examples.
  • Python 3.9+ for Python examples.

Examples default to:

http://127.0.0.1:9222

Override it with CDP_ENDPOINT:

CDP_ENDPOINT=http://127.0.0.1:9222 npm --prefix examples/javascript run human-type
CDP_ENDPOINT=http://127.0.0.1:9222 python3 examples/python/human_type.py

JavaScript Examples

Install dependencies:

npm --prefix examples/javascript install

Run Human Type:

npm --prefix examples/javascript run human-type

Run VirtualMouse:

npm --prefix examples/javascript run virtual-mouse

Python Examples

Install dependencies:

python3 -m venv /tmp/cdp-extras-venv
/tmp/cdp-extras-venv/bin/pip install -r examples/python/requirements.txt

Run Human Type:

/tmp/cdp-extras-venv/bin/python examples/python/human_type.py

Run VirtualMouse:

/tmp/cdp-extras-venv/bin/python examples/python/virtual_mouse.py

Example Matrix

Feature JavaScript Python
Human Type examples/javascript/human-type.mjs examples/python/human_type.py
VirtualMouse examples/javascript/virtual-mouse.mjs examples/python/virtual_mouse.py

Human Type API

Input.typeText types into the currently focused editable element.

await client.send("Input.typeText", {
  text: "Typed by Browser Vision Human Type",
  minDelay: 55,
  maxDelay: 130,
});

Parameters:

  • text: text to type.
  • minDelay: optional minimum inter-key delay in milliseconds.
  • maxDelay: optional maximum inter-key delay in milliseconds.

VirtualMouse API

Minimal flow:

await client.send("VirtualMouse.create", {
  speed: 1.2,
  x: 100,
  y: 100,
  targetWidth: 32,
  noiseScale: 1.0,
  includeReaction: true,
  exactFinal: true,
  seed: 12345,
});

await client.send("VirtualMouse.move", { x: 500, y: 240 });
await client.send("VirtualMouse.click", { duration: 40 });
await client.send("VirtualMouse.destroy");

Commands:

  • VirtualMouse.create: creates the per-page virtual mouse.
  • VirtualMouse.configure: changes movement settings for later commands.
  • VirtualMouse.move: moves to x, y in CSS pixels relative to the main frame viewport.
  • VirtualMouse.click: moves if coordinates are provided, then left-clicks. Omitted coordinates use the remembered cursor position.
  • VirtualMouse.destroy: removes the virtual cursor.

Useful options:

  • speed: movement speed scale, 0..4; 0 means teleport.
  • targetWidth: target size in CSS pixels, 8..96.
  • noiseScale: movement noise multiplier, 0..3; 0 disables noise.
  • includeReaction: includes a reaction delay before movement.
  • exactFinal: ends exactly at the requested point when true.
  • seed: deterministic trajectory variation.
  • duration: VirtualMouse.click hold time between mouse down and mouse up, valid 0..1000 ms.

Using From Your Library

See docs/using-from-your-library.md for the copyable integration pattern and wrapper guidance.

About

CDP Extras is a repository containing examples for using Browser Vision's Chrome DevTools Protocol (CDP) extensions. It demonstrates two main capabilities: Human Type (for natural text input) and VirtualMouse (for human-like cursor movements). The repository provides working examples in both JavaScript and Python.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors