Skip to content

Commit

Permalink
Added ESM example
Browse files Browse the repository at this point in the history
  • Loading branch information
justchrister authored Apr 19, 2024
1 parent 39248f1 commit 0dd8827
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/puppeteer-extra-plugin-anonymize-ua/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')())
Expand All @@ -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});
```
* * *

0 comments on commit 0dd8827

Please sign in to comment.