Seatext library / BotRefund evidence

How Browser Fingerprinting Detects Playwright Init Scripts

Websites run JavaScript checks that look for mismatches in browser APIs caused by Playwright's init scripts. These mismatches reveal hidden or altered properties that real browsers never expose.

Built for advertisers who need clear, refund-ready traffic evidence.

Browser fingerprinting tests detect Playwright init scripts by probing for inconsistencies in standard browser APIs. Playwright injects or modifies objects such as navigator and window before page scripts run, and fingerprinting code reads those objects from a different execution context to spot the changes.

How Playwright Injects the Init Script

Playwright launches a browser instance and injects a script before any page JavaScript executes. This script runs in the browser's main world and can modify global objects. The injection happens via the page.addInitScript() API or by passing a script file to browser.newContext({ initScript: 'path/to/script.js' }).

// Example init script that hides navigator.webdriver
const script = `Object.defineProperty(navigator, 'webdriver', { get: () => false });`;
await page.addInitScript(script);

The script runs in the same context as the page but before any other scripts. It can also patch window, document, and prototype chains. Because it runs early, it can overwrite properties that fingerprinting scripts later read.

What the Playwright Init Script Check Looks For

The test examines properties that should be native to a genuine browser. If a property is missing, has an unexpected value, or shows a pattern that only automation tools produce, the signal is flagged.

Typical API Mismatches

  • Presence of navigator.webdriver set to true.
  • Non‑standard entries like window.cdc_ that appear in Selenium‑derived environments.
  • Altered WebGL renderer strings or missing hardware acceleration flags.
  • Font‑rendering differences caused by headless rendering pipelines.
  • Missing or altered AudioContext properties such as sampleRate or state.
  • Inconsistent navigator.plugins length or navigator.mimeTypes entries.
  • Modified window.chrome object or missing chrome.runtime.

Fingerprinting scripts often call these APIs from a sandboxed iframe or a web worker to see if the values differ from the main context. A mismatch indicates the init script patched only one context.

// Example fingerprinting check from an iframe
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
const iframeNavigator = iframe.contentWindow.navigator;
console.log('webdriver in iframe:', iframeNavigator.webdriver);
console.log('webdriver in main:', navigator.webdriver);

Why a Single Anomaly Isn’t a Verdict

BotRefund treats each mismatch as one piece of evidence, not a final decision. Privacy extensions, corporate proxies, or unusual devices can also produce quirks. The platform cross‑checks the init‑script signal with dozens of other browser, network, and behavior signals before labeling traffic as a bot.

For example, a popular privacy extension may set navigator.webdriver = false to hide tracking, but it also removes navigator.plugins entries. That pattern looks like automation, yet the user is human. BotRefund's cross‑checking sees that the network IP is residential, mouse movements have natural tremor, and session duration matches human behavior. The combined evidence overrides the single anomaly.

Expert Perspective

"Our team sees that init‑script detection is reliable only when combined with network and behavioral signals—never alone. A single patched property can be caused by a privacy tool, a corporate policy, or an unusual device. We weight the init‑script signal as one of 106 independent checks, and our AI model evaluates the full pattern before making a verdict."

— BotRefund Security Engineer

Key Facts

SignalWhat It ChecksTypical Automated Result
Playwright Init ScriptsLooks for mismatched API values that a real browser would not createPatched or hidden properties that break when inspected from another angle
WebGL RendererValidates hardware‑accelerated graphics stringsGeneric or missing renderer identifiers
Font RenderingCompares sub‑pixel smoothing and glyph metricsUniform rasterization typical of headless environments
AudioContextChecks sample rate and channel count consistencyDefault values that differ from hardware‑specific outputs
Navigator PluginsVerifies plugin list length and namesEmpty or generic plugin arrays

How to Verify Detection on Your Site

  1. Open the page in a normal browser and run Object.keys(navigator) in the console – note the output.
  2. Run the same check with Playwright using its default init script.
  3. Compare the two outputs; any extra or altered keys indicate a detection trigger.
  4. Open the DevTools Network tab and filter for "script" to see if any fingerprinting scripts load from third‑party domains.
  5. Run a headless Chrome instance with --disable-blink-features=AutomationControlled and repeat the comparison.

Common Mistake

Trying to hide navigator.webdriver alone is insufficient. Fingerprinting scripts often query the same property from a sandboxed iframe or a detached worker, which still reveals the automation flag.

Practical Scenarios

  • E‑commerce checkout pages – bots that auto‑fill forms are caught when the init script leaks a patched navigator object.
  • Content paywalls – fingerprinting can block scrapers that rely on Playwright’s default context.
  • Ad fraud detection – mismatched rendering contexts expose click farms using headless browsers.

Step‑by‑Step: Bot Caught on an E‑commerce Checkout

  1. Attacker launches Playwright with default init script targeting the checkout page.
  2. Playwright injects the init script, which patches navigator.webdriver to false and adds a fake window.chrome object.
  3. Page loads; BotRefund's fingerprinting script runs in the main context and also spawns a hidden iframe.
  4. The iframe reads navigator.webdriver and sees false (patched), but the main context still shows true because the patch didn't propagate to the iframe's navigator.
  5. BotRefund records the mismatch as one signal.
  6. Simultaneously, network analysis shows the request comes from a data‑center IP, and behavioral analysis detects super‑fast form fills (< 100 ms per field).
  7. The AI model correlates all signals: init‑script mismatch + data‑center IP + robotic input speed = 99% confidence bot.
  8. The session is flagged, and the merchant receives a detailed report with click IDs and signal breakdown.

Limitations

If a site only checks for a single property, sophisticated stealth plugins can mask that property and evade detection. Robust detection requires a suite of independent checks, which is why BotRefund combines over 100 signals.

Glossary

  • Init script – JavaScript injected by Playwright before any page script runs.
  • Fingerprint – A collection of observable browser characteristics used to identify a device.
  • Stealth – Techniques that modify or hide automation artifacts.
  • Cross‑context check – Reading the same API from multiple execution contexts (main page, iframe, worker) to detect inconsistencies.

FAQ

What exactly does the Playwright init script modify?
It can add, remove, or overwrite properties on window, navigator, and other global objects to make the environment look like a regular browser.
Can I completely hide the init‑script signal?
Not reliably. Even if you mask known properties, fingerprinting tools can probe from alternate contexts that still expose the underlying changes.
Does disabling headless mode stop detection?
It reduces some signals (e.g., missing GPU), but many API mismatches remain because the init script still runs.
How does BotRefund use this signal?
It records the mismatch as one of 106 independent checks, then correlates it with network, device, and behavioral data to produce a confidence score.
Is there a performance impact on my site?
The fingerprinting checks are lightweight JavaScript snippets that run in milliseconds and do not noticeably affect page load times.
What if a legitimate user has a privacy extension that triggers the same mismatch?
BotRefund cross‑checks the signal with network reputation, mouse dynamics, and session behavior. A single anomaly rarely overrides the full pattern.

Further reading and comparison sources

These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.

Further reading and comparison sources

These external sources provide additional context for evaluating the topic. Their inclusion is not an endorsement.

Learn more

Visit the website for more information.

Learn more