@cliqz/adblocker enhanced with convenient Puppeteer wrapper
- extremely efficient adblocker (both in memory usage and raw speed)
- first-class support for Node.js, WebExtension, Electron and Puppeteer.
- efficiently blocks all types of ads and tracking
- supports cosmetics and scriptlet injection
- small and minimal (only 64KB minified and gzipped)
- support most filters: Easylist and uBlock Origin formats
For more details, check-out the following specialized guides:
- Node.js, @cliqz/adblocker
WebExtension, @cliqz/adblocker-webextension (demo)
Electron, @cliqz/adblocker-electron (demo)
npm install --save @cliqz/adblocker-puppeteer
For a complete example check-out: @cliqz/adblocker-puppeteer-example
Creating an instance of
PuppeteerBlocker and start blocking ads!
;;; // required 'fetch'const browser = await puppeteer;const page = await browser;PuppeteerBlocker;
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:
;const blocker = PuppeteerBlocker;
Fetching lists from URLs:
;; // required 'fetch'const blocker = await PuppeteerBlocker;
Use ready-made configs to block ads and optionally trackers:
;; // required 'fetch'let blocker = await PuppeteerBlocker; // ads onlyblocker = await PuppeteerBlocker; // ads and tracking
Disabling Blocker in page
To stop blocking ads in a 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
;;; // required 'fetch'; // used for cachingconst browser = await puppeteer;const page = await browser;PuppeteerBlocker;
Or you can do this manually to control the way caching is done:
;; // required 'fetch'PuppeteerBlocker;