# @ghostery/adblocker-puppeteer

> Ghostery adblocker Puppeteer wrapper

Latest version **2.20.1** (published 2026-10-09) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ghostery/adblocker-puppeteer
pnpm add @ghostery/adblocker-puppeteer
yarn add @ghostery/adblocker-puppeteer
bun add @ghostery/adblocker-puppeteer
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.20.1 |
| Published | 2026-10-09 |
| First published | 2024-10-17 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 102.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1011 |
| Author | Ghostery |
| Maintainers | chrmod, smalluban |

## Links

- npm: https://www.npmjs.com/package/@ghostery/adblocker-puppeteer
- Repository: https://github.com/ghostery/adblocker
- Homepage: https://github.com/ghostery/adblocker#readme
- Issues: https://github.com/ghostery/adblocker/issues
- npm.io page: https://npm.io/package/@ghostery/adblocker-puppeteer

## Dependencies (3)

- [tldts-experimental](https://npm.io/package/tldts-experimental.md) ^7.4.10
- [@ghostery/adblocker](https://npm.io/package/@ghostery/adblocker.md) ^2.20.1
- [@ghostery/adblocker-content](https://npm.io/package/@ghostery/adblocker-content.md) ^2.20.1

## Recent versions

- 2.20.1 (latest) — 2026-10-09
- 2.20.0 — 2026-10-09
- 2.19.0 — 2026-10-09
- 2.18.2 — 2026-08-05
- 2.18.1 — 2026-07-01
- 2.18.0 — 2026-06-04
- 2.17.3 — 2026-05-19
- 2.17.2 — 2026-05-19
- 2.17.1 — 2026-05-14
- 2.17.0 — 2026-05-08
- 2.16.0 — 2026-05-08
- 2.15.0 — 2026-05-04
- 2.14.5 — 2026-05-04
- 2.14.4 — 2026-04-30
- 2.14.3 — 2026-04-28
- … 49 more at https://npm.io/package/@ghostery/adblocker-puppeteer/versions

## README

<h1 align="center">Puppeteer Adblocker</h1>

<p align="center">
  <em>
    Efficient
    · Minimal
    · JavaScript
    · TypeScript
    · uBlock Origin- and Easylist-compatible
  </em>
  <br />
  <em>
    <a href="https://github.com/ghostery/adblocker/tree/master/packages/adblocker">Node.js</a>
    · <a href="https://github.com/ghostery/adblocker/tree/master/packages/adblocker-puppeteer">Puppeteer</a>
    · <a href="https://github.com/ghostery/adblocker/tree/master/packages/adblocker-electron">Electron</a>
    · <a href="https://github.com/ghostery/adblocker/tree/master/packages/adblocker-webextension">WebExtension</a>
  </em>
</p>

<p align="center">
  <a href="https://github.com/ghostery/adblocker/actions?query=workflow%3ATests">
    <img alt="Github Actions Build Status" src="https://img.shields.io/github/actions/workflow/status/ghostery/adblocker/tests.yml?label=tests&style=flat-square"></a>
  <a href="https://github.com/ghostery/adblocker/actions?query=workflow%3Assets">
    <img alt="Github Actions Assets Status" src="https://img.shields.io/github/actions/workflow/status/ghostery/adblocker/assets.yml?label=assets&style=flat-square"></a>
  <a href="https://twitter.com/acdlite/status/974390255393505280">
    <img alt="Blazing Fast" src="https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@ghostery/adblocker">
    <img alt="npm version" src="https://img.shields.io/npm/v/@ghostery/adblocker.svg?style=flat-square"></a>
  <a href="https://www.npmjs.com/package/@ghostery/adblocker">
    <img alt="weekly downloads from npm" src="https://img.shields.io/npm/dw/@ghostery/adblocker.svg?style=flat-square"></a>
  <br/>
  <a href="#badge">
    <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a>
  <a href="https://twitter.com/ghostery">
    <img alt="Follow Ghostery on Twitter" src="https://img.shields.io/twitter/follow/ghostery.svg?label=follow+ghostery&style=flat-square"></a>
  <a href="https://github.com/ghostery/adblocker">
    <img alt="Dependabot" src="https://img.shields.io/badge/dependabot-enabled-brightgreen?logo=dependabot&style=flat-square"></a>
  <a href="https://github.com/ghostery/adblocker/blob/master/LICENSE">
    <img alt="License Badge" src="https://img.shields.io/github/license/ghostery/adblocker?style=flat-square"></a>
  <a href="https://lgtm.com/projects/g/ghostery/adblocker?mode=list">
    <img alt="LGTM Badge" src="https://img.shields.io/lgtm/alerts/github/ghostery/adblocker?style=flat-square"></a>
</p>

---

## Getting Started

Install: `npm install --save @ghostery/adblocker-puppeteer`.

## Usage

For a *complete example* check-out: [@ghostery/adblocker-puppeteer-example](https://github.com/ghostery/adblocker/tree/master/packages/adblocker-puppeteer-example).

Creating an instance of `PuppeteerBlocker` and start blocking ads!

```javascript
import puppeteer from 'puppeteer';
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';
import fetch from 'cross-fetch'; // required 'fetch'

const browser = await puppeteer.launch();
const page = await browser.newPage();

PuppeteerBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
  blocker.enableBlockingInPage(page);
});
```

You are ready to block ads!

There are other ways you can *create an instance of the blocking engine* to
start blocking ads.

If you already have filters locally:
```javascript
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';

const blocker = PuppeteerBlocker.parse(fs.readFileSync('easylist.txt', 'utf-8'));
```

Fetching lists from URLs:
```javascript
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';
import fetch from 'cross-fetch'; // required 'fetch'

const blocker = await PuppeteerBlocker.fromLists(fetch, [
  'https://easylist.to/easylist/easylist.txt'
]);
```

Use ready-made configs to block ads and optionally trackers:
```javascript
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';
import fetch from 'cross-fetch'; // required 'fetch'

let blocker = await PuppeteerBlocker.fromPrebuiltAdsOnly(fetch); // ads only
blocker = await PuppeteerBlocker.fromPrebuiltAdsAndTracking(fetch); // ads and tracking
```

### Disabling Blocker in page

To stop blocking ads in a page:

```javascript
await blocker.disableBlockingInPage(page);
```

### Caching Blocker using Serialization

To avoid having to create the same instance of `PuppeteerBlocker` all over again,
you can serialize it to a byte-array which you can store on disk for faster
loading.

```javascript
import puppeteer from 'puppeteer';
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';
import fetch from 'cross-fetch'; // required 'fetch'
import { promises as fs } from 'fs'; // used for caching

const browser = await puppeteer.launch();
const page = await browser.newPage();

PuppeteerBlocker.fromPrebuiltAdsAndTracking(fetch, {
  path: 'engine.bin',
  read: fs.readFile,
  write: fs.writeFile,
}).then((blocker) => {
  blocker.enableBlockingInPage(page);
});
```

Or you can do this manually to control the way caching is done:

```javascript
import { PuppeteerBlocker } from '@ghostery/adblocker-puppeteer';
import fetch from 'cross-fetch'; // required 'fetch'

PuppeteerBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
  const buffer = blocker.serialize();
  const restoredBlocker = PuppeteerBlocker.deserialize(buffer);
  // `restoredBlocker` is deep-equal to `blocker`!
});
```

---
_Source: https://npm.io/package/@ghostery/adblocker-puppeteer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
