Applies a browser fingerprint profile to a tab and its workers via CDP overrides and JS injection, ensuring consistent identity across pages, iframes, and workers.
class FingerprintApplier:
"""Applies a fingerprint profile to a single tab and its worker targets.
Owns the whole fingerprint-injection subsystem so ``Tab`` does not: the CDP
``Emulation`` overrides, the ``addScriptToEvaluateOnNewDocument`` JavaScript
injection, and the auto-attach machinery that replays the same identity on
dedicated, shared and service workers. A ``Tab`` composes an instance of this
and ``Tab.apply_fingerprint`` is a thin wrapper delegating to :meth:`apply`.
"""
# Per-session worker CDP commands use a short timeout so a slow or
# unresponsive worker target can never block resuming the worker.
_WORKER_COMMAND_TIMEOUT = 5
_ORIENTATION_CDP_MAP: dict[str, ScreenOrientationType] = {
'portrait-primary': ScreenOrientationTy
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key