This repository contains the known filters subscriptions available to AdGuard users. We re-host these filters on filters.adtidy.org
. Also, these filters can be slightly modified in order to achieve better compatibility with AdGuard.
We may add third-party filters to AdGuard Filters Registry. When making a decision about adding a third-party filter, we follow these rules:
template.txt
Template file is used by the filters compiler to prepare the final filter version.
exclude.txt
A list of regular expressions. Rules that match these exclusions will not be included in the resulting filter.
metadata.json
Filter metadata. Includes name, description, etc.
filterId
— unique filter identifier (integer)name
— filter name; can be localizeddescription
— filter descriptiontimeAdded
— time when this filter was added to the registry; milliseconds since January 1, 1970; you can exec new Date().getTime()
in the browser console to get the current timehomepage
— filter website/homepagedeprecated
— optional, boolean, filter is deprecated and should not be used by the products,
but filter is still available, i.e. not removedexpires
— filter's default expiration period; used as filter update interval if "Default" is chosen for according setting in AdGuard productdisplayNumber
— this number is used when AdGuard sorts available filters (GUI)groupId
— group identifiersubscriptionUrl
— This field only makes sense for third-party lists that come from the registry. The idea is that these lists are re-hosted by the registry and downloaded not from the source urldownloadUrl
— main filter download urltags
— a list of tagstrustLevel
— level of trust which describe allowed and permitted rules types; possible values:
low
— only low-risk rule types are allowed; defaults to low if trust level is not configured at allhigh
— trusted third-party filter lists; some particular rules from there are still permittedfull
— all types of filter rules are allowed; only AdGuard filter lists have full trust at the momentignoreTrustLevel
- note that this directive will allow ignoring the trustLevel
for a specific internal file of a third-party filterplatformsIncluded
— the list of platforms to compile the filter for, e.g. ["mac", "windows", "android"]
. If you need to compile the filter for all platforms remove this propertyplatformsExcluded
— the list of platforms to skip while filter compiling, e.g. ["ios", "ext_safari"]
. If you need to compile the filter for all platforms remove this propertyNote please that both
platformsIncluded
andplatformsExcluded
should not be set in filter's metadata simultaneously.
revision.json
Filter version metadata, automatically filled and overwritten on each build.
filter.txt
Resulting compiled filter.
diff.txt
Build log that contains excluded and converted rules with an explanation.
trusted-rules.txt
This file contains rules that are excluded by the filters compiler based on the specified trustLevel.
Every filter can be marked by a number of tags. Every tag metadata listed in /tags/metadata.json
.
Possible tags:
lang:*
— for language-specific filters; one or multiple lang-tags can be used. For instance, AdGuard Russian filter is marked with the lang:ru
tag.
purpose:*
— determines filters purposes; multiple purpose-tags can be used for one filter list. For instance, AdGuard DNS
is marked with both purpose:ads
and purpose:privacy
.
recommended
— for low-risk filter lists which are recommended to use in their category. The category is determined by the pair of the lang:*
and purpose:*
tags.
obsolete
— for abandoned filter lists; filter's metadata with this tag will be excluded from filters.json
and filters_i18n.json
.
/groups/metadata.json
— filters groups metadata. Each filter should belong to one of the groups.
For each filter, AdGuard compiles two versions: full and optimized. Optimized version is much more lightweight and does not contain rules which are not used at all or used rarely. Rules usage frequency comes from the collected filter rules statistics (thanks to the volunteers who enabled it in their AdGuard).
optimization_config.json
- This file defines the target for the optimization process. AdGuard will attempt to compress the lists by removing the least frequently used rules until the compression goal (defined in percentages) is achieved.
NOTE:
However, these changes will only take effect after being uploaded to the server, as filters-compiler
does not use this file locally but retrieves it from the server.
Script located in scripts/build/custom_platforms.js
customizes the way filters are compiled for certain platforms. We should use it if we need to
temporary change rules for a platform. In all other cases, we should prefer the default configuration.
Below is a example of the configuration for the platform AdGuard for Chrome
with comments:
"EXTENSION_CHROMIUM": {
// Defines the platform for which the settings are specified.
"platform": "ext_chromium",
// Defines the path that can be used to access the settings or resources associated with this platform.
"path": "extension/chromium",
// Overrides the expires value set in the filter metadata (for this platform).
"expires": "12 hours",
"configuration": {
// Sets an array of regular expressions that will be used to remove certain rules.
"removeRulePatterns": [
"^((?!#%#).)*\\$\\$|\\$\\@\\$",
"\\$(.*,)?replace=",
"important,replace=",
"\\$(.*,)?app",
"\\$network",
"\\$protobuf",
"important,protobuf",
"\\$extension",
",extension"
],
// Sets an array of objects that will be used to replace certain values.
"replacements": [
{
"from": ":has\\(",
"to": ":-abp-has("
}
],
// Specifies whether to ignore hints for rules. A value of "false" means that hints will not be ignored.
"ignoreRuleHints": false
},
"defines": {
"adguard": true,
"adguard_ext_chromium": true
}
},
If you want to help with filters translations, you can join us on Crowdin: https://crowdin.com/project/adguard-applications/en#/miscellaneous/filters-registry
Please learn more about translating our products: https://adguard.com/kb/miscellaneous/contribute/translate/program/
@include
directive allows to include the content of specified file into the filter.
More information about the @include
directive and its options can be found here: https://github.com/AdguardTeam/FiltersCompiler/#include-directive.
Install Dependencies
yarn install
Build Filters and Patches:
To build all filters, run:
yarn build
The yarn build
command accepts two parameters:
-i
: Filters to build.-s
: Filters to skip.For example, to build only AdGuard filters:
yarn build -i=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,224
It takes filter templates from the /filters
path, loads their content, compiles filters based on the provided whitelist and blacklist, generates log and report files, and creates a copy of platform files for future patch generation in temp/platforms
to compare old and new filters.
After every yarn build
, yarn will execute the postbuild
task, which checks all generated filters in the platforms/
folder. If there are no changes in the filter except for deleting Diff-Path
(because the compiler doesn't retrieve this tag from metadata and deletes it on every compile run), the script will undo these unnecessary changes.
Build Patches
To build patches with different TTL (Time To Live) and selectively include or exclude specific filter IDs, use the following commands:
For a TTL of 10 hours:
yarn build:patches --time=10 --resolution=h
For a TTL of 60 minutes:
yarn build:patches --time=60 --resolution=m
For a TTL of 3000 seconds:
yarn build:patches --time=3000 --resolution=s
To include specific filter IDs:
yarn build:patches --include=1,2,3
This includes only filters with IDs 1, 2, and 3 in the patch generation process.
To exclude specific filter IDs:
yarn build:patches --skip=4,5
This excludes filters with IDs 4 and 5 from the patch generation process.
This script recursively finds new filter files in the platforms/
folder, generates patches by comparing them with corresponding old filter files (from temp/platforms
), and saves these patches in a designated directory. The --include
and --skip
parameters allow for selective processing of filters based on their IDs. After generating the patches, the script copies any existing old patches to the new filter directory and cleans up temporary files, facilitating the maintenance and updates of filters.
Validate Platforms
To validate filters.json
and filters_i18n.json
for platforms, use the following command:
yarn validate:platforms ./platforms
Validate Locales
To validate locales, use the following command:
yarn validate:locales
(Optional) Combined Validation
Steps 4 and 5 can be combined and run with a single command:
yarn validate
Install Dependencies
yarn install
Run the Build Process
yarn auto-build --mode adguard
Install Dependencies
yarn install
Run the Build Process
yarn auto-build --mode all
For information on working with locales, please refer to the Translations README.
You can expand wildcard domains using the CLI commands provided in this project. These commands help update and expand wildcard domains across various platforms. For more information on why this feature was needed, visit this link.
Install Dependencies
yarn install
Update Wildcard Domains
This command extracts wildcard domains from the filters, converts them to a list of domains, selects the alive domains, and saves the resulting map to a JSON file wildcard_domains.json.
yarn update-wildcard-domains <filtersDir> <wildcardDomainsFile>
Arguments:
<filtersDir>
: Directory containing the filter files.<wildcardDomainsFile>
: Filename for the wildcard domains JSON.Example:
yarn update-wildcard-domains filters scripts/wildcard-domain-processor/wildcard_domains.json
Expand Wildcard Domains
This command processes platform filters and expands wildcard domains based on the previously generated map in the file wildcard_domains.json.
yarn expand-wildcard-domains <platformsDir> <wildcardDomainsFile>
Arguments:
<platformsDir>
: Directory containing the platform files.<wildcardDomainsFile>
: Filename for the wildcard domains JSON.Example:
yarn expand-wildcard-domains platforms scripts/wildcard-domain-processor/wildcard_domains.json
To see the help information for each command, you can use the -h
option:
Update Wildcard Domains Help:
yarn update-wildcard-domains -h
Expand Wildcard Domains Help:
yarn expand-wildcard-domains -h
These commands must be run from the root directory of the project, and the directories specified will be resolved relative to the current working directory.
Once a year, we will compress the repository to reduce its size. We will delete all remote branches and overwrite the master branch with a squashed history. The compression script will retain the first N commits in their original order in the history. All other commits (except the first one) will be squashed into a single commit.
Squash all old commits
yarn install
yarn compress [commits_to_keep]
It will retain the first [commits_to_keep] (default is 10,000, which is approximately one year of history) commits, starting from now, in their original order in the history. All other older commits (except the very first one) will be squashed into a single commit.
Overwrite master branch:
git push --set-upstream origin --force master
List all remote branches:
git ls-remote --heads origin
Remove Remote Branches: Remove remote branches that are no longer needed locally and push the removal to the remote repository:
git push origin --delete branchName
Replace `branchName`` with the name of the branch you want to delete.
Prune Remote Branches: Use git remote prune origin to remove references to remote branches that have been deleted on the remote repository. This keeps your local repository in sync with the remote.
git remote prune origin
Clean the Reflog: Over time, Git can accumulate references in the reflog that are no longer needed. You can clean the reflog using the following command:
git reflog expire --expire=now --all
git gc --aggressive --prune=now
This will remove unnecessary entries from the reflog and perform garbage collection.
After this procedure git repository will reduce it's size.