Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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,
  samplingRateHz: 125,
});

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. Set release: false to press and hold the left button; the next VirtualMouse.click releases it.
  • 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.
  • samplingRateHz: mousemove points generated per second of movement, 1..240, default 125.
  • trajectory: trajectory algorithm name — lognormal-ou (default), dmtg-spline, minimum-jerk, sigma-lognormal, or windmouse.
  • delay: VirtualMouse.click pre-click delay between reaching the target and mouse down, valid 0..1000 ms, default 0. It does not change movement duration or the duration hold time.
  • duration: VirtualMouse.click hold time between mouse down and mouse up, valid 0..1000 ms.
  • release: whether VirtualMouse.click releases the left button, boolean, default true. true presses and releases the left button (a normal click) and also releases a button held by a previous release: false click. false presses and holds the left button (no mouse up), so the next VirtualMouse.click releases it — use it for click-and-hold and drag-and-drop.

delay and duration are independent: delay waits after the cursor reaches the target and before mouse down, while duration is the mouse-down to mouse-up hold time.

await client.send("VirtualMouse.click", { x: 520, y: 260, delay: 40 });

Drag and drop — press and hold, move while held, then release:

await client.send("VirtualMouse.click", { x: 120, y: 200, release: false });
await client.send("VirtualMouse.move", { x: 480, y: 360 });
await client.send("VirtualMouse.click", { release: true });

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

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors