const page = await browser.newPage();
await page.evaluateOnNewDocument(() => {
const newProto = navigator.__proto__;
//delete newProto.webdriver;
newProto.webdriver = false
navigator.__proto__ = newProto;
});
evaluateOnNewDocument解释如下,在页面脚本加载完但未执行前的状态。
https://pptr.dev/#?product=Puppeteer&version=v13.2.0&show=api-pageevaluateonnewdocumentpagefunction-args