0

I keep getting the same error no matter what, when Puppeteer launches Chrome:

enter image description here

My code:

//....
let pathToExtension = require('path').join(__dirname, 'ext'); // doesn't help
// pathToExtension = none of these work either: the app directory, the chrome extension directory, the chrome user data directory ...
pathToExtension = `E:/ext`
  browser = await puppeteer.launch({
    headless: false, //true,
    executablePath: executablePath, 
    args: [`--disable-extensions-except=${pathToExtension}'`,
        `--load-extension=${pathToExtension}`,
       // ignoredDefaultArgs: ['--disable-extensions'], 
       // I would expect the above to allow all extensions, but seems to do nothing
      })
//....

I have followed existing solutions here on SO:

Also, my code above is basically one from official docs https://pptr.dev/guides/chrome-extensions/ .

UPDATE: Switching headless: false to true made the error (hopefully not just the message) disappear. However, I still need the extensions to load on headful Chrome. The doc page (above) states that "Extensions in Chrome/Chromium currently only work in non-headless mode and experimental Chrome headless mode.", so I'd expect it to work in headful/non-headless. Not sure abut the "experimental Chrome".

marko-36
  • 1,309
  • 3
  • 23
  • 38
  • I feel like you've probably already checked this, but is your manifest in the root directory of the file your uploading for the extension? – Jridyard Dec 03 '22 at 14:42
  • The extensions are installed via Chrome store, I haven't touched them, except for copying to different locations, as mentioned in the code. Manifest.json is present in the original form. – marko-36 Dec 03 '22 at 16:28

1 Answers1

0
export const extensions = [
  path.join(process.cwd(), 'plugins', 'cookies'),
  path.join(process.cwd(), 'plugins', 'ublock-origin'),
];
Daniel Ehrhardt
  • 908
  • 7
  • 16