From 9826c131262f413905c2630122cdf84951ceb39b Mon Sep 17 00:00:00 2001 From: Artem <106631540+rzc0d3r@users.noreply.github.com> Date: Thu, 4 Jan 2024 02:24:12 +0200 Subject: [PATCH] Added command line argument --no-headless --- main.py | 6 +++--- modules/shared_tools.py | 8 +++++--- wiki/CommandLineArguments.md | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 557716bc0..9637cd826 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ ██╔══╝ ╚════██║██╔══╝ ██║ ██╔═██╗ ██╔══╝ ╚██╔╝ ██║ ██║██╔══╝ ██║╚██╗██║ ███████╗███████║███████╗ ██║ ██║ ██╗███████╗ ██║ ╚██████╔╝███████╗██║ ╚████║ ╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ - Project Version: v1.2.0.0 + Project Version: v1.2.0.1 Project Devs: rzc0d3r, AdityaGarg8, k0re, Fasjeit, alejanpa17 """ @@ -80,12 +80,12 @@ def chrome_driver_installer_menu(): # auto updating or installing chrome driver sys.argv.append('--force') driver = None if '--firefox' in sys.argv: - driver = shared_tools.initSeleniumWebDriver('firefox') + driver = shared_tools.initSeleniumWebDriver('firefox', headless=('--no-headless' not in sys.argv)) else: chromedriver_path = chrome_driver_installer_menu() if chromedriver_path is not None: os.chmod(chromedriver_path, 0o777) - driver = shared_tools.initSeleniumWebDriver('chrome', chromedriver_path) + driver = shared_tools.initSeleniumWebDriver('chrome', chromedriver_path, headless=('--no-headless' not in sys.argv)) only_account = False if '--account' in sys.argv: logger.console_log('\n-- Account Generator --\n') diff --git a/modules/shared_tools.py b/modules/shared_tools.py index a1e7007be..c4aa96897 100644 --- a/modules/shared_tools.py +++ b/modules/shared_tools.py @@ -62,7 +62,7 @@ def untilConditionExecute(chrome_driver_obj: Chrome, js: str, delay=DEFAULT_DELA def createPassword(length): return ''.join(['Xx0$']+[random.choice(string.ascii_letters) for _ in range(length)]) -def initSeleniumWebDriver(browser_name: str, webdriver_path = None): +def initSeleniumWebDriver(browser_name: str, webdriver_path = None, headless=True): driver_options = None driver = None if browser_name.lower() == 'chrome': @@ -70,7 +70,8 @@ def initSeleniumWebDriver(browser_name: str, webdriver_path = None): driver_options.add_experimental_option('excludeSwitches', ['enable-logging']) driver_options.add_argument("--log-level=3") driver_options.add_argument("--lang=en-US") - driver_options.add_argument('--headless') + if headless: + driver_options.add_argument('--headless') driver_service = ChromeService(executable_path=webdriver_path) if os.name == 'posix': # For Linux if sys.platform.startswith('linux'): @@ -86,7 +87,8 @@ def initSeleniumWebDriver(browser_name: str, webdriver_path = None): driver_options = FirefoxOptions() driver_service = FirefoxService(executable_path=webdriver_path) driver_options.set_preference('intl.accept_languages', 'en-US') - driver_options.add_argument('--headless') + if headless: + driver_options.add_argument('--headless') if os.name == 'posix': # For Linux if sys.platform.startswith('linux'): console_log('Initializing firefox-driver for Linux', INFO) diff --git a/wiki/CommandLineArguments.md b/wiki/CommandLineArguments.md index dbe839587..e2378d5f3 100644 --- a/wiki/CommandLineArguments.md +++ b/wiki/CommandLineArguments.md @@ -6,3 +6,4 @@ | --force | disabled | Disables all user input, but waiting for the Enter key to be pressed before exiting the program remains | | --cli | disabled | Disables all user input (GitHub CI Requirements) | | --firefox | disabled | Launching the project via firefox browser (Runs through the chrome browser by default) | +| --no-headless | disabled | Shows the browser at runtime (by default hides the browser at runtime) | \ No newline at end of file