Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppeteer Delete Navigator.Webdriver

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.

like image 886
Ali Haydar Güleç Avatar asked Dec 26 '18 16:12

Ali Haydar Güleç


2 Answers

Try this:

const newProto = navigator.__proto__;
delete newProto.webdriver;
navigator.__proto__ = newProto;
like image 160
Nodarius Avatar answered Oct 23 '22 14:10

Nodarius


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.

like image 43
Rui Costa Avatar answered Oct 23 '22 15:10

Rui Costa