ClawBench Chrome Extension

June 13, 2026 · View on GitHub

This is the source code for the ClawBench Chrome Extension, which provides browser fingerprint hardening for benchmark runs.

The extension is responsible for the following tasks:

  • Injecting stealth.js at document_start in the page's MAIN world.
  • Applying anti-bot-detection patches for webdriver, plugins, WebGL, permissions, and related browser fingerprints.

Action capture, screenshot capture, request logging, request interception, and tab activation are handled by the runtime server over CDP. The extension does not send data to the server.

A setup.sh script is provided to load the extension into Chrome. Linux and macOS are supported.

Files

FileDescription
manifest.jsonManifest V3 extension definition. Loads stealth.js on all URLs.
stealth.jsAnti-bot-detection patches. Runs at document_start in MAIN world. Overrides navigator.webdriver, plugins, WebGL, permissions, etc.
setup.shDetects Chrome/Chromium binary on macOS or Linux and launches with --load-extension and remote debugging enabled.

Event Capture

Browser event capture now lives in src/clawbench/runtime/runtime-server/server.py. The server injects capture listeners through CDP and preserves the historical action schema:

click, keydown, keyup, input, scroll, change, submit, plus a synthetic pageLoad on each navigation.

Throttling

High-frequency events (scroll, input) are throttled to one every 500ms. Screenshots are also throttled to one every 500ms.

Action Payload

Each action sent to the server contains:

{
  "type": "click",
  "timestamp": 1710000001234,
  "url": "https://example.com/",
  "target": {
    "tagName": "BUTTON",
    "id": "submit-btn",
    "className": "btn primary",
    "textContent": "Submit",
    "xpath": "/html[1]/body[1]/form[1]/button[1]"
  },
  "x": 255,
  "y": 245
}

Additional fields by event type:

  • click: x, y (coordinates)
  • keydown/keyup: key (key name)
  • input/change: value (truncated to 200 chars)
  • scroll: scrollX, scrollY
  • pageLoad: title

Anti-Bot-Detection (Stealth)

The extension includes stealth.js, a content script injected at document_start in the MAIN world — meaning it runs before any page JavaScript and patches the page's actual window/navigator objects (not the extension's isolated world). This reduces the chance of being blocked by reCAPTCHA, Cloudflare Turnstile, and similar bot-detection systems.

The stealth measures are split across three layers:

Layer 1: Chrome Launch Flags (entrypoint.sh)

FlagWhat it does
Removed --enable-automationWas explicitly telling Chrome to set navigator.webdriver = true and show the "controlled by automated software" infobar. Removing it eliminates both signals.
Removed --disable-gpuWas disabling all GPU/WebGL rendering. Sites that fingerprint WebGL would see no renderer — a strong headless signal.
--disable-blink-features=AutomationControlledTells Blink not to set navigator.webdriver = true, even if CDP is attached. Belt-and-suspenders with the flag removal.
--use-gl=angle --use-angle=swiftshaderEnables software-rendered WebGL via SwiftShader through the ANGLE backend. This makes WebGL available with realistic renderer strings without a real GPU. Trade-off: higher CPU usage since all GL operations run in software.
--enable-webglExplicitly ensures WebGL contexts can be created.
--remote-debugging-address=127.0.0.1CDP was previously bound to 0.0.0.0 (all interfaces). Now only accessible internally. External access still works through the socat forwarder on port 9223. Prevents page JavaScript from detecting CDP by probing network ports.

Layer 2: Chrome Profile (entrypoint.sh)

An empty Chrome profile with no bookmarks, no history, and no preferences is a strong signal of a freshly-created automated browser. The entrypoint now pre-populates:

  • Preferences: accept_languages, safebrowsing, dns_prefetching, window_placement, skip_first_run_ui, etc.
  • Bookmarks: Three common entries (Google, YouTube, Wikipedia).
  • Local State: Profile metadata with a named profile ("Person 1").

Layer 3: JavaScript Patches (stealth.js)

#PatchWhy
1navigator.webdriver → falseThe #1 bot detection signal. Real Chrome returns false; automated Chrome returns true. Even with the Blink flag, CDP attachment can re-enable it.
2navigator.languages → ['en-US', 'en']Ensures consistent locale regardless of container environment.
3navigator.plugins — fake Chrome PDF Plugin, Chrome PDF Viewer, Native ClientHeadless/automated Chrome reports an empty PluginArray (length 0). Real Chrome always has PDF and NaCl plugins.
4navigator.mimeTypes — fake application/pdf entriesMust match the fake plugins. Empty mimeTypes = headless signal.
5WebGL getParameter() — return SwiftShader vendor/rendererEven with SwiftShader actually running, this ensures consistent, known-good strings across Chromium versions. Intercepts UNMASKED_VENDOR_WEBGL (0x9245) and UNMASKED_RENDERER_WEBGL (0x9246).
6Permissions.query({name:'notifications'})'prompt', Notification.permission'default'Automated browsers deny all permissions by default. Real browsers return 'prompt'/'default' for notifications.
7window.chrome.runtime — ensure object existsSome bot detectors check if (!window.chrome || !window.chrome.runtime) to distinguish headless Chrome from real Chrome.
8Remove $cdc_/cdc_ properties on documentChromedriver injects these properties. Not used by CDP directly, but removed as a precaution.
9navigator.hardwareConcurrency → 8 (if < 4)Docker containers with limited CPUs may report 1-2, which is suspicious for a desktop browser.
10navigator.deviceMemory → 8 (if < 4)Same — low memory is suspicious for desktop.
11Iframe navigator.webdriver patchingAdvanced fingerprinters create iframes and check navigator.webdriver inside them to bypass page-level overrides. We hook document.createElement('iframe') and patch the iframe's navigator on load.

Layer 4: Dockerfile

libegl1 and libgbm1 are installed to provide the EGL and GBM libraries that Chrome's ANGLE/SwiftShader backend needs. Without them, --use-gl=angle silently falls back to no-GPU mode.

Test Results

Verified against bot-detection sites (2026-03-28):

TestResult
bot.sannysoft.com10/11 main tests pass (only "WebDriver New" orange — CDP attachment quirk; "WebDriver Advanced" passes)
intoli headless detection"You are not Chrome headless"
Cloudflare (nowsecure.nl)Soft Turnstile challenge (not hard-blocked)
CreepJSFingerprint generated without bot flag

Local Development

Run Chrome with the extension loaded:

./setup.sh https://example.com