1

i use gologin service. gologin is a browser antidetect service where I can fake my browser identity / can manage browser fingerprint. so I can freely do web-scraping without being detected.

in this case I want to be able to load my extension into that browser using the puppeteer.connect() method.

here's the code:


const puppeteer = require('puppeteer-core');
const GoLogin = require('gologin');

(async () => {
  const GL = new GoLogin({
    token: 'yU0token',
    profile_id: 'yU0Pr0f1leiD',
  });

  const { status, wsUrl } = await GL.start();
  const browser = await puppeteer.connect({
    browserWSEndpoint: wsUrl.toString(),
    ignoreHTTPSErrors: true,
  });

  const page = await browser.newPage();
  await page.goto('https://myip.link/mini');
  console.log(await page.content());
  await browser.close();
  await GL.stop();
})();



I don't know how. please help me, so i can load my extension using this puppeteer.connect()
isco
  • 11
  • 1

1 Answers1

0

Assume your wish is loading chrome-extension into your puppeteer browser.

  1. Find chrome-extension Working Directory Where does Chrome store extensions?
  2. Find your extension ID by go to chrome://extensions/
  3. Sample code:

const puppeteer = require('puppeteer-core');

const MY_EXTENSION_PATH = '~/Library/Application Support/Google/Chrome/Default/Extensions/cdockenadnadldjbbgcallicgledbeoc/0.3.38_0'
async function loadExtension() {
  return puppeteer.launch({
    headless: 0,
    args: [
      `--disable-extensions-except=${MY_EXTENSION_PATH}`,
      `--load-extension=${MY_EXTENSION_PATH}`,
    ],
  });
}
Hoang Dung Pham
  • 366
  • 1
  • 5
  • Isn't the puppeteer.connect() method different from the puppeteer.launch() method which will run chromium? My goal is to use the puppeteer.connect() method so that I can use the custom browser provided by gologin. If I use the puppeteer.launch() method it will run chromium. I mean, I want my code to look like this: – isco Jul 05 '21 at 16:27
  • const browser = await puppeteer.connect({ browserWSEndpoint: wsUrl.toString(), args: [ `--disable-extensions-except=${MY_EXTENSION_PATH}`, `--load-extension=${MY_EXTENSION_PATH}`, ], }); – isco Jul 05 '21 at 16:31
  • Is it possible? – isco Jul 05 '21 at 16:32