Change intercept js / inject cookies in webview#26
Conversation
| " const nativeToString = Function.prototype.toString;\n" | ||
| " const nativeCallToString = Function.prototype.call.bind(nativeToString);\n" | ||
| " const wrappedFns = new WeakMap();\n" | ||
| " \n" | ||
| " Function.prototype.toString = function() {\n" | ||
| " if (wrappedFns.has(this)) {\n" | ||
| " return wrappedFns.get(this);\n" | ||
| " }\n" | ||
| " return nativeCallToString(this);\n" | ||
| " };\n" | ||
| " wrappedFns.set(Function.prototype.toString, 'function toString() { [native code] }');\n" |
There was a problem hiding this comment.
Hahaha, missed seeing this. Overriding the toString, good old times. Fun fact though function toString() { [native code] } is only for chromium based browsers, firefox and safari actually has function () {\n [native code]\n}. But I guess it's not an issue even though we are on WKWebView - so Safari - because they don't yet have that much data from users using WebView
Not really sure if it's worth for you changing it to the one with newlines, but again, you did say adding all of this code made stuff work for Delta when they use akamai, so I guess normal users would probably be detected more 😂 classic antibot behavior
| " const automationProps = ['__webdriver_script_fn', '__driver_evaluate', '__webdriver_evaluate',\n" | ||
| " '__selenium_evaluate', '__fxdriver_evaluate', '__driver_unwrapped', '__webdriver_unwrapped',\n" | ||
| " '__selenium_unwrapped', '__fxdriver_unwrapped', '_Selenium_IDE_Recorder', '_selenium',\n" | ||
| " 'calledSelenium', '_WEBDRIVER_ELEM_CACHE', 'ChromeDriverw', 'driver-hierarchical',\n" | ||
| " '__nightmare', '__phantomas', '_phantom', 'phantom', 'callPhantom'];\n" | ||
| " automationProps.forEach(p => { try { Object.defineProperty(window, p, { get: () => undefined, configurable: true }); } catch(e) {} });\n" |
There was a problem hiding this comment.
Actually interesting, any of these are present in WKWebView? Didn't know
| " const OriginalError = Error;\n" | ||
| " Error = function(...args) {\n" | ||
| " const err = new OriginalError(...args);\n" | ||
| " if (err.stack) err.stack = err.stack.replace(/\\n.*interceptedRequestHandler.*/g, '');\n" |
There was a problem hiding this comment.
I knew DD and PX are pretty annoying with CDP error stacks, good catch :P
adds stealthiness to the intercepting js script which bypassed akamai's 400 responses for delta airlines