I've a puppeteer script which works as expected when it's headless:false
mode with Google Chrome profile and executablePath
because I need to keep all sessions and browser data every time when I use the script, it also has chrome extension which works on the script browser profile.
But when I only make change to headless:true
mode, same script doesn't work as before, it doesn't remember all browser data(sessions), and doesn't recognize my browser extension.
Here is the script code,
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth')
puppeteer.use(StealthPlugin())
const browser = await puppeteer.launch({
headless: true,
ignoreHTTPSErrors: true,
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
args: [
'--user-data-dir=/Users/x/Library/Application Support/Google/Chrome/Profile 2',
'--window-size=1920,1080',
"--no-sandbox",
//"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-gpu",
"--disable-extensions",
"--disable-dev-tools",
"--disable-infobars",
"--ignore-certificate-errors",
"--enable-logging",
"--v=1",
'--disable-setuid-sandbox',
'--disable-infobars',
'--window-position=0,0',
'--ignore-certifcate-errors',
'--ignore-certifcate-errors-spki-list',
'--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'
]
});
const page = await browser.newPage();
Is there anyway that I can keep using my script with no problem on headless:true
mode or should I run the script like browser open all the time on a VDS machine :/
Thanks.
Information