6

I m using puppeteer for scraping. I can pass navigator.webdriver property= false but i need to delete that prop completely.

https://bot.sannysoft.com/

I tried with passing false to navigator.webdriver. This trick can pass on https://intoli.com/blog/not-possible-to-block-chrome-headless/chrome-headless-test.html

but in https://bot.sannysoft.com/ cant.

here is webpage testing bot. This test is looking for are there any "webdriver" prop in navigator object. Doesn't care if its true or false. I need to remove this webdriver prop from browser.

4 Answers4

10

Try this:

const newProto = navigator.__proto__;
delete newProto.webdriver;
navigator.__proto__ = newProto;
Nodarius
  • 366
  • 4
  • 15
1

Since I can't comment, I'll leave an answer:

I had the same question, and @Nodarius's answer worked for me. Since you didn't accept it, I assume your problem is still persisting.

This is probably because, even if you run in, you need that code to run before the page loads (or before the website accesses the variable).

I achieved this using a proxy (https://mitmproxy.org/) which loads the script before the page loads.

Hope it helps.

Rui Costa
  • 55
  • 1
  • 2
  • 9
0

This works

await page.evaluateOnNewDocument(() => {
  window.navigator = {}
})
0
await page.evaluateOnNewDocument(() => {
    Object.defineProperty(navigator, "webdriver", {
      get: () => false,
    });
});