puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

Add 'user-agents' package

Open jstormail2 opened this issue 5 years ago • 1 comments

The user-agents package is updated daily to include popular user agents. For instance, a random ua sample:

{
  "appName": "Netscape",
  "connection": {
    "downlink": 10,
    "effectiveType": "4g",
    "rtt": 0
  },
  "platform": "Win32",
  "pluginsLength": 3,
  "vendor": "Google Inc.",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36",
  "viewportHeight": 660,
  "viewportWidth": 1260,
  "deviceCategory": "desktop",
  "screenHeight": 800,
  "screenWidth": 1280
}

I would use a custom function as indicated in puppeteer-extra-plugin-anonymize-ua, but I would also like to implement the other ua data, such as viewport, platform, etc.

What would be the best way to go about adding the user-agents library to either puppeteer-extra-plugin-stealth or puppeteer-extra-plugin-anonymize-ua?

jstormail2 avatar Apr 14 '19 17:04 jstormail2

For the time being you could use the custom function feature of the puppeteer-extra-plugin-anonymize-ua plugin. :)

puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')({
  customFn: (ua) => "MyCustomUserAgent/1.0"
}))

This sounds like a nice addition to puppeteer-extra, will implement it when I find some time.

berstend avatar Nov 25 '19 12:11 berstend