Skip to content

Commit 85123d3

Browse files
committed
Update Chromium settings
1 parent 5be3bc6 commit 85123d3

File tree

1 file changed

+50
-3
lines changed

1 file changed

+50
-3
lines changed

seleniumbase/core/browser_launcher.py

100755100644
Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
DISABLE_CSP_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "disable_csp.zip")
4545
AD_BLOCK_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "ad_block.zip")
4646
RECORDER_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "recorder.zip")
47+
SBASE_EXT_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "sbase_ext.zip")
4748
DOWNLOADS_FOLDER = download_helper.get_downloads_folder()
4849
PROXY_ZIP_PATH = proxy_helper.PROXY_ZIP_PATH
4950
PROXY_ZIP_LOCK = proxy_helper.PROXY_ZIP_LOCK
@@ -601,9 +602,19 @@ def _set_chrome_options(
601602
# Only change it if not "normal", which is the default.
602603
chrome_options.page_load_strategy = settings.PAGE_LOAD_STRATEGY.lower()
603604
if headless2:
604-
pass # Processed After Version Check
605+
if servername and servername != "localhost":
606+
# The Grid Node will need Chrome 109 or newer
607+
chrome_options.add_argument("--headless=new")
608+
else:
609+
pass # Processed After Version Check
605610
elif headless:
606-
chrome_options.add_argument("--headless")
611+
if not undetectable:
612+
chrome_options.add_argument("--headless")
613+
if undetectable and servername and servername != "localhost":
614+
# The Grid Node will need Chrome 109 or newer
615+
chrome_options.add_argument("--headless=new")
616+
else:
617+
pass # Processed After Version Check
607618
if (settings.DISABLE_CSP_ON_CHROME or disable_csp) and not headless:
608619
# Headless Chrome does not support extensions, which are required
609620
# for disabling the Content Security Policy on Chrome.
@@ -633,6 +644,11 @@ def _set_chrome_options(
633644
chrome_options = add_chrome_ext_dir(chrome_options, recorder_dir)
634645
else:
635646
chrome_options = _add_chrome_recorder_extension(chrome_options)
647+
if is_using_uc(undetectable, browser_name):
648+
sbase_ext_zip = SBASE_EXT_ZIP_PATH
649+
sbase_ext_dir = os.path.join(DOWNLOADS_FOLDER, "sbase_ext")
650+
_unzip_to_new_folder(sbase_ext_zip, sbase_ext_dir)
651+
chrome_options = add_chrome_ext_dir(chrome_options, sbase_ext_dir)
636652
if proxy_string:
637653
if proxy_auth:
638654
zip_it = True
@@ -2149,8 +2165,23 @@ def get_local_driver(
21492165
edge_options.add_argument("--headless=chrome")
21502166
except Exception:
21512167
edge_options.add_argument("--headless=new")
2168+
elif headless and undetectable:
2169+
# (For later: UC Mode doesn't support Edge now)
2170+
try:
2171+
if int(use_version) >= 109:
2172+
edge_options.add_argument("--headless=new")
2173+
elif (
2174+
int(use_version) >= 96
2175+
and int(use_version) <= 108
2176+
):
2177+
edge_options.add_argument("--headless=chrome")
2178+
else:
2179+
pass # Will need Xvfb on Linux
2180+
except Exception:
2181+
pass
21522182
elif headless:
2153-
edge_options.add_argument("--headless")
2183+
if "--headless" not in edge_options.arguments:
2184+
edge_options.add_argument("--headless")
21542185
if mobile_emulator:
21552186
emulator_settings = {}
21562187
device_metrics = {}
@@ -2617,6 +2648,22 @@ def get_local_driver(
26172648
chrome_options.add_argument("--headless=chrome")
26182649
except Exception:
26192650
chrome_options.add_argument("--headless=new")
2651+
elif headless and undetectable:
2652+
try:
2653+
if int(use_version) >= 109:
2654+
chrome_options.add_argument("--headless=new")
2655+
elif (
2656+
int(use_version) >= 96
2657+
and int(use_version) <= 108
2658+
):
2659+
chrome_options.add_argument("--headless=chrome")
2660+
else:
2661+
pass # Will need Xvfb on Linux
2662+
except Exception:
2663+
pass
2664+
elif headless:
2665+
if "--headless" not in chrome_options.arguments:
2666+
chrome_options.add_argument("--headless")
26202667
disable_build_check = False
26212668
uc_driver_version = None
26222669
if is_using_uc(undetectable, browser_name):

0 commit comments

Comments
 (0)