[Python] Chromium web extension with NoDriver

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I downloaded chromium version 136 and im using it on macOS 64 ARM. I opened it manually and added a chrome web extension and it works. When I close chrome, quit, and open it the extension is always active. But when I run my code with NoDriver from a python script, the chromium tab thats opened does not have the extension and its inside an incognito mode. How can I enable the extension for this way?

    Chromium setup code

    async def worker(emailStr):
    browser = None
    PassProvided = None

    password = None
    if ".com:" in emailStr:
    emailStr, password = emailStr.split(":", 1)
    PassProvided = password

    try:
    # Select a random proxy if enabled
    proxy = None
    if USE_PROXIES and proxies:
    proxy = random.choice(proxies)
    else:
    print(f"{red_text}Not using proxy {reset}")

    # Randomize window size and position for unique fingerprint
    window_width = random.randint(1000, 1500)
    window_height = random.randint(750, 950)
    x_position = random.randint(0, 500)
    y_position = random.randint(0, 500)

    # Build Chrome arguments
    args = [
    f"--window-size={window_width},{window_height}",
    f"--window-position={x_position},{y_position}",
    "--disable-sync",
    "--no-first-run",
    "--no-default-browser-check",
    "--disable-backgrounding-occluded-windows",
    "--disable-renderer-backgrounding",
    "--disable-background-timer-throttling",
    "--disable-breakpad",
    "--disable-extensions",
    "--incognito",
    "--disable-dev-shm-usage",
    ]

    # Inject proxy if used
    if proxy:
    host, port, username, proxyPass = parse_proxy(proxy)
    proxy_creds= [username,proxyPass]
    proxy_url = f"http://{host}:{port}"
    args.append(f"--proxy-server={proxy_url}")

    # Start nodriver browser
    browser = await nd.start(
    browser_executable_path=CHROMIUM_PATH,
    headless=HEADLESS_MODE,
    stealth=True,
    browser_args=args
    )

    # Set up proxy authentication
    main_tab = await browser.get("draft:,")
    await setup_proxy(proxy_creds[0], proxy_creds[1], main_tab)

    # Navigate to Target homepage
    tab = await browser.get("https://www.target.com/")

    # Clear browser storage for clean session
    await tab.evaluate("""
    () => {
    localStorage.clear();
    sessionStorage.clear();
    }
    """)

    Continue reading...

Compartilhe esta Página