需在 background script 中调用 enableBlockingInBrowser 才会生效;fromPrebuiltAdsAndTracking 会加载预置规则,离线或网络受限时可能失败;不同运行环境需安装对应的独立包(如 adblocker-puppeteer、adblocker-electron)
adblocker
ghosteryMPL-2.0活跃维护可嵌入的 TypeScript 广告拦截库,基于 EasyList 规则做内容过滤,能直接集成到浏览器或 Puppeteer 等环境里实现隐私保护。
Efficient embeddable adblocker library
npm install --save @ghostery/adblocker-webextensionREADME 未说明,纯 JavaScript 库,无显存或 GPU 要求
Ghostery 出品的 JS 广告拦截库,可嵌入浏览器扩展、Electron 和 Puppeteer 中屏蔽广告与追踪器
可嵌入的 TypeScript 广告拦截库,基于 EasyList 规则做内容过滤,能直接集成到浏览器或 Puppeteer 等环境里实现隐私保护。
核心能力
- 兼容 Easylist 与 uBlock Origin 99% 的过滤规则
- 提供 WebExtension、Electron、Puppeteer 和 Node.js 多端封装
- 用 fromPrebuiltAdsAndTracking 加载预置规则并一键启用拦截
- 可作为独立 JS 库在 Node.js 或 React Native 等环境运行
- 算法高效,已被 Ghostery、Cliqz 等产品用于生产环境
容易踩的坑
- v2.20.3最新正式版2026-10-28 · 2026-10-28 13:03 UTC
:bug: Bug Fix
@ghostery/adblocker- Optimize regexp matching with leading or trailing ".*" #5863 (@philipp-classen)
:nut_and_bolt: Dependencies
- Build(deps): Bump undici from 7.30.0 to 7.30.1 #5866 (@dependabot[bot])
- Build(deps): Bump tldts-experimental from 7.4.16 to 7.4.18 in the tldts group #5858 (@dependabot[bot])
Authors: 2
- @dependabot[bot]
- Philipp Claßen (@philipp-classen)
- v2.20.12026-10-09 · 2026-10-09 17:11 UTC
查看更新说明
:bug: Bug Fix
@ghostery/adblocker- fix: subframe scriptlet filters ignore negated hostnames #5850 (@philipp-classen)
:nut_and_bolt: Dependencies
- Build(deps): Bump tldts-experimental from 7.4.11 to 7.4.16 in the tldts group #5856 (@dependabot[bot])
Authors: 2
- @dependabot[bot]
- Philipp Claßen (@philipp-classen)
- v2.20.02026-10-09 · 2026-10-09 16:14 UTC
查看更新说明
:running_woman: Performance
@ghostery/adblocker- fix: share uBO's safeSelf snapshot between separately injected scriptlets #5855 (@tomasrivero)
:house: Internal
@ghostery/adblocker- Update local assets #5817 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5812 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5811 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5808 ([email protected] @ghostery-adblocker-bot[bot])
:nut_and_bolt: Dependencies
- Build(deps): Bump ip-address from 10.4.0 to 10.7.2 #5844 (@dependabot[bot])
- Build(deps): Bump postcss-selector-parser from 7.1.1 to 7.1.6 #5853 (@dependabot[bot])
- Build(deps): Bump source-map-js from 1.2.1 to 1.2.2 #5852 (@dependabot[bot])
- Build(deps): Bump nx from 23.1.1 to 23.2.1 #5851 (@dependabot[bot])
- Build(deps): Bump undici from 7.29.0 to 7.30.0 #5843 (@dependabot[bot])
- Build(deps-dev): Bump the webextension group across 1 directory with 2 updates #5836 (@dependabot[bot])
- Build(deps): Bump browserslist from 4.28.1 to 4.28.9 #5835 (@dependabot[bot])
- Build(deps): Bump @humanfs/node from 0.16.7 to 0.16.8 #5833 (@dependabot[bot])
- Build(deps): Bump @babel/core from 7.28.6 to 7.29.7 #5742 (@dependabot[bot])
- Build(deps): Bump esbuild from 0.28.0 to 0.28.1 #5732 (@dependabot[bot])
- Build(deps): Bump the playwright group with 2 updates #5838 (@dependabot[bot])
- Build(deps): Bump tldts-experimental from 7.4.10 to 7.4.11 in the tldts group #5828 (@dependabot[bot])
- Build(deps-dev): Bump axios from 1.19.0 to 1.20.0 #5848 (@dependabot[bot])
- Build(deps): Bump undici from 7.28.0 to 7.29.0 #5803 (@dependabot[bot])
- Build(deps): Bump nx from 22.3.3 to 22.7.8 #5806 (@dependabot[bot])
- Build(deps): Bump tldts-experimental from 7.4.9 to 7.4.10 in the tldts group across 1 directory #5798 (@dependabot[bot])
- Build(deps): Bump the playwright group across 1 directory with 2 upd
- v2.18.22026-08-05 · 2026-08-05 15:33 UTC
查看更新说明
:bug: Bug Fix
- docs: fix HTML tag mismatch, list punctuation, and typo in README.md #5775 (@ferkans-amir @amir-rezaei)
@ghostery/adblocker- fix: preprocessor evaluation takes misplaced operators #5795 (@seia-soto)
:house: Internal
- fix(ci): playwright browsers not being found #5787 (@seia-soto)
@ghostery/adblocker- Update local assets #5805 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5797 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5796 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5794 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5791 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5789 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5783 ([email protected] @seia-soto @ghostery-adblocker-bot[bot])
- Update local assets #5781 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5774 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5773 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5769 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5767 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5765 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5764 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5762 ([email protected] @ghostery-adblocker-bot[bot])
- Update local assets #5759 ([email protected] [@ghostery-adblocker-bot[bot]](https://github.com
- v2.18.12026-07-01 · 2026-07-01 02:32 UTC
查看更新说明
:bug: Bug Fix
@ghostery/adblocker- fix: normalizedUrl is set too early #5743 (@seia-soto)
:house: Internal
@ghostery/adblocker-content,@ghostery/adblocker-electron-example,@ghostery/adblocker-electron-preload,@ghostery/adblocker-electron,@ghostery/adblocker-extended-selectors,@ghostery/adblocker-playwright-example,@ghostery/adblocker-playwright,@ghostery/adblocker-puppeteer-example,@ghostery/adblocker-puppeteer,@ghostery/adblocker-webextension-cosmetics,@ghostery/adblocker-webextension-example,@ghostery/adblocker-webextension,@ghostery/adblocker- internal: housekeeping with 2026 asset registration #5740 (@seia-soto)
@ghostery/adblocker- Update local assets #5733 ([email protected] @ghostery-adblocker-bot[bot])
- fix(test): migration test #5725 (@seia-soto)
- Update local assets #5726 ([email protected] @ghostery-adblocker-bot[bot])
:nut_and_bolt: Dependencies
- Build(deps): Bump tldts-experimental from 7.4.3 to 7.4.4 in the tldts group across 1 directory #5744 (@dependabot[bot])
- Build(deps): Bump the playwright group across 1 directory with 2 updates #5745 (@dependabot[bot])
- Build(deps): Bump @sigstore/core from 3.1.0 to 3.2.1 #5749 (@dependabot[bot])
- Build(deps): Bump undici from 7.25.0 to 7.28.0 #5737 (@dependabot[bot])
- Build(deps): Bump form-data from 4.0.5 to 4.0.6 #5738 (@dependabot[bot])
- Build(deps-dev): Bump @types/chrome from 0.1.42 to 0.1.43 in the webextension group #5727 (@dependabot[bot])
@ghostery/adblocker-electron-example,@ghostery/adblocker-electron-preload,@ghostery/adblocker-electron,@ghostery/adblocker-puppeteer-example,@ghostery/adblocker-puppeteer- Build(deps): Bump the production-dependencies group across 1 directory with 2 updates #5747 (@dependabot[bot])
Authors: 4
- @dependabot[bot]
- @ghostery-adblocker-bot[bot]
- Ghostery Adblocker Bot ([email protected])
- HoJeong Go (@seia-soto)
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
The Ghostery adblocker is a JavaScript library for blocking ads, trackers, and annoyances with a strong focus on efficiency. It was designed with compatibility in mind and integrates seamlessly with the following environments:
- Block ads in Puppeteer,
- Block ads in Electron,
- Block ads in Chrome and Firefox,
- Or as a standalone JavaScript library.
Getting Started
The Ghostery adblocker is the easiest and most efficient way to block ads and trackers in your project. Only a few lines of code are required to integrate smoothly with Puppeteer, Electron, a Chrome- and Firefox-compatible browser extension, or any environment supporting JavaScript (e.g. Node.js or React Native).
Here is how to do it in two steps for a Chrome- and Firefox-compatible WebExtension:
- Install:
npm install --save @ghostery/adblocker-webextension - Add the following in your background script:
import { WebExtensionBlocker } from '@ghostery/adblocker-webextension';
WebExtensionBlocker.fromPrebuiltAdsAndTracking().then((blocker) => {
blocker.enableBlockingInBrowser(browser);
});
Congratulations, you are now blocking all ads and trackers! :tada:
Compatibility
The library supports 99% of all filters from the Easylist and uBlock Origin projects. Check the compatibility matrix on the wiki for more details.
Contributing
This project makes use of lerna and yarn workspaces under the hood. Quickly get started with:
- Fork and clone the repository,
- Enable corepack:
corepack enable, - Install dependencies:
yarn install --immutable, - Build:
yarn build, - Test:
yarn test.
For any questions, feel free to open an issue or a pull request to get some help!
Who is using it?
This library is the building block technology used to power the adblockers from Ghostery and Cliqz on both desktop and mobile platforms. It is already running in production for millions of users and has been battle-tested to satisfy the following use-cases:
- Mobile-friendly adblocker in react-native, WebExtension, or custom JavaScript context: Ghostery for iOS.
- Ads and trackers blocker in Electron applications, Puppeteer headless browsers, Cliqz browser, ghostery and standalone).
- Batch requests processing in Node.js, HTML fuzzy keyword matcher, and more.
The innovative algorithms and architecture designed and implemented in this project have been shown to be among the most efficient ways to implement ad-blockers and have been used in other projects to implement highly performant adblockers such as Brave.
Swag
Show the world you're using ghostery/adblocker →
[](https://github.com/ghostery/adblocker)
Or HTML:
<a href="https://github.com/ghostery/adblocker/" target="_blank" rel="noopener noreferrer">
<img alt="powered by Ghostery" src="https://img.shields.io/badge/ghostery-powered-blue?logo=ghostery">
</a>