Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add parameter driver_executable_is_patched #1687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add parameter driver_executable_is_patched
  • Loading branch information
milahu committed Dec 3, 2023
commit 2c07c9f515c0ba5b360127a6f0970189fed5e1ac
2 changes: 2 additions & 0 deletions undetected_chromedriver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def __init__(
options=None,
user_data_dir=None,
driver_executable_path=None,
driver_executable_is_patched=False,
browser_executable_path=None,
port=0,
enable_cdp_events=False,
Expand Down Expand Up @@ -250,6 +251,7 @@ def __init__(
self.debug = debug
self.patcher = Patcher(
executable_path=driver_executable_path,
executable_is_patched=driver_executable_is_patched,
force=patcher_force_close,
version_main=version_main,
user_multi_procs=user_multi_procs,
Expand Down
13 changes: 11 additions & 2 deletions undetected_chromedriver/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Patcher(object):
def __init__(
self,
executable_path=None,
executable_is_patched=False,
force=False,
version_main: int = 0,
user_multi_procs=False,
Expand All @@ -52,6 +53,8 @@ def __init__(
Args:
executable_path: None = automatic
a full file path to the chromedriver executable
executable_is_patched: False
executable_path is an already patched chromedriver executable
force: False
terminate processes which are holding lock
version_main: 0 = auto
Expand Down Expand Up @@ -86,10 +89,12 @@ def __init__(
self.executable_path = os.path.abspath(
os.path.join(".", self.executable_path)
)
self.executable_is_patched = False

if executable_path:
self._custom_exe_path = True
self.executable_path = executable_path
self.executable_is_patched = executable_is_patched

# Set the correct repository to download the Chromedriver from
if self.is_old_chromedriver:
Expand Down Expand Up @@ -118,11 +123,12 @@ def _set_platform_name(self):
self.platform_name = "mac-x64"
self.exe_name %= ""

def auto(self, executable_path=None, force=False, version_main=None, _=None):
def auto(self, executable_path=None, executable_is_patched=None, force=False, version_main=None, _=None):
"""

Args:
executable_path:
executable_is_patched:
force:
version_main:

Expand All @@ -144,8 +150,11 @@ def auto(self, executable_path=None, force=False, version_main=None, _=None):
self.executable_path = executable_path
self._custom_exe_path = True

if executable_is_patched == None:
executable_is_patched = self.executable_is_patched

if self._custom_exe_path:
ispatched = self.is_binary_patched(self.executable_path)
ispatched = executable_is_patched or self.is_binary_patched(self.executable_path)
if not ispatched:
return self.patch_exe()
else:
Expand Down