Created
March 26, 2025 06:31
-
-
Save T1ckbase/3b762018076f5068292d6ebdc914e77c to your computer and use it in GitHub Desktop.
Anti bot detection for playwright
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://bot.sannysoft.com | |
// https://www.browserscan.net/bot-detection | |
// https://fingerprintjs.github.io/BotD/main/ | |
// Webdriver | |
const defaultGetter = Object.getOwnPropertyDescriptor(Navigator.prototype, 'webdriver').get; | |
// defaultGetter.apply(navigator); // true | |
// defaultGetter.toString(); // 'function get webdriver() { [native code] }' | |
Object.defineProperty(Navigator.prototype, 'webdriver', { | |
set: undefined, | |
enumerable: true, | |
configurable: true, | |
get: new Proxy(defaultGetter, { apply: (target, thisArg, args) => { | |
// emulate getter call validation | |
Reflect.apply(target, thisArg, args); | |
return false; | |
}}) | |
}); | |
// const patchedGetter = Object.getOwnPropertyDescriptor(Navigator.prototype, 'webdriver').get; | |
// patchedGetter.apply(navigator); // false | |
// patchedGetter.toString(); // 'function () { [native code] }' | |
// CDP | |
console.debug = () => {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment