sonarcloud fixes
This commit is contained in:
parent
b5ef699f4f
commit
e5935faa13
4 changed files with 2 additions and 20 deletions
15
util.js
15
util.js
|
|
@ -27,21 +27,6 @@ export const handleSIGINT = (context = null) => process.on('SIGINT', async () =>
|
|||
if (context) await context.close(); // in order to save recordings also on SIGINT, we need to disable Playwright's handleSIGINT and close the context ourselves
|
||||
});
|
||||
|
||||
// stealth with playwright: https://github.com/berstend/puppeteer-extra/issues/454#issuecomment-917437212
|
||||
// gets userAgent and then removes "Headless" from it
|
||||
const newStealthContext = async (browser, contextOptions = {}, debug = false) => {
|
||||
if (!debug) { // only need to fix userAgent in headless mode
|
||||
const dummyContext = await browser.newContext();
|
||||
const originalUserAgent = await (await dummyContext.newPage()).evaluate(() => navigator.userAgent);
|
||||
await dummyContext.close();
|
||||
// console.log('originalUserAgent:', originalUserAgent); // Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/96.0.4664.110 Safari/537.36
|
||||
contextOptions = {
|
||||
...contextOptions,
|
||||
userAgent: originalUserAgent.replace("Headless", ""), // HeadlessChrome -> Chrome, TODO needed?
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const stealth = async (context) => {
|
||||
// stealth with playwright: https://github.com/berstend/puppeteer-extra/issues/454#issuecomment-917437212
|
||||
// https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra-plugin-stealth/evasions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue