Captcha
A native captcha module inside the browser engine: it clears supported challenges without executing a single line of JavaScript in the page — perception through the accessibility path, action through the engine's humanized input, so everything it does looks like a real user.
The short version
The module is always on — there is no enable switch. Two entry points:
- On demand —
resolveCaptcha: solve once, right now. - Automatic mode — watch every tab and clear supported captchas as they
appear. Enable it at launch (
--captcha-auto) or on the running browser, in both directions (the CDPBrowser.setCaptchaAutocommand, or the MCPcaptcha_autotool). The runtime toggle always wins over the launch flag.
What a vendor rebrand changes — labels, hosts, layout sizes — is data, updated through the signature pack without a rebuild.
Supported challenges
| Family | Kind | Notes |
|---|---|---|
| Cloudflare Turnstile | checkbox (interstitial + widget) | also look-alike gates |
| reCAPTCHA v2 | checkbox + audio flow | audio transcribed by a configured STT endpoint (or the local Whisper server — see below) |
| reCAPTCHA v2 / hCaptcha | image grids | tiles located by perception, chosen by a configured vision model (--captcha-llm-*) |
| GeeTest v3/v4 | slide puzzle | the gap is found in the pixels of a native screenshot; dragged with a human velocity profile; no backend needed |
| AWS WAF | checkbox | |
| Akamai / PerimeterX | press & hold | a humanized press-hold-release (1.4–2.2 s, jittered); div-only widget, seen through the text-node perception fallback |
Invisible challenges (Turnstile invisible, reCAPTCHA v3) have nothing to
act on: they are passive scoring, reported as not_found.
Launch switches
--captcha-auto # automatic mode from the start
--captcha-interval=3 # idle re-check period, seconds (1..60, default 3)
--captcha-timeout=30 # verification budget per solve, seconds (1..300)
--captcha-llm-url/key/model # optional vision backend (image grids)
--captcha-stt-url/key/model # optional STT backend (reCAPTCHA audio)
--captcha-signatures=URL # signature pack: https://… (loopback http and
# file:// allowed)Remote endpoints must be https (loopback http allowed); keys travel only in the Authorization header and never appear in logs.
The automatic mode
One watcher per tab: after each committed navigation (and once when watching
starts) it runs the same pipeline as resolveCaptcha — detection is part of
it, so a page without a captcha costs one observation and nothing else. Tabs
opened later are picked up by the sweep.
The idle watch is two-tier, so the default 3 s period costs almost nothing: every tick is a frame-tree scan — pure browser process, microseconds, the renderer untouched — and the full accessibility observation (milliseconds of renderer CPU per tab) runs only when a challenge frame is present (every real family has one) or every ~15 s as a fallback for frame-less gates.
Guards: one solve at a time per tab, a per-tab cooldown, never twice for the
same navigation, and failures are never auto-retried (call captcha_resolve
for deliberate retries).
Runtime control on a running browser
CDP (any client connected to the browser):
{"id":1,"method":"Browser.setCaptchaAuto","params":{
"targetId":"<any tab>","enabled":true}}
→ {"enabled":true}
{"id":2,"method":"Browser.resolveCaptcha","params":{
"targetId":"<the page>","timeoutSeconds":30}}
→ {"status":"solved","provider":"cloudflare","message":"challenge cleared"}
{"id":3,"method":"Browser.setCaptchaOptions","params":{
"targetId":"<any tab>","options":"{\"signaturesUrl\":\"https://ops.example/pack.json\"}"}}
→ {"options":"{…the normalized options now in effect…}"}status ∈ solved | not_found | disabled | timeout | failed | tab_closed | unsupported. The auto toggle and the options are process-global (all tabs);
targetId only routes the call. setCaptchaOptions accepts the same keys
as the runtime view: auto, intervalSeconds, timeoutSeconds, the
llm*/stt* backends and signaturesUrl — setting a pack URL reloads
the pack live.
Signature packs
A pack is a small JSON an operator serves (any static host — S3, a CDN, your own endpoint); the engine is the client. It carries everything a vendor rebrand touches, so fixes land server-side without a rebuild:
{
"version": 2,
"providers": {
"cloudflare": {
"frame_hosts": ["challenges.cloudflare.com"],
"checkbox_names": ["verify you are human"],
"entry_names": [], "audio_buttons": [], "play_buttons": [],
"response_fields": [], "verify_buttons": [], "refresh_buttons": [],
"geometry": {"cell_min_px": 40}
}
}
}version 1— the detection strings (hosts, every control's label snippets). Providers not listed keep their compiled-in defaults.version 2— addsgeometry: per-provider flow tuning (handle_min_px,cell_min_px,notch_margin_px,hold_ms_min/max) the engine reads instead of constants.- Remote URLs must be https (loopback http and
file://allowed). The parser is strict — known keys only, bounded numbers, printable-ASCII strings, size caps — a broken pack is rejected with a reason and the engine keeps its defaults: a pack can retune the flows, never break them. - Load at launch (
--captcha-signatures=…) or live on a running browser (setCaptchaOptionswithsignaturesUrl; file packs apply immediately).
Flow logic — a genuinely new interaction type — is the only part that needs an engine update; everything short of it is data.
CLI
start accepts the launch switches directly:
npx ninjasurfer start my-profile --captcha-auto --captcha-interval=5 \ --captcha-stt-url=https://stt.example/v1/audio/transcriptions --captcha-stt-key=…
--local-stt (with an optional --stt-model) starts the local Whisper server
described under Backends and passes its --captcha-stt-*
switches to the browser for you.
MCP
The MCP server exposes three tools (they map 1:1 to the CDP commands above):
captcha_resolve({ timeoutSeconds?, profile?, tab? })— one-shot solve on the current page.captcha_auto({ enabled, profile? })— flip the automatic mode on the running browser, in both directions.captcha_options({ options, profile? })— the full runtime options surface, including a live signature-pack reload viasignaturesUrl.
An engine build without the captcha module answers with a clear "this engine build has no captcha module" instead of a raw protocol error.
Backends
- Vision (
--captcha-llm-*): any OpenAI-compatible chat/completions endpoint that accepts images — used to pick grid tiles. - STT (
--captcha-stt-*): any OpenAI-compatible/audio/transcriptionsendpoint — used for the reCAPTCHA audio flow. - Local Whisper: the JS SDK ships an optional local STT server (Whisper
via transformers.js, loopback, no keys, no cloud).
npx ninjasurfer sttruns it and prints the--captcha-stt-*switches to launch with;start --local-sttdoes both in one step. It needs the optional packages@huggingface/transformersandaudio-decode.