Search code examples
node.jsgoogle-chromegoogle-chrome-extensionpuppeteerchromium

How can I enable Chromium Extensions?


I am trying to open Chromium with extensions, but I cannot figure out how to do this. When chromium opens there are no extensions installed.

I tried to open with '--enable-remote-extensions', --load-extension=`, I tried to drag and drop the .crx into chromium extensions panel, but nothing worked.

I've got "An error has occurred Installation is not enabled" and "Package is invalid: 'CRX_REQUIRED_PROOF_MISSING'

Could you help me with a working example ? Thanks!


Solution

  • After lots of trial and error, I've solved this issue.

    Below is the working code and I hope it will help someone else.

    const puppeteer = require('puppeteer');
    const extentionPath = "C:\\Users\\<YOUR_USERNAME>\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1\\Extensions\\<LONG_STRING_EXTENTION_ID>\\<EXTENTION_VERSION>"
    
    
    (async () => {
        const customArgs = [
            `--start-maximized`,
            `--load-extension=${extentionPath}`
        ];
        const browser = await puppeteer.launch({
            defaultViewport: null,
            headless: false,
            ignoreDefaultArgs: ["--disable-extensions", "--enable-automation"],
            args: customArgs,
        });
        const page = await browser.newPage();
        await page.goto(`https://google.com/`);
        await page.waitForNavigation();
        await page.close();
        await browser.close();
    })();