adblocker

ghosteryMPL-2.0活跃维护

可嵌入的 TypeScript 广告拦截库,基于 EasyList 规则做内容过滤,能直接集成到浏览器或 Puppeteer 等环境里实现隐私保护。

Efficient embeddable adblocker library

v2.20.3发布于 2026-10-28 13:03 UTC1,016star +1 / 7 天124fork同步于 2026-11-10 11:51 UTC

怎么上手

由 README 提炼,执行前请确认
npm install --save @ghostery/adblocker-webextension
硬件要求按 README 说明

README 未说明,纯 JavaScript 库,无显存或 GPU 要求

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Ghostery 出品的 JS 广告拦截库,可嵌入浏览器扩展、Electron 和 Puppeteer 中屏蔽广告与追踪器

可嵌入的 TypeScript 广告拦截库,基于 EasyList 规则做内容过滤,能直接集成到浏览器或 Puppeteer 等环境里实现隐私保护。

核心能力

  • 兼容 Easylist 与 uBlock Origin 99% 的过滤规则
  • 提供 WebExtension、Electron、Puppeteer 和 Node.js 多端封装
  • 用 fromPrebuiltAdsAndTracking 加载预置规则并一键启用拦截
  • 可作为独立 JS 库在 Node.js 或 React Native 等环境运行
  • 算法高效,已被 Ghostery、Cliqz 等产品用于生产环境

容易踩的坑

需在 background script 中调用 enableBlockingInBrowser 才会生效;fromPrebuiltAdsAndTracking 会加载预置规则,离线或网络受限时可能失败;不同运行环境需安装对应的独立包(如 adblocker-puppeteer、adblocker-electron)

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2.20.3
  1. v2.20.3最新正式版2026-10-28 · 2026-10-28 13:03 UTC
    :bug: Bug Fix
    :nut_and_bolt: Dependencies
    Authors: 2
  2. v2.20.12026-10-09 · 2026-10-09 17:11 UTC
    查看更新说明
    :bug: Bug Fix
    :nut_and_bolt: Dependencies
    Authors: 2
  3. 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
    :nut_and_bolt: Dependencies
  4. v2.18.22026-08-05 · 2026-08-05 15:33 UTC
    查看更新说明
    :bug: Bug Fix
    :house: Internal
  5. v2.18.12026-07-01 · 2026-07-01 02:32 UTC
    查看更新说明
    :bug: Bug Fix
    • @ghostery/adblocker
    :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
    • @ghostery/adblocker
    :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

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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:

    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:

    1. Install: npm install --save @ghostery/adblocker-webextension
    2. 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:

    1. Fork and clone the repository,
    2. Enable corepack: corepack enable,
    3. Install dependencies: yarn install --immutable,
    4. Build: yarn build,
    5. 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 → powered by Ghostery

    [![powered by Ghostery](https://img.shields.io/badge/ghostery-powered-blue?logo=ghostery)](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>
    

    License

    Mozilla Public License 2.0