Assembles a complete JavaScript injection script that overrides browser fingerprint surfaces CDP cannot control, using a shared native-toString hook and per-section builders.
def build_fingerprint_js(
config: FingerprintConfig, user_agent: str = '', platform: str = ''
) -> str:
"""Build the complete page fingerprint injection script.
Returns a single JS string that installs the shared native-toString hook
and overrides every configured fingerprint surface CDP cannot handle.
Empty string if nothing to inject.
Args:
config: Fingerprint configuration.
user_agent: Reduced User-Agent string to expose as ``navigator.userAgent``
in every realm (including detached iframes). Empty string skips it.
platform: ``navigator.platform`` value to expose in every realm.
"""
parts: list[str] = [_build_identity_js(user_agent, platform)]
if 'navigator' in config:
nav: dict[str, object] = dict(config[
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key