build_fingerprint_worker_js (fingerprint_builder)

pydoll · scraping, fingerprint-evasion, web-worker-spoofing, javascript-injection, automation

Generates a JavaScript injection script to spoof Web Worker fingerprinting surfaces like navigator and WebGL, ensuring consistent evasion in worker contexts.

def build_fingerprint_worker_js(
    config: FingerprintConfig, user_agent: str = '', platform: str = ''
) -> str:
    """Build the worker fingerprint injection script.

    Web Workers expose ``WorkerNavigator`` (not the page ``Navigator``) and have
    no ``screen``/``window``/``document``, so only the surfaces that exist in a
    worker are injected: ``navigator.userAgent``, ``navigator.appVersion``,
    ``navigator.platform``, ``navigator.deviceMemory``, ``navigator.languages`` /
    ``navigator.language``, ``navigator.connection`` and WebGL (via
    ``OffscreenCanvas``).

    ``userAgent`` / ``appVersion`` / ``platform`` are injected here (guarded by
    existence) because ``Emulation.setUserAgentOverride`` does not reliably update
    those ``WorkerNavigator`` properties on out-of-pa

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key