|
2 | 2 | """ |
3 | 3 | Soul Browser Test Script |
4 | 4 | Opens https://telegram.org/support for 2 minutes in visible mode (no headless) |
| 5 | +Uses Playwright with stealth settings |
5 | 6 | """ |
6 | 7 |
|
7 | 8 | import time |
8 | | -from soulbrowser import launch |
| 9 | +from playwright.sync_api import sync_playwright |
9 | 10 |
|
10 | 11 | def main(): |
11 | 12 | print("🚀 Starting Soul Browser...") |
12 | 13 | print("📍 Opening: https://telegram.org/support") |
13 | 14 | print("⏱️ Will stay open for 2 minutes") |
14 | 15 | print("-" * 50) |
15 | 16 |
|
16 | | - # Launch browser in visible mode (headless=False) |
17 | | - browser = launch(headless=False) |
18 | | - |
19 | | - # Create new page |
20 | | - page = browser.new_page() |
21 | | - |
22 | | - # Navigate to Telegram support |
23 | | - page.goto("https://telegram.org/support", wait_until="domcontentloaded") |
24 | | - |
25 | | - print(f"✅ Page loaded: {page.title()}") |
26 | | - print("⏳ Waiting for 2 minutes...") |
27 | | - |
28 | | - # Wait for 2 minutes (120 seconds) |
29 | | - time.sleep(120) |
30 | | - |
31 | | - print("🛑 Closing browser...") |
32 | | - browser.close() |
| 17 | + with sync_playwright() as p: |
| 18 | + # Launch Chromium in visible mode with stealth args |
| 19 | + browser = p.chromium.launch( |
| 20 | + headless=False, |
| 21 | + args=[ |
| 22 | + "--disable-blink-features=AutomationControlled", |
| 23 | + "--disable-infobars", |
| 24 | + "--disable-dev-shm-usage", |
| 25 | + "--disable-browser-side-navigation", |
| 26 | + "--disable-gpu-sandbox", |
| 27 | + "--no-first-run", |
| 28 | + "--no-service-autorun", |
| 29 | + "--password-store=basic", |
| 30 | + "--use-mock-keychain", |
| 31 | + "--disable-backgrounding-occluded-windows", |
| 32 | + "--disable-renderer-backgrounding", |
| 33 | + "--disable-background-timer-throttling", |
| 34 | + "--disable-ipc-flooding-protection", |
| 35 | + "--enable-features=NetworkService,NetworkServiceInProcess", |
| 36 | + ] |
| 37 | + ) |
| 38 | + |
| 39 | + # Create context with realistic settings |
| 40 | + context = browser.new_context( |
| 41 | + viewport={"width": 1920, "height": 1080}, |
| 42 | + user_agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", |
| 43 | + locale="en-US", |
| 44 | + timezone_id="America/New_York", |
| 45 | + ) |
| 46 | + |
| 47 | + # Remove webdriver detection |
| 48 | + context.add_init_script(""" |
| 49 | + Object.defineProperty(navigator, webdriver, { |
| 50 | + get: () => undefined |
| 51 | + }); |
| 52 | + |
| 53 | + // Overwrite plugins |
| 54 | + Object.defineProperty(navigator, plugins, { |
| 55 | + get: () => [1, 2, 3, 4, 5] |
| 56 | + }); |
| 57 | + |
| 58 | + // Overwrite languages |
| 59 | + Object.defineProperty(navigator, languages, { |
| 60 | + get: () => [en-US, en] |
| 61 | + }); |
| 62 | + |
| 63 | + // Hide automation |
| 64 | + window.chrome = { runtime: {} }; |
| 65 | + """) |
| 66 | + |
| 67 | + # Create page and navigate |
| 68 | + page = context.new_page() |
| 69 | + page.goto("https://telegram.org/support", wait_until="domcontentloaded") |
| 70 | + |
| 71 | + print(f"✅ Page loaded: {page.title()}") |
| 72 | + print("⏳ Waiting for 2 minutes...") |
| 73 | + |
| 74 | + # Wait for 2 minutes (120 seconds) |
| 75 | + time.sleep(120) |
| 76 | + |
| 77 | + print("🛑 Closing browser...") |
| 78 | + browser.close() |
| 79 | + |
33 | 80 | print("✅ Done!") |
34 | 81 |
|
35 | 82 | if __name__ == "__main__": |
|
0 commit comments