Revert "working patch"

This reverts commit c0ee188636.
This commit is contained in:
ultrafunkamsterdam 2020-09-19 18:15:41 +02:00
parent c0ee188636
commit 17e1f0e584
2 changed files with 21 additions and 33 deletions

View File

@ -16,7 +16,7 @@ from setuptools import setup
setup(
name="undetected-chromedriver",
version="1.4.1",
version="1.4.0",
packages=["undetected_chromedriver"],
install_requires=["selenium",],
url="https://github.com/ultrafunkamsterdam/undetected_chromedriver",

View File

@ -49,37 +49,26 @@ class Chrome:
kwargs["options"] = ChromeOptions()
instance = object.__new__(_Chrome)
instance.__init__(*args, **kwargs)
instance._orig_get = instance.get
def _get_wrapped(*args, **kwargs):
if instance.execute_script("return navigator.webdriver"):
instance.execute_cdp_cmd(
"Page.addScriptToEvaluateOnNewDocument",
{"source": """
Object.defineProperty(window, 'navigator', {
value: new Proxy(navigator, {
has: (target, key) => (key === 'webdriver' ? false : key in target),
get: (target, key) =>
key === 'webdriver'
? undefined
: typeof target[key] === 'function'
? target[key].bind(target)
: target[key]
})
});
(function () {
}) ();
""" + ("console.log = console.dir = console.error = function(){};" if not enable_console_log else '' ) }
)
return instance._orig_get(*args, **kwargs)
instance.get = _get_wrapped
instance.execute_cdp_cmd(
"Page.addScriptToEvaluateOnNewDocument",
{
"source": """
Object.defineProperty(window, 'navigator', {
value: new Proxy(navigator, {
has: (target, key) => (key === 'webdriver' ? false : key in target),
get: (target, key) =>
key === 'webdriver'
? undefined
: typeof target[key] === 'function'
? target[key].bind(target)
: target[key]
})
});
"""
+ "console.dir = console.log = function(){};"
if not enable_console_log else ''
},
)
original_user_agent_string = instance.execute_script(
"return navigator.userAgent"
)
@ -103,7 +92,6 @@ class ChromeOptions:
instance.add_argument("start-maximized")
instance.add_experimental_option("excludeSwitches", ["enable-automation"])
instance.add_experimental_option("useAutomationExtension", False)
instance.add_argument("--disable-blink-features=AutomationControlled");
logger.info(f"starting undetected_chromedriver.ChromeOptions({args}, {kwargs})")
return instance