Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Open fingerprint.com demo with a spoofed profile and keep it visible. | |
| Usage: | |
| python scripts/test_fingerprint_com.py | |
| python scripts/test_fingerprint_com.py --duration 120 --url https://fingerprint.com/demo/ | |
| python scripts/test_fingerprint_com.py --headless | |
| """ | |
| import argparse | |
| import sys | |
| import time | |
| from DrissionPage import ChromiumPage, ChromiumOptions | |
| # Make local modules importable | |
| sys.path.insert(0, '.') | |
| from spoofers.cdp_spoofer import CDPSpoofer | |
| from spoofers.profile import generate_random_profile | |
| def main() -> int: | |
| parser = argparse.ArgumentParser(description="Open fingerprint.com demo with spoofed profile") | |
| parser.add_argument('--duration', type=int, default=120, help='Seconds to keep the page open') | |
| parser.add_argument('--url', default='https://fingerprint.com/demo/', help='Target URL') | |
| parser.add_argument('--headless', action='store_true', help='Run in headless mode') | |
| args = parser.parse_args() | |
| profile = generate_random_profile() | |
| print("[PROFILE]") | |
| print(f" User-Agent: {profile.user_agent[:80]}...") | |
| print(f" Timezone: {profile.timezone} (offset: {profile.timezone_offset})") | |
| print(f" Screen: {profile.screen_width}x{profile.screen_height}") | |
| print(f" WebGL: {profile.webgl_renderer[:60]}...") | |
| print(f" Locale: {profile.locale}") | |
| options = ChromiumOptions() | |
| options.set_argument('--no-first-run') | |
| options.set_argument('--no-default-browser-check') | |
| options.set_argument('--disable-dev-shm-usage') | |
| options.set_argument('--disable-infobars') | |
| options.set_argument('--lang=en-US') | |
| options.set_argument('--accept-lang=en-US,en') | |
| options.set_argument('--window-size=1920,1080') | |
| if args.headless: | |
| options.headless() | |
| options.set_argument('--disable-gpu') | |
| options.set_argument('--no-sandbox') | |
| print("[BROWSER] Starting...") | |
| page = ChromiumPage(options) | |
| print("[SPOOF] Applying pre-navigation spoofing...") | |
| spoofer = CDPSpoofer(profile) | |
| spoofer.apply_pre_navigation(page) | |
| print(f"[NAV] Opening {args.url}") | |
| page.get(args.url) | |
| # Keep page open for requested duration | |
| print(f"[WAIT] Holding for {args.duration}s...") | |
| for remaining in range(args.duration, 0, -1): | |
| print(f" {remaining}s remaining", end='\r') | |
| time.sleep(1) | |
| print("\n[WAIT] Done.") | |
| page.quit() | |
| return 0 | |
| if __name__ == '__main__': | |
| raise SystemExit(main()) | |