Skip to content

AdguardTeam/FiltersCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Atlassian Bamboo
Aug 22, 2023
798a2f1 · Aug 22, 2023
Jul 24, 2023
Nov 8, 2022
Jul 24, 2023
Mar 9, 2023
Aug 22, 2023
Jun 3, 2022
Mar 1, 2023
Jul 17, 2020
Jun 3, 2022
Aug 22, 2023
Feb 2, 2018
Aug 30, 2022
Nov 8, 2022
Feb 1, 2023
Aug 22, 2023
Jun 23, 2023
Aug 22, 2023

Repository files navigation

AG Filters

What is AdGuard?

Filters compiler package

Usage

This package is suggested to be used with filters repository with directory structure presented in tests here.

The package could be run with the following command:

 const whitelist = [1, 3];
 const blacklist = [2];

 const path = require('path');
 const compiler = require("adguard-filters-compiler");

 const filtersDir = path.join(__dirname, './filters');
 const logPath = path.join(__dirname, './log.txt');
 const reportPath = path.join(__dirname, './report.txt');

 const platformsPath = path.join(__dirname, './platforms');

 const customPlatformsConfig = {
    // Here you can redefine some of the platforms from platforms.json
    // or add new platforms if you need it.
    "MAC_V3": {
        "platform": "mac",
        "path": "mac_v3",
        "configuration": {
            "ignoreRuleHints": false,
            "removeRulePatterns": [
                "^\\/.*" // remove regex rules for some reason.
            ],
            "replacements": [
                {
                    "from": "regex",
                    "to": "repl"
                }
            ]
        },
        "defines": {
            "adguard": true,
            "adguard_app_mac": true
        }
    },
 };

 compiler.compile(filtersDir, logPath, reportPath, platformsPath, whitelist, blacklist, customPlatformsConfig);

Tests

 yarn test

Development

In order to add support for new scriptlets and redirects, you should update @adguard/tsurlfilter with updated scriptlets.

For fixing scriptlets converting or validation you should update scriptlets.

Filters metadata

Check the filters metadata information description here