use anyhow::Result;
use chaser_oxide::{Browser, BrowserConfig, ChaserPage};
use futures::StreamExt;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
println!("Launching chaser-oxide Stealth Browser...");
let (browser, mut handler) = Browser::launch(
BrowserConfig::builder()
.viewport(None)
.build()
.map_err(|e| anyhow::anyhow!(e))?,
)
.await?;
tokio::spawn(async move { while let Some(_) = handler.next().await {} });
println!("Creating page...");
let page = browser.new_page("about:blank").await?;
println!("Applying stealth patches...");
page.enable_stealth_mode().await?;
tokio::time::sleep(Duration::from_millis(100)).await;
println!("Navigating to detection test...");
page.goto("https://bot.sannysoft.com").await?;
tokio::time::sleep(Duration::from_secs(3)).await;
let chaser = ChaserPage::new(page);
println!("Simulating human mouse movement...");
chaser.move_mouse_human(500.0, 300.0).await?;
println!("\nReading values from the PAGE (main world sees spoofed values):");
let user_agent = chaser.evaluate_stealth("navigator.userAgent").await?;
println!(" navigator.userAgent = {:?}", user_agent);
println!("\nWaiting for page to render...");
tokio::time::sleep(Duration::from_secs(5)).await;
chaser
.raw_page()
.save_screenshot(
chaser_oxide::page::ScreenshotParams::builder().build(),
"stealth_test.png",
)
.await?;
println!("Screenshot saved to stealth_test.png");
println!("\nBrowser will close in 5 seconds...");
tokio::time::sleep(Duration::from_secs(5)).await;
Ok(())
}