mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-12 10:31:50 +01:00
make private window mode configurable
This commit is contained in:
@@ -240,6 +240,7 @@ browser:
|
||||
# --start-maximized
|
||||
binary_location: # path to custom browser executable, if not specified will be looked up on PATH
|
||||
extensions: [] # a list of .crx extension files to be loaded
|
||||
use_private_window: true
|
||||
user_data_dir: "" # see https://github.com/chromium/chromium/blob/main/docs/user_data_dir.md
|
||||
profile_name: ""
|
||||
|
||||
|
||||
@@ -273,6 +273,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
||||
self.browser_config.arguments = self.config["browser"]["arguments"]
|
||||
self.browser_config.binary_location = self.config["browser"]["binary_location"]
|
||||
self.browser_config.extensions = [abspath(item, relative_to = self.config_file_path) for item in self.config["browser"]["extensions"]]
|
||||
self.browser_config.use_private_window = self.config["browser"]["use_private_window"]
|
||||
self.browser_config.user_data_dir = abspath(self.config["browser"]["user_data_dir"], relative_to = self.config_file_path)
|
||||
self.browser_config.profile_name = self.config["browser"]["profile_name"]
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ browser:
|
||||
# --start-maximized
|
||||
binary_location: # path to custom browser executable, if not specified will be looked up on PATH
|
||||
extensions: [] # a list of .crx extension files to be loaded
|
||||
use_private_window: true
|
||||
user_data_dir: "" # see https://github.com/chromium/chromium/blob/main/docs/user_data_dir.md
|
||||
profile_name: ""
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class BrowserConfig:
|
||||
self.arguments:Iterable[str] = []
|
||||
self.binary_location:str = None
|
||||
self.extensions:Iterable[str] = []
|
||||
self.use_private_window:bool = True
|
||||
self.user_data_dir:str = ""
|
||||
self.profile_name:str = ""
|
||||
|
||||
@@ -50,10 +51,11 @@ class SeleniumMixin:
|
||||
LOG.info("Creating WebDriver session...")
|
||||
|
||||
def init_browser_options(browser_options:ChromiumOptions):
|
||||
if isinstance(browser_options, webdriver.EdgeOptions):
|
||||
browser_options.add_argument("-inprivate")
|
||||
else:
|
||||
browser_options.add_argument("--incognito")
|
||||
if self.browser_config.use_private_window:
|
||||
if isinstance(browser_options, webdriver.EdgeOptions):
|
||||
browser_options.add_argument("-inprivate")
|
||||
else:
|
||||
browser_options.add_argument("--incognito")
|
||||
|
||||
if self.browser_config.user_data_dir:
|
||||
LOG.info(" -> Browser User Data Dir: %s", self.browser_config.user_data_dir)
|
||||
|
||||
Reference in New Issue
Block a user