from DrissionPage import ChromiumPage, ChromiumOptions


def open_browser():
    options = ChromiumOptions()
    options.set_local_port(28888)
    options.set_argument(arg='--disable-notifications', value=True)
    options.set_argument(arg='--disable-extensions', value=False)
    options.set_argument(arg='--disable-background-networking', value=True)
    options.set_argument(arg='--disable-gpu', value=True)
    options.set_argument(arg='--dns-prefetch-disable', value=True)
    options.set_argument(arg='--disable-infobars', value=True)
    options.set_argument(arg='--disable-dev-shm-usage', value=True)
    options.set_argument(arg='--enable-automation', value=False)
    options.set_argument(arg='--log-level', value='3')
    options.set_argument(arg='--start-maximized', value=True)
    options.set_argument(arg='--ignore-ssl-errors', value=True)
    options.set_argument(arg='--no-sandbox')
    options.headless(False)
    options.incognito(False)
    driver = ChromiumPage(addr_or_opts=options)
    driver.set.window.max()
    return driver

def attach_browser():
    return ChromiumPage(addr_or_opts=28888)

def quit_browser(driver):
    driver.quit()