Manifest V3 Subscriptions
MV3 subscriptions
EWE keeps track of filter lists through subscriptions.. With the introduction of Manifest V3 (MV3), all extensions must define filtering rules in a specific format that's incompatible with eyeo's filter list format.
Filter lists have to be converted to rulesets, then, which are referenced in the extension manifest file. With MV3, both rulesets and subscriptions must be bundled and distributed together within the extension.
On this page, you'll learn about how subscription lists work, how to convert them to rulesets, and how to add custom subscriptions.
Subscription list basics
A subscription list is a JSON file with information that defines the subscription's details and where it should be fetched from.
The following example shows the EasyList subscription list:
Subscriptions
A filter list is a text file with filtering rules, referenced by its URL or ID in subscription lists. In Manifest V2, a subscription consisted mostly of filter list in a specific format:
DNR rules and rulesets
DNR rules are the filtering rule format used in Manifest V3. They are provided in ruleset files, which are formatted in JSON, as in the following example:
Manifest file changes
To filter network requests, rulesets have to be listed in the extension manifest file, as in the following example:
You may also need to make other changes to the manifest file. For more information, refer to the official Manifest V3 documentation.
Converting filter lists to DNR rulesets
Follow these steps to convert a filter list to a DNR ruleset:
Get at least one filter list.
(Optional:) Merge several filter lists into a single list.
Download filters.
Convert filters to DNR rules.
Add DNR ruleset information to the manifest file.
Command line scripts
Depending on your project's structure, your extension may need a separate, custom workflow. Several command-line scripts are available to help with this process.
These scripts are designed to run one after another, using the previous script's output as the following script's input, while allowing custom steps (like data transformation) between scripts to accommodate various workflows.
In the most common use case, where no specific requirements or changes are needed, the script's calls chain might look as follows:
subs-init
This script downloads default subscription list to given output file location. (The default subscription list is located at "https://easylist-downloads.adblockplus.org/v3/index.json"
.)
Usage:
Options:
output
/o
: Output file. Default:"scriptsOutput/subscriptions_mv3.json"
Example:
subs-merge
This script merges subscription lists. This is useful for workflows in which a main subscription list needs to be merged with a custom list.
If there is only one subscription list, this step can be skipped. If skipped, however, the subs-fetch
script won't work with default options, as it by default expects the output file of this script as input file.
Usage:
Options:
input
/i
: Input file(s). Default:"scriptsOutput/subscriptions_mv3.json"
output
/o
: Output file. Default:"scriptsOutput/custom-subscriptions.json"
space
/s
: Number of spaces to be used for indentation in the output file. Default:0
Example:
subs-fetch
This snippet downloads filter lists from the subscriptions defined in input files.
Usage:
Options:
input
/i
: Input file(s). Default:"scriptsOutput/custom-subscriptions.json"
output
/o
: Output directory. Default:"scriptsOutput/subscriptions"
ignoreFetchErrors
/ife
: Whether to ignore fetching errors. This is useful when download URL might be unreliable. Default:false
Example:
subs-convert
This snippet converts filter lists to rulesets. Conversion only applies to network request rules, that is, URL filters. Other filters will continue to be provided with the filter list files after this step.
Usage:
Options:
input
/i
: Input directory. Default:"scriptsOutput/subscriptions"
output
/o
: Output directory. Default:"scriptsOutput/rulesets"
report
/r
: Boolean flag. If this flag is passed the report is generated. You can also use--no-report
to force the report to not be generated. Default:false
report-output
/O
: Report directory. Default:"scriptsOutput/report"
Example:
subs-generate
This snippet generates web extension manifest fragment. Contents of this file must be added to the manifest file. See Manifest file changes for details.
Usage:
Options:
input
/i
: Input directory. Default:"scriptsOutput/rulesets"
output
/o
: Output file. Default:"scriptsOutput/rulesets/rulesets.json"
prefix
/p
: Prefix text to be used in the fragment. (This is mainly used for specifying the path.) Default:""
Example:
For convenience and testing purposes, running npm run build
will automatically run the previous scripts to create a meaningful subset of data used in our tests.
Custom subscriptions list
The default provided subscriptions can be overridden by adding a file called custom-subscriptions.json
in the scriptsOutput
directory and then using the following command: npm run subs-merge -- [-i ...] -o $(pwd)/scriptsOutput/custom-subscriptions.json
to merge the files.
Note the following:
use
-i
argument to add a file to the list of input files if necessaryone can use
$(pwd)
on nix-based environments or../../custom-subscriptions.json
for convenienceBy default these scripts output ruleset files into a folder called
scriptsOutput/rulesets
and the full subscription files intoscriptsOutput/subscriptions
.
Examples:
merge product-specific subscriptions file with default subscriptions:
merge two subscriptions files:
The scripts are also available via npm symlinks:
Adding subscriptions
Before subscriptions are added, availability of subscriptions (that are added in manifest file) through the Solution has to be checked:
Then, subscriptions can be added using their URLs:
To check which subscriptions are added and available:
Last updated