Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/t2leaf/t2-puppeteer-plugin-random-ua
Helping to improve web scraping and automation by evading detection.
https://github.com/t2leaf/t2-puppeteer-plugin-random-ua
puppeteer puppeteer-plugin puppeteer-random-ua random-user-agent user-agent
Last synced: 4 days ago
JSON representation
Helping to improve web scraping and automation by evading detection.
- Host: GitHub
- URL: https://github.com/t2leaf/t2-puppeteer-plugin-random-ua
- Owner: T2LEAF
- Created: 2025-01-08T03:27:42.000Z (8 days ago)
- Default Branch: main
- Last Pushed: 2025-01-11T17:29:16.000Z (5 days ago)
- Last Synced: 2025-01-11T17:39:42.988Z (5 days ago)
- Topics: puppeteer, puppeteer-plugin, puppeteer-random-ua, random-user-agent, user-agent
- Language: TypeScript
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# t2-puppeteer-plugin-random-ua
[![npm version](https://badge.fury.io/js/t2-puppeteer-plugin-random-ua.svg)](https://badge.fury.io/js/t2-puppeteer-plugin-random-ua)
## Description
A Puppeteer plugin for random user-agents.
This plugin helps you generate random user-agents for your Puppeteer scripts, making them more robust against detection by websites.
## Installation
```bash
npm install t2-puppeteer-plugin-random-ua
```or using Yarn:
```bash
yarn add t2-puppeteer-plugin-random-ua
```### Usage
```js
import puppeteer from 'puppeteer';
import randomUserAgent from 't2-puppeteer-plugin-random-ua';(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Attach the plugin
randomUserAgent().onPageCreated(page)
await page.goto('https://example.com');console.log(await page.evaluate(() => navigator.userAgent));
await browser.close();
})();```
### Usage with puppeteer-extra
```js
import puppeteerExtra from 'puppeteer-extra';
import randomUserAgent from 't2-puppeteer-plugin-random-ua';puppeteerExtra.use(randomUserAgent());
(async () => {
const browser = await puppeteerExtra.launch();
const page = await browser.newPage();await page.goto('https://example.com');
console.log(await page.evaluate(() => navigator.userAgent));
await browser.close();
})();```