Skip to main content

capture_perfect_screenshots/
capture_perfect_screenshots.rs

1use anyhow::Result;
2use headless_engine::browser::tab::BrowserTab;
3use headless_engine::network::fingerprint::DeviceProfile;
4use std::fs;
5use std::path::Path;
6
7#[tokio::main]
8async fn main() -> Result<()> {
9    println!("================================================================================");
10    println!(">>> CAPTURING HIGH-FIDELITY SCREENSHOTS FOR CHATGPT & GOOGLE");
11    println!("================================================================================\n");
12
13    let artifact_dir = Path::new(r"C:\Users\abhis\.gemini\antigravity-ide\brain\c08da294-7846-44b1-9403-559e0d23ce0f");
14    let evidence_dir = Path::new("evidence");
15
16    // 1. ChatGPT
17    println!("[1/3] Capturing ChatGPT (chatgpt.com)...");
18    let mut tab1 = BrowserTab::with_profile(DeviceProfile::ChromeWindows)?;
19    tab1.navigate("https://chatgpt.com/").await?;
20    tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
21    if let Some(shot) = tab1.screenshot_async().await {
22        println!("  -> ChatGPT Screenshot Bytes: {}", shot.png_bytes.len());
23        if !shot.png_bytes.is_empty() {
24            fs::write(evidence_dir.join("chatgpt_screenshot.png"), &shot.png_bytes)?;
25            fs::write(artifact_dir.join("chatgpt_screenshot.png"), &shot.png_bytes)?;
26        }
27    }
28
29    // 2. Google AI Mode (udm=50)
30    println!("\n[2/3] Capturing Google AI Mode (udm=50)...");
31    let mut tab2 = BrowserTab::with_profile(DeviceProfile::ChromeWindows)?;
32    tab2.navigate("https://www.google.com/search?q=Rust+programming+language+features&udm=50").await?;
33    tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
34    if let Some(shot) = tab2.screenshot_async().await {
35        println!("  -> Google AI Mode Screenshot Bytes: {}", shot.png_bytes.len());
36        if !shot.png_bytes.is_empty() {
37            fs::write(evidence_dir.join("google_aimode_screenshot.png"), &shot.png_bytes)?;
38            fs::write(artifact_dir.join("google_aimode_screenshot.png"), &shot.png_bytes)?;
39        }
40    }
41
42    // 3. Google Normal Search
43    println!("\n[3/3] Capturing Google Normal Search...");
44    let mut tab3 = BrowserTab::with_profile(DeviceProfile::ChromeWindows)?;
45    tab3.navigate("https://www.google.com/search?q=headless+browser+pure+rust+engine").await?;
46    tokio::time::sleep(tokio::time::Duration::from_millis(500)).await;
47    if let Some(shot) = tab3.screenshot_async().await {
48        println!("  -> Google Normal Search Screenshot Bytes: {}", shot.png_bytes.len());
49        if !shot.png_bytes.is_empty() {
50            fs::write(evidence_dir.join("google_normal_search_screenshot.png"), &shot.png_bytes)?;
51            fs::write(artifact_dir.join("google_normal_search_screenshot.png"), &shot.png_bytes)?;
52        }
53    }
54
55    println!("\n>>> Finished capturing screenshots.");
56    Ok(())
57}