bard-rs 1.2.7

Google Gemini CLI (Bard)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

"""
2024-02-25

__Secure-1PSID

"""


def add_cookie(driver, name, value):
    """
    Function to add or overwrite a cookie
    """
    cookie = {"name": name, "value": value}
    driver.add_cookie(cookie)


try:
    # Initialize the Chrome WebDriver
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

    # Navigate to the URL
    driver.get("https://gemini.google.com/")

    # Use an infinite loop to continuously accept cookie inputs
    while True:
        # Wait for the user to input cookie name and value
        cookie_input = input(
            "Enter cookie in format COOKIE_NAME=cookie_value or CTRL+C to exit: "
        )

        if "=" in cookie_input:
            name, value = cookie_input.split("=", 1)  # Split input into name and value
            add_cookie(driver, name.strip(), value.strip())
            print(f"Cookie added: {name} = {value}")
            driver.refresh()  # Refresh the browser to apply the cookie
        else:
            print("Invalid format. Please use the format COOKIE_NAME=cookie_value.")

except KeyboardInterrupt:
    print("\nExiting and closing the browser.")
    driver.quit()  # Close the browser on exit