|
44 | 44 | DISABLE_CSP_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "disable_csp.zip")
|
45 | 45 | AD_BLOCK_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "ad_block.zip")
|
46 | 46 | RECORDER_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "recorder.zip")
|
| 47 | +SBASE_EXT_ZIP_PATH = os.path.join(EXTENSIONS_DIR, "sbase_ext.zip") |
47 | 48 | DOWNLOADS_FOLDER = download_helper.get_downloads_folder()
|
48 | 49 | PROXY_ZIP_PATH = proxy_helper.PROXY_ZIP_PATH
|
49 | 50 | PROXY_ZIP_LOCK = proxy_helper.PROXY_ZIP_LOCK
|
@@ -601,9 +602,19 @@ def _set_chrome_options(
|
601 | 602 | # Only change it if not "normal", which is the default.
|
602 | 603 | chrome_options.page_load_strategy = settings.PAGE_LOAD_STRATEGY.lower()
|
603 | 604 | 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 |
605 | 610 | 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 |
607 | 618 | if (settings.DISABLE_CSP_ON_CHROME or disable_csp) and not headless:
|
608 | 619 | # Headless Chrome does not support extensions, which are required
|
609 | 620 | # for disabling the Content Security Policy on Chrome.
|
@@ -633,6 +644,11 @@ def _set_chrome_options(
|
633 | 644 | chrome_options = add_chrome_ext_dir(chrome_options, recorder_dir)
|
634 | 645 | else:
|
635 | 646 | 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) |
636 | 652 | if proxy_string:
|
637 | 653 | if proxy_auth:
|
638 | 654 | zip_it = True
|
@@ -2149,8 +2165,23 @@ def get_local_driver(
|
2149 | 2165 | edge_options.add_argument("--headless=chrome")
|
2150 | 2166 | except Exception:
|
2151 | 2167 | 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 |
2152 | 2182 | elif headless:
|
2153 |
| - edge_options.add_argument("--headless") |
| 2183 | + if "--headless" not in edge_options.arguments: |
| 2184 | + edge_options.add_argument("--headless") |
2154 | 2185 | if mobile_emulator:
|
2155 | 2186 | emulator_settings = {}
|
2156 | 2187 | device_metrics = {}
|
@@ -2617,6 +2648,22 @@ def get_local_driver(
|
2617 | 2648 | chrome_options.add_argument("--headless=chrome")
|
2618 | 2649 | except Exception:
|
2619 | 2650 | 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") |
2620 | 2667 | disable_build_check = False
|
2621 | 2668 | uc_driver_version = None
|
2622 | 2669 | if is_using_uc(undetectable, browser_name):
|
|
0 commit comments