pub async fn apply_stealth_to_page(
page: &Page,
config: &BrowserConfig,
) -> Result<()>Expand description
Inject all stealth scripts into a freshly opened browser page.
Scripts are registered with Page.addScriptToEvaluateOnNewDocument so they
execute before any page-owned JavaScript on every subsequent navigation.
Which scripts are injected is determined by
crate::config::StealthLevel:
| Level | Injected content |
|---|---|
None | Nothing |
Basic | CDP leak fix + navigator.webdriver removal + minimal navigator spoof |
Advanced | Basic + full WebGL/navigator spoofing + fingerprint + WebRTC protection |
§Errors
Returns crate::error::BrowserError::CdpError if a CDP command fails.
§Example
use stygian_browser::stealth::apply_stealth_to_page;
apply_stealth_to_page(page, config).await?;