Merge pull request #2 from TJM4/master

Fixed bug where webdriver property could be detected
This commit is contained in:
Leon 2020-01-26 16:06:23 +01:00 committed by GitHub
commit bf360b9808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -46,10 +46,18 @@ class Chrome:
"Page.addScriptToEvaluateOnNewDocument", "Page.addScriptToEvaluateOnNewDocument",
{ {
"source": """ "source": """
Object.defineProperty(navigator, 'webdriver', { Object.defineProperty(window, 'navigator', {
get: () => undefined 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]
}) })
""" })
"""
}, },
) )
original_user_agent_string = instance.execute_script( original_user_agent_string = instance.execute_script(