stealth was not working due to removed new before require?

HEAD was showing hcaptcha while commit 64d0ba8ce7 claimed successfully without one.
Only relevant diff seems to be the removed `new` about which ts-check complained and which is also missing in
the example in https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth/evasions.
This commit is contained in:
Ralf Vogler 2021-12-28 21:32:58 +01:00
parent 81b04f6f2f
commit 96432884b3

View file

@ -42,7 +42,7 @@ const newStealthContext = async (browser, contextOptions = {}) => {
'webgl.vendor',
'window.outerdimensions'
];
const evasions = enabledEvasions.map(e => require(`puppeteer-extra-plugin-stealth/evasions/${e}`));
const evasions = enabledEvasions.map(e => new require(`puppeteer-extra-plugin-stealth/evasions/${e}`));
const stealth = {
callbacks: [],
async evaluateOnNewDocument(...args) {
@ -60,6 +60,7 @@ const newStealthContext = async (browser, contextOptions = {}) => {
(async () => {
const browser = await chromium.launch({
channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
headless: false,
});
/** @type {import('playwright').BrowserContext} */
const context = await newStealthContext(browser, {