From 22bf5fe24b2247a46a063026654c9585cec0fd4f Mon Sep 17 00:00:00 2001 From: miclon Date: Wed, 2 Aug 2023 10:02:37 +0800 Subject: [PATCH 1/2] fix: log function does not exist --- playwright_stealth/js/chrome.csi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playwright_stealth/js/chrome.csi.js b/playwright_stealth/js/chrome.csi.js index 388e39f..b1c8b49 100644 --- a/playwright_stealth/js/chrome.csi.js +++ b/playwright_stealth/js/chrome.csi.js @@ -14,7 +14,7 @@ if (!window.chrome) { if (!('csi' in window.chrome) && (window.performance || window.performance.timing)) { const {csi_timing} = window.performance - log.info('loading chrome.csi.js') + // log.info('loading chrome.csi.js') window.chrome.csi = function () { return { onloadT: csi_timing.domContentLoadedEventEnd, From c4f511292d12097549fb36a40a66289c195ed4b0 Mon Sep 17 00:00:00 2001 From: miclon Date: Wed, 2 Aug 2023 10:03:25 +0800 Subject: [PATCH 2/2] fix: webdriver fake --- playwright_stealth/js/navigator.webdriver.js | 13 +++++++++++++ playwright_stealth/stealth.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 playwright_stealth/js/navigator.webdriver.js diff --git a/playwright_stealth/js/navigator.webdriver.js b/playwright_stealth/js/navigator.webdriver.js new file mode 100644 index 0000000..52a2f47 --- /dev/null +++ b/playwright_stealth/js/navigator.webdriver.js @@ -0,0 +1,13 @@ +Object.defineProperty(Object.getPrototypeOf(navigator), 'webdriver', { + set: undefined, + enumerable: true, + configurable: true, + get: new Proxy( + Object.getOwnPropertyDescriptor(Object.getPrototypeOf(navigator), 'webdriver').get, + { apply: (target, thisArg, args) => { + // emulate getter call validation + Reflect.apply(target, thisArg, args); + return false; + }} + ) +}); \ No newline at end of file diff --git a/playwright_stealth/stealth.py b/playwright_stealth/stealth.py index 37a4b18..721e6f4 100644 --- a/playwright_stealth/stealth.py +++ b/playwright_stealth/stealth.py @@ -31,7 +31,7 @@ def from_file(name): 'navigator_hardware_concurrency': from_file('navigator.hardwareConcurrency.js'), 'outerdimensions': from_file('window.outerdimensions.js'), 'utils': from_file('utils.js'), - 'webdriver': 'delete Object.getPrototypeOf(navigator).webdriver', + 'webdriver': from_file('navigator.webdriver.js'), 'webgl_vendor': from_file('webgl.vendor.js'), }