thomasdondorf / puppeteer-cluster

Puppeteer Pool, run a cluster of instances in parallel
MIT License
3.22k stars 309 forks source link

Extension doesn't work #543

Open silvestrodecaro opened 3 months ago

silvestrodecaro commented 3 months ago

I'm trying to load CapSolver's extension on my browser instances generated with Puppeteer Cluster, but it seems that the extension only works on the about:blank instance (the instance that Puppeteer Cluster creates when you use CONCURRENCY_CONTEXT) and not on the actual browsing instances.

Screenshot

const { Cluster } = require('puppeteer-cluster');

(async () => {
    const pathToExtension = require('path').join(__dirname, 'capsolver');
    const cluster = await Cluster.launch({
        concurrency: Cluster.CONCURRENCY_CONTEXT,
        maxConcurrency: 2,
        puppeteerOptions: {
            headless: false,
            args: [
                `--disable-extensions-except=${pathToExtension}`,
                `--load-extension=${pathToExtension}`,
            ],
        },
    });

    await cluster.task(async ({ page, data: url }) => {
        await page.goto(url);
        await delay(60000);
    });

    cluster.queue('http://www.google.com/');
    cluster.queue('http://www.wikipedia.org/');
    // many more pages

    await cluster.idle();
    await cluster.close();
})();

function delay(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}