CheshireCaat / playwright-with-fingerprints

Anonymous automation via playwright with fingerprint replacement technology.
MIT License
124 stars 8 forks source link

newContext not have ? #10

Closed Romhast closed 1 year ago

Romhast commented 1 year ago

Hi, I was going to use newContext for geolocation and device, but I couldn't find such a function. Do you know?

image image

const { plugin } = require('playwright-with-fingerprints');
const { readFile, writeFile } = require('fs/promises');

(async () => {
  // Get a fingerprint from the server:
  const fingerprint = await plugin.fetch('', {
    tags: ['Microsoft Windows', 'Chrome'],
  });
  await writeFile('fingerprint.json', fingerprint);
  plugin.useFingerprint(fingerprint);

  // Launch the browser instance:

  const browser = await plugin.launch({headless: false});
  const context = await browser.newContext({
    geolocation: { longitude: 41.890221, latitude: 12.492348 },
    permissions: ['geolocation']
  });

  // The rest of the code is the same as for a standard `playwright` library:
  const page = await browser.newPage();
  await page.goto('https://fingerprint.com/');
})();
CheshireCaat commented 1 year ago

As mentioned in the warning message and also in this commit for the latest release, the launch method has been replaced with launchPersistentContext. Also please check #9 and #8.

It means that the launch method now returns a BrowserContext instance instead of a Browser, and also accepts options object from the launchPersistentContext as parameters. In order to change geolocation and so on you should use the methods described here.