From 0dd8827f52370bd4e0bea8a1104bfd25e4d377b6 Mon Sep 17 00:00:00 2001 From: christer <42318403+justchrister@users.noreply.github.com> Date: Fri, 19 Apr 2024 21:18:14 +0200 Subject: [PATCH] Added ESM example --- .../puppeteer-extra-plugin-anonymize-ua/readme.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/puppeteer-extra-plugin-anonymize-ua/readme.md b/packages/puppeteer-extra-plugin-anonymize-ua/readme.md index 54c4c3dcb..028c87d8d 100644 --- a/packages/puppeteer-extra-plugin-anonymize-ua/readme.md +++ b/packages/puppeteer-extra-plugin-anonymize-ua/readme.md @@ -32,7 +32,7 @@ Type: `function (opts)` - `opts.customFn` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** A custom UA replacer function. (optional, default `null`) Example: - +### CommonJS ```javascript const puppeteer = require('puppeteer-extra') puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')()) @@ -42,5 +42,15 @@ puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')({ ) const browser = await puppeteer.launch() ``` - +### ES Modules (ESM) +```javascript +import puppeteer from 'puppeteer-extra'; +import AnonymizeUa from 'puppeteer-extra-plugin-anonymize-ua' + +const browser = await puppeteer + .use(AnonymizeUa({ + customFn: (ua) => person.userAgent}) + ) + .launch({headless: false}); +``` * * *