
    g1                         d dl mZ d dlmZ d dlmZ d dlmZm	Z	 dedefdZ
dedefdZdedefd	ZddedefdZddedefdZy
)    )Page)StealthConfig)
PropertiesBrowserType
propertiesconfigc                     g }t               }|j                  |       D ]  }|j                  |        dj                  |      S )zECombines the scripts for the page based on the properties and config.
)r   enabled_scriptsappendjoin)r   r   scriptsscripts       O/var/www/openai/venv/lib/python3.12/site-packages/playwright_stealth/stealth.pycombine_scriptsr      s@     G_F((4v 599W    pagec                 H    |j                  | j                         d          yzuGenerates the stealth headers for the page by replacing the original headers with the spoofed ones for every request.headerNset_extra_http_headersas_dictr   r   s     r   generate_stealth_headers_syncr      s    
 2 2 4X >?r   c                 d   K   |j                  | j                         d          d{    y7 wr   r   r   s     r   generate_stealth_headers_asyncr      s(     

%
%j&8&8&:8&D
EEEs   &0.0Nc                 j    t               }t        ||      }t        ||        | j                  |       y)z@teaches synchronous playwright Page to be stealthy like a ninja!N)r   r   r   add_init_scriptr   r   r   combined_scripts       r   stealth_syncr"      s-    J%j&9O!*d3)r   c                    K   t        |r|j                  nt        j                        }t	        ||      }t        ||        d{    | j                  |       d{    y7 7 w)zAteaches asynchronous playwright Page to be stealthy like a ninja!)browser_typeN)r   r$   r   CHROMEr   r   r   r    s       r   stealth_asyncr&   &   sY     )<)<KL^L^_J%j&9O
(T
:::



/// ;/s$   AA)A%A)A' A)'A))N)playwright.async_apir   	AsyncPageplaywright.sync_apiSyncPageplaywright_stealth.corer   playwright_stealth.propertiesr   r   r   r   r   r"   r&    r   r   <module>r.      sv    2 0 1 A
 M @j @ @
FZ Fy F
*x * *0i 0 0r   