Utility to load prebuilt AdGuard DNR rulesets for mv3 extensions.
The list of available filters can be found by filters
in the metadata.
-
Dnr-rulesets
- Basic usage
- Advanced usage
- Example
-
Included filter lists
- Ad Blocking
- Privacy
- Social Widgets
- Annoyances
- Security
- Other
-
Language-specific
- AdGuard Russian filter
- AdGuard German filter
- AdGuard Japanese filter
- AdGuard Dutch filter
- AdGuard Spanish/Portuguese filter
- AdGuard Turkish filter
- AdGuard French filter
- AdGuard Ukrainian filter
- Bulgarian list
- EasyList Czech and Slovak
- EasyList Hebrew
- EasyList Italy
- EasyList Lithuania
- Latvian List
- Liste AR
- AdBlockID
- EasyList Thailand
- Hungarian filter
- ABPVN List
- Official Polish filters for AdBlock, uBlock Origin & AdGuard
- Estonian List
- AdGuard Chinese filter
- List-KR
- Adblock List for Finland
- Persian Blocker
- Polish Anti Adblock Filters
- Frellwit's Swedish Filter
- Dandelion Sprout's Nordic Filters
- Dandelion Sprout's Serbo-Croatian List
- IndianList
- Macedonian adBlock Filters
- Development
Install package.
NOTE: To update filters in time, make sure you have the latest version of the package installed.
npm install --save-dev @adguard/dnr-rulesets
- Add scripts to your
package.json
to load DNR rulesets and patch extension manifest.
{
"scripts": {
"load-dnr-rulesets": "dnr-rulesets load <path-to-output>",
"patch-manifest": "dnr-rulesets manifest <path-to-manifest> <path-to-output>"
}
}
patch-manifest
command also provide two options:
-
-f, --force-update
- force update rulesets with existing id (default: false) -
-i, --ids <ids...>
- filters ids to append (default: []) -
-e, --enable <ids...>
- enable filters by default (default: []) -
-r, --ruleset-prefix <prefix>
- prefix for filters ids (default: "ruleset_") -
-m, --filters-match <match>
- filters files match glob pattern (default: "filter_+([0-9]).txt")
- Run the script to load DNR rulesets as part of your build flow.
npm run load-dnr-rulesets
- Patch your extension manifest to include DNR rulesets.
npm run patch-manifest
You can also integrate functions for downloading and updating the manifest into your build script:
- Load DNR rulesets.
import { AssetsLoader } from '@adguard/dnr-rulesets';
const loader = new AssetsLoader();
await loader.load('<path-to-output>');
- Patch extension manifest.
import { ManifestPatcher } from '@adguard/dnr-rulesets';
const patcher = new ManifestPatcher();
patcher.path(
'<path-to-manifest>',
'<path-to-output>',
{
// Optional: specify filter IDs to include
ids: ['2', '3'],
// Optional: specify enabled filter IDs
enabled: ['2'],
// Optional: set to true to overwrite existing rulesets
forceUpdate: true,
// Optional: set prefix for ruleset paths
rulesetPrefix: 'ruleset_',
// Optional: specify filter files matching glob pattern
filtersMatch: 'filter_+([0-9]).txt',
},
)
/
|
|declarative
| |
| |ruleset_<id>
| |
| |ruleset_<id>.json // DNR ruleset converted from filter_<id>.txt
| |metadata.json // Ruleset metadata with source mapping
| |lazy_Metadata.json // Additional ruleset metadata for lazy loading
|
|filter_<id>.txt // Original filter rules with specified id
We also provide flexible API to apply rulesets to the manifest object. It can be useful if you want to patch to the manifest while bundling.
import { RulesetsInjector } from '@adguard/dnr-rulesets';
const injector = new RulesetsInjector();
const manifest = {
// Your manifest data
};
const ManifestWithRulesets = injector.applyRulesets(
(id) => `<path to rulesets>/${id}.json`,
manifest,
['2', '3'],
{
// Optional: specify filter IDs to include
ids: ['2', '3'],
// Optional: specify enabled filter IDs
enabled: ['2'],
// Optional: set to true to overwrite existing rulesets
forceUpdate: true,
// Optional: set prefix for ruleset paths
rulesetPrefix: 'ruleset_',
},
);
Example of usage: adguard-api-mv3
EasyList + AdGuard English filter. This filter is necessary for quality ad blocking.
- Filter ID: 2
- Path:
<filters-directory>/declarative/ruleset_2/ruleset_2.json
Filter for all known mobile ad networks. Useful for mobile devices.
- Filter ID: 11
- Path:
<filters-directory>/declarative/ruleset_11/ruleset_11.json
IMPORTANT: This filter is not convertible (excluded from build), but it is still included in the metadata. It should be downloaded from the server on the client and applied dynamically.
Filter to quickly resolve content filtering issues on popular websites without updating the extension.
- Filter ID: 24
The most comprehensive list of various online counters and web analytics tools. Use this filter if you do not want your actions on the Internet to be tracked.
- Filter ID: 3
- Path:
<filters-directory>/declarative/ruleset_3/ruleset_3.json
Filter that enhances privacy by removing tracking parameters from URLs.
- Filter ID: 17
- Path:
<filters-directory>/declarative/ruleset_17/ruleset_17.json
Filter for social media widgets such as 'Like' and 'Share' buttons and more.
- Filter ID: 4
- Path:
<filters-directory>/declarative/ruleset_4/ruleset_4.json
Blocks cookie notices on web pages.
- Filter ID: 18
- Path:
<filters-directory>/declarative/ruleset_18/ruleset_18.json
Blocks all kinds of pop-ups that are not necessary for websites' operation according to our Filter policy.
- Filter ID: 19
- Path:
<filters-directory>/declarative/ruleset_19/ruleset_19.json
Blocks irritating banners that promote mobile apps of websites.
- Filter ID: 20
- Path:
<filters-directory>/declarative/ruleset_20/ruleset_20.json
Blocks irritating elements on web pages that do not fall under the popular categories of annoyances.
- Filter ID: 21
- Path:
<filters-directory>/declarative/ruleset_21/ruleset_21.json
Blocks annoying third-party widgets: online assistants, live support chats, etc.
- Filter ID: 22
- Path:
<filters-directory>/declarative/ruleset_22/ruleset_22.json
Blocks domains that are known to be used to propagate malware and spyware.
- Filter ID: 208
- Path:
<filters-directory>/declarative/ruleset_208/ruleset_208.json
Phishing URL blocklist for uBlock Origin (uBO), AdGuard, Vivaldi, Pi-hole, Hosts file, Dnsmasq, BIND, Unbound, Snort and Suricata.
- Filter ID: 255
- Path:
<filters-directory>/declarative/ruleset_255/ruleset_255.json
List for blocking untrustworthy websites.
- Filter ID: 256
- Path:
<filters-directory>/declarative/ruleset_256/ruleset_256.json
Filter for risky sites, warning users of potential threats.
- Filter ID: 257
- Path:
<filters-directory>/declarative/ruleset_257/ruleset_257.json
Filter designed to test certain hazardous filtering rules before they are added to the basic filters.
- Filter ID: 5
- Path:
<filters-directory>/declarative/ruleset_5/ruleset_5.json
Filter that unblocks search ads in Google, DuckDuckGo, Bing, or Yahoo and self-promotion on websites.
- Filter ID: 10
- Path:
<filters-directory>/declarative/ruleset_10/ruleset_10.json
Filter that enables ad blocking on websites in Russian language.
- Filter ID: 1
- Path:
<filters-directory>/declarative/ruleset_1/ruleset_1.json
EasyList Germany + AdGuard German filter. Filter list that specifically removes ads on websites in German language.
- Filter ID: 6
- Path:
<filters-directory>/declarative/ruleset_6/ruleset_6.json
Filter that enables ad blocking on websites in Japanese language.
- Filter ID: 7
- Path:
<filters-directory>/declarative/ruleset_7/ruleset_7.json
EasyList Dutch + AdGuard Dutch filter. Filter list that specifically removes ads on websites in Dutch language.
- Filter ID: 8
- Path:
<filters-directory>/declarative/ruleset_8/ruleset_8.json
Filter list that specifically removes ads on websites in Spanish, Portuguese, and Brazilian Portuguese languages.
- Filter ID: 9
- Path:
<filters-directory>/declarative/ruleset_9/ruleset_9.json
Filter list that specifically removes ads on websites in Turkish language.
- Filter ID: 13
- Path:
<filters-directory>/declarative/ruleset_13/ruleset_13.json
Liste FR + AdGuard French filter. Filter list that specifically removes ads on websites in French language.
- Filter ID: 16
- Path:
<filters-directory>/declarative/ruleset_16/ruleset_16.json
Filter that enables ad blocking on websites in Ukrainian language.
- Filter ID: 23
- Path:
<filters-directory>/declarative/ruleset_23/ruleset_23.json
Additional filter list for websites in Bulgarian.
- Filter ID: 103
- Path:
<filters-directory>/declarative/ruleset_103/ruleset_103.json
Additional filter list for websites in Czech and Slovak.
- Filter ID: 105
- Path:
<filters-directory>/declarative/ruleset_105/ruleset_105.json
Additional filter list for websites in Hebrew.
- Filter ID: 108
- Path:
<filters-directory>/declarative/ruleset_108/ruleset_108.json
Additional filter list for websites in Italian.
- Filter ID: 109
- Path:
<filters-directory>/declarative/ruleset_109/ruleset_109.json
Additional filter list for websites in Lithuanian.
- Filter ID: 110
- Path:
<filters-directory>/declarative/ruleset_110/ruleset_110.json
Additional filter list for websites in Latvian.
- Filter ID: 111
- Path:
<filters-directory>/declarative/ruleset_111/ruleset_111.json
Additional filter list for websites in Arabic.
- Filter ID: 112
- Path:
<filters-directory>/declarative/ruleset_112/ruleset_112.json
Additional filter list for websites in Indonesian.
- Filter ID: 120
- Path:
<filters-directory>/declarative/ruleset_120/ruleset_120.json
Filter that blocks ads on Thai sites.
- Filter ID: 202
- Path:
<filters-directory>/declarative/ruleset_202/ruleset_202.json
Hufilter. Filter list that specifically removes ads on websites in the Hungarian language.
- Filter ID: 203
- Path:
<filters-directory>/declarative/ruleset_203/ruleset_203.json
Vietnamese adblock filter list.
- Filter ID: 214
- Path:
<filters-directory>/declarative/ruleset_214/ruleset_214.json
Additional filter list for websites in Polish.
- Filter ID: 216
- Path:
<filters-directory>/declarative/ruleset_216/ruleset_216.json
Polish filter list for cookies blocking.
- Filter ID: 217
- Path:
<filters-directory>/declarative/ruleset_217/ruleset_217.json
Filter for ad blocking on Estonian sites.
- Filter ID: 218
- Path:
<filters-directory>/declarative/ruleset_218/ruleset_218.json
EasyList China + AdGuard Chinese filter. Filter list that specifically removes ads on websites in Chinese language.
- Filter ID: 224
- Path:
<filters-directory>/declarative/ruleset_224/ruleset_224.json
Filter that removes ads and various scripts from websites with Korean content. Combined and augmented with AdGuard-specific rules for enhanced filtering. This filter is expected to be used alongside with AdGuard Base filter.
- Filter ID: 227
- Path:
<filters-directory>/declarative/ruleset_227/ruleset_227.json
Finnish ad blocking filter list.
- Filter ID: 233
- Path:
<filters-directory>/declarative/ruleset_233/ruleset_233.json
Filter list for blocking ads and trackers on websites in Persian.
- Filter ID: 235
- Path:
<filters-directory>/declarative/ruleset_235/ruleset_235.json
Official Polish filters against Adblock alerts.
- Filter ID: 238
- Path:
<filters-directory>/declarative/ruleset_238/ruleset_238.json
Filter that aims to remove regional Swedish ads, tracking, social media, annoyances, sponsored articles etc.
- Filter ID: 243
- Path:
<filters-directory>/declarative/ruleset_243/ruleset_243.json
This list covers websites for Norway, Denmark, Iceland, Danish territories, and the Sami indigenous population.
- Filter ID: 249
- Path:
<filters-directory>/declarative/ruleset_249/ruleset_249.json
A filter list for websites in Serbian, Montenegrin, Croatian, and Bosnian.
- Filter ID: 252
- Path:
<filters-directory>/declarative/ruleset_252/ruleset_252.json
Additional filter list for websites in Hindi, Tamil and other Dravidian and Indic languages.
- Filter ID: 253
- Path:
<filters-directory>/declarative/ruleset_253/ruleset_253.json
Blocks ads and trackers on various Macedonian websites.
- Filter ID: 254
- Path:
<filters-directory>/declarative/ruleset_254/ruleset_254.json
Downloads original rules, converts it to DNR rule sets via TSUrlFilter declarative-converter and generates extension manifest with predefined rules resources.
pnpm run build:assets
Builds SDK to load DNR rule sets to the specified directory.
pnpm run build:lib
Builds CLI utility to load DNR rule sets to the specified directory.
pnpm run build:cli
Generates Included filter lists section.
pnpm run build:docs
Clears dist
folder and runs build:assets
, build:cli
and build:lib
scripts.
pnpm run build