Skip to content

Commit 9747310

Browse files
committed
Update UC Mode
1 parent 70b05ff commit 9747310

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,19 @@ def find_edgedriver_version_to_use(use_version, driver_version):
340340
return use_version
341341

342342

343-
def has_cf(text):
343+
def has_captcha(text):
344344
if (
345345
"<title>403 Forbidden</title>" in text
346346
or "Permission Denied</title>" in text
347347
or 'id="challenge-error-text"' in text
348348
or "<title>Just a moment..." in text
349349
or 'action="/?__cf_chl_f_tk' in text
350+
or 'id="challenge-widget-' in text
350351
or 'src="chromedriver.js"' in text
351352
or 'class="g-recaptcha"' in text
352353
or 'content="Pixelscan"' in text
353354
or 'id="challenge-form"' in text
355+
or "/challenge-platform" in text
354356
or "window._cf_chl_opt" in text
355357
or "/recaptcha/api.js" in text
356358
or "/turnstile/" in text
@@ -377,7 +379,7 @@ def uc_special_open_if_cf(
377379
status_str.startswith("3")
378380
or status_str.startswith("4")
379381
or status_str.startswith("5")
380-
or has_cf(req_get.text)
382+
or has_captcha(req_get.text)
381383
):
382384
special = True
383385
if status_str == "403" or status_str == "429":
@@ -763,6 +765,8 @@ def _on_a_cf_turnstile_page(driver):
763765
source = driver.get_page_source()
764766
if (
765767
'data-callback="onCaptchaSuccess"' in source
768+
or "/challenge-platform/scripts/" in source
769+
or 'id="challenge-widget-' in source
766770
or "cf-turnstile-" in source
767771
):
768772
return True
@@ -866,6 +870,13 @@ def _uc_gui_click_captcha(
866870
and driver.is_element_present("div.spacer div")
867871
):
868872
frame = "div.spacer div"
873+
elif (
874+
driver.is_element_present('script[src*="challenges.c"]')
875+
and driver.is_element_present(
876+
'[data-testid*="challenge-"] div'
877+
)
878+
):
879+
frame = '[data-testid*="challenge-"] div'
869880
elif (
870881
(
871882
driver.is_element_present('[name*="cf-turnstile-"]')
@@ -883,6 +894,14 @@ def _uc_gui_click_captcha(
883894
)
884895
):
885896
frame = "%s .cf-turnstile-wrapper" % frame
897+
elif (
898+
frame != "iframe"
899+
and driver.is_element_present(
900+
'%s [name*="cf-turnstile"]' % frame
901+
)
902+
and driver.is_element_present("%s div" % frame)
903+
):
904+
frame = "%s div" % frame
886905
elif driver.is_element_present(".cf-turnstile-wrapper"):
887906
frame = ".cf-turnstile-wrapper"
888907
elif driver.is_element_present(
@@ -1102,6 +1121,13 @@ def _uc_gui_handle_captcha(
11021121
and driver.is_element_present("div.spacer div")
11031122
):
11041123
frame = "div.spacer div"
1124+
elif (
1125+
driver.is_element_present('script[src*="challenges.c"]')
1126+
and driver.is_element_present(
1127+
'[data-testid*="challenge-"] div'
1128+
)
1129+
):
1130+
frame = '[data-testid*="challenge-"] div'
11051131
elif (
11061132
(
11071133
driver.is_element_present('[name*="cf-turnstile-"]')

0 commit comments

Comments
 (0)