Chrome:'manifest file is missing or unreadable' when launched by Puppeteer

isr3a4wc  于 2023-09-28  发布在  Go
关注(0)|答案(1)|浏览(147)

无论如何,当Puppeteer启动Chrome时,我总是得到相同的错误:

我的代码:

//....
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
      })
//....

我在SO上遵循了现有的解决方案:

  • 扩展必须解包:

Failed to load extension and manifest file is missing or unreadable while trying to test Chrome extensions with Playwright

  • --disable-extensions-except--load-extension都需要设置:

puppeteer unable to load chrome extension in browser
另外,我上面的代码基本上是来自官方文档https://pptr.dev/guides/chrome-extensions/的代码。
更新:将headless: false切换到true使错误(希望不仅仅是消息)消失了。然而,我仍然需要扩展程序来加载到令人眼花缭乱的Chrome上。文档页面(上面)指出“* Chrome/Chromium中的扩展程序目前只能在非无头模式和实验性Chrome无头模式下工作。*”,所以我希望它能在有头/非无头模式下工作。不确定是不是“实验性的Chrome”。

kyvafyod

kyvafyod1#

export const extensions = [
  path.join(process.cwd(), 'plugins', 'cookies'),
  path.join(process.cwd(), 'plugins', 'ublock-origin'),
];

相关问题