Skip to content

Instantly share code, notes, and snippets.

@T1ckbase
Created March 26, 2025 06:31
Show Gist options
  • Save T1ckbase/3b762018076f5068292d6ebdc914e77c to your computer and use it in GitHub Desktop.
Save T1ckbase/3b762018076f5068292d6ebdc914e77c to your computer and use it in GitHub Desktop.
Anti bot detection for playwright
// 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