@adguard/agtree 4.0.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/ast-utils/clone.js +12 -8
- package/dist/ast-utils/modifiers.js +13 -11
- package/dist/ast-utils/network-rules.js +10 -9
- package/dist/ast-utils/scriptlets.js +20 -18
- package/dist/common/abp-snippet-injection-body-common.js +1 -1
- package/dist/common/agent-common.js +1 -1
- package/dist/common/ubo-html-filtering-body-common.js +1 -1
- package/dist/common/ubo-selector-common.js +1 -1
- package/dist/compatibility-tables/base.js +7 -6
- package/dist/compatibility-tables/compatibility-table-data.js +1 -1
- package/dist/compatibility-tables/modifiers.js +4 -3
- package/dist/compatibility-tables/platforms.js +1 -1
- package/dist/compatibility-tables/redirects.js +4 -4
- package/dist/compatibility-tables/schemas/base.js +2 -2
- package/dist/compatibility-tables/schemas/modifier.js +4 -4
- package/dist/compatibility-tables/schemas/platform.js +3 -2
- package/dist/compatibility-tables/schemas/redirect.js +1 -1
- package/dist/compatibility-tables/schemas/resource-type.js +1 -1
- package/dist/compatibility-tables/schemas/scriptlet.js +1 -1
- package/dist/compatibility-tables/scriptlets.js +2 -2
- package/dist/compatibility-tables/utils/platform-helpers.js +6 -4
- package/dist/compatibility-tables/utils/resource-type-helpers.js +1 -1
- package/dist/compatibility-tables/utils/zod-camelcase.js +3 -3
- package/dist/converter/base-interfaces/base-converter.js +22 -16
- package/dist/converter/base-interfaces/conversion-result.js +15 -11
- package/dist/converter/base-interfaces/rule-converter-base.js +19 -13
- package/dist/converter/comment/index.js +11 -9
- package/dist/converter/cosmetic/css.js +12 -10
- package/dist/converter/cosmetic/element-hiding.js +12 -10
- package/dist/converter/cosmetic/header-removal.js +16 -13
- package/dist/converter/cosmetic/html.js +18 -18
- package/dist/converter/cosmetic/index.js +28 -24
- package/dist/converter/cosmetic/rule-modifiers/adg.js +15 -12
- package/dist/converter/cosmetic/rule-modifiers/ubo.js +22 -19
- package/dist/converter/cosmetic/scriptlet.js +26 -22
- package/dist/converter/css/index.js +13 -11
- package/dist/converter/data/css.js +8 -8
- package/dist/converter/filter-list.js +12 -10
- package/dist/converter/index.js +1 -1
- package/dist/converter/misc/network-rule-modifier.js +20 -16
- package/dist/converter/network/index.js +16 -12
- package/dist/converter/raw-filter-list.js +12 -10
- package/dist/converter/raw-rule.js +14 -12
- package/dist/converter/rule.js +17 -13
- package/dist/errors/adblock-syntax-error.js +1 -1
- package/dist/errors/not-implemented-error.js +2 -2
- package/dist/errors/rule-conversion-error.js +2 -2
- package/dist/generator/base-generator.js +1 -1
- package/dist/generator/comment/agent-comment-generator.js +4 -3
- package/dist/generator/comment/agent-generator.js +5 -4
- package/dist/generator/comment/comment-rule-generator.js +6 -5
- package/dist/generator/comment/config-comment-generator.js +5 -4
- package/dist/generator/comment/hint-comment-generator.js +5 -4
- package/dist/generator/comment/hint-generator.js +4 -3
- package/dist/generator/comment/metadata-comment-generator.js +3 -2
- package/dist/generator/comment/pre-processor-comment-generator.js +6 -5
- package/dist/generator/comment/simple-comment-generator.js +3 -2
- package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +13 -11
- package/dist/generator/cosmetic/cosmetic-rule-generator.js +5 -4
- package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +7 -5
- package/dist/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.js +3 -3
- package/dist/generator/cosmetic/html-filtering-body/html-filtering-body-generator.js +1 -1
- package/dist/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.js +2 -2
- package/dist/generator/cosmetic/scriptlet-body/abp-snippet-injection-body-generator.js +7 -5
- package/dist/generator/cosmetic/scriptlet-body/adg-scriptlet-injection-body-generator.js +7 -5
- package/dist/generator/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-generator.js +8 -6
- package/dist/generator/cosmetic/selector/attribute-selector-generator.js +2 -2
- package/dist/generator/cosmetic/selector/class-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/complex-selector-generator.js +4 -4
- package/dist/generator/cosmetic/selector/id-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/pseudo-class-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/selector-combinator-generator.js +1 -1
- package/dist/generator/cosmetic/selector/selector-list-generator.js +1 -1
- package/dist/generator/cosmetic/selector/type-selector-generator.js +1 -1
- package/dist/generator/css/adg-css-injection-generator.js +5 -1
- package/dist/generator/filterlist-generator.js +5 -4
- package/dist/generator/index.js +1 -1
- package/dist/generator/misc/domain-list-generator.js +1 -1
- package/dist/generator/misc/list-items-generator.js +5 -3
- package/dist/generator/misc/logical-expression-generator.js +5 -4
- package/dist/generator/misc/modifier-generator.js +4 -3
- package/dist/generator/misc/modifier-list-generator.js +5 -4
- package/dist/generator/misc/parameter-list-generator.js +6 -5
- package/dist/generator/misc/value-generator.js +2 -1
- package/dist/generator/network/host-rule-generator.js +2 -1
- package/dist/generator/network/network-rule-generator.js +2 -1
- package/dist/generator/rule-generator.js +6 -4
- package/dist/index.js +1 -2
- package/dist/nodes/index.js +1 -1
- package/dist/package.json.js +2 -2
- package/dist/parser/base-parser.js +1 -1
- package/dist/parser/comment/agent-comment-parser.js +11 -9
- package/dist/parser/comment/agent-parser.js +12 -9
- package/dist/parser/comment/comment-parser.js +8 -7
- package/dist/parser/comment/config-comment-parser.js +9 -6
- package/dist/parser/comment/hint-comment-parser.js +17 -12
- package/dist/parser/comment/hint-parser.js +10 -7
- package/dist/parser/comment/metadata-comment-parser.js +9 -7
- package/dist/parser/comment/preprocessor-parser.js +14 -11
- package/dist/parser/comment/simple-comment-parser.js +5 -2
- package/dist/parser/cosmetic/cosmetic-rule-parser.js +29 -25
- package/dist/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.js +3 -3
- package/dist/parser/cosmetic/html-filtering-body/html-filtering-body-parser.js +4 -4
- package/dist/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.js +7 -7
- package/dist/parser/cosmetic/scriptlet-body/abp-snippet-injection-body-parser.js +12 -9
- package/dist/parser/cosmetic/scriptlet-body/adg-scriptlet-injection-body-parser.js +12 -9
- package/dist/parser/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-parser.js +11 -8
- package/dist/parser/cosmetic/selector/handlers/attribute-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/class-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/complex-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/compound-selector-handler.js +2 -2
- package/dist/parser/cosmetic/selector/handlers/id-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.js +5 -3
- package/dist/parser/cosmetic/selector/handlers/type-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/selector-list-parser.js +7 -7
- package/dist/parser/css/adg-css-injection-parser.js +4 -3
- package/dist/parser/css/balancing.js +22 -18
- package/dist/parser/css/constants.js +1 -1
- package/dist/parser/css/css-token-stream.js +15 -4
- package/dist/parser/css/ubo-selector-parser.js +8 -4
- package/dist/parser/filterlist-parser.js +8 -5
- package/dist/parser/index.js +1 -1
- package/dist/parser/misc/app-list-parser.js +4 -3
- package/dist/parser/misc/domain-list-parser.js +8 -6
- package/dist/parser/misc/list-items-parser.js +8 -6
- package/dist/parser/misc/logical-expression-parser.js +25 -18
- package/dist/parser/misc/method-list-parser.js +4 -3
- package/dist/parser/misc/modifier-list.js +3 -3
- package/dist/parser/misc/modifier-parser.js +5 -4
- package/dist/parser/misc/parameter-list-parser.js +6 -5
- package/dist/parser/misc/stealth-option-list-parser.js +4 -3
- package/dist/parser/misc/ubo-parameter-list-parser.js +10 -9
- package/dist/parser/misc/value-parser.js +2 -2
- package/dist/parser/network/host-rule-parser.js +15 -7
- package/dist/parser/network/network-rule-parser.js +11 -9
- package/dist/parser/options.js +1 -1
- package/dist/parser/rule-parser.js +11 -7
- package/dist/types/ast-utils/clone.d.ts +12 -8
- package/dist/types/ast-utils/filter-list.d.ts +5 -4
- package/dist/types/ast-utils/modifiers.d.ts +11 -9
- package/dist/types/ast-utils/network-rules.d.ts +8 -7
- package/dist/types/ast-utils/scriptlets.d.ts +19 -17
- package/dist/types/compatibility-tables/base.d.ts +6 -5
- package/dist/types/compatibility-tables/redirects.d.ts +1 -1
- package/dist/types/compatibility-tables/schemas/platform.d.ts +1 -0
- package/dist/types/compatibility-tables/utils/platform-helpers.d.ts +5 -3
- package/dist/types/compatibility-tables/utils/zod-camelcase.d.ts +3 -3
- package/dist/types/converter/base-interfaces/base-converter.d.ts +21 -15
- package/dist/types/converter/base-interfaces/conversion-result.d.ts +20 -16
- package/dist/types/converter/base-interfaces/rule-converter-base.d.ts +19 -13
- package/dist/types/converter/comment/index.d.ts +9 -7
- package/dist/types/converter/cosmetic/css.d.ts +9 -7
- package/dist/types/converter/cosmetic/element-hiding.d.ts +9 -7
- package/dist/types/converter/cosmetic/header-removal.d.ts +10 -7
- package/dist/types/converter/cosmetic/html.d.ts +9 -9
- package/dist/types/converter/cosmetic/index.d.ts +14 -10
- package/dist/types/converter/cosmetic/rule-modifiers/adg.d.ts +9 -6
- package/dist/types/converter/cosmetic/rule-modifiers/ubo.d.ts +9 -6
- package/dist/types/converter/cosmetic/scriptlet.d.ts +14 -10
- package/dist/types/converter/css/index.d.ts +9 -7
- package/dist/types/converter/data/css.d.ts +1 -1
- package/dist/types/converter/filter-list.d.ts +10 -8
- package/dist/types/converter/index.d.ts +1 -1
- package/dist/types/converter/misc/network-rule-modifier.d.ts +13 -9
- package/dist/types/converter/network/index.d.ts +15 -11
- package/dist/types/converter/raw-filter-list.d.ts +8 -6
- package/dist/types/converter/raw-rule.d.ts +8 -6
- package/dist/types/converter/rule.d.ts +14 -10
- package/dist/types/errors/not-implemented-error.d.ts +1 -1
- package/dist/types/errors/rule-conversion-error.d.ts +1 -1
- package/dist/types/generator/comment/agent-comment-generator.d.ts +3 -2
- package/dist/types/generator/comment/agent-generator.d.ts +4 -3
- package/dist/types/generator/comment/comment-rule-generator.d.ts +3 -2
- package/dist/types/generator/comment/config-comment-generator.d.ts +4 -3
- package/dist/types/generator/comment/hint-comment-generator.d.ts +4 -3
- package/dist/types/generator/comment/hint-generator.d.ts +3 -2
- package/dist/types/generator/comment/metadata-comment-generator.d.ts +1 -0
- package/dist/types/generator/comment/pre-processor-comment-generator.d.ts +3 -2
- package/dist/types/generator/comment/simple-comment-generator.d.ts +2 -1
- package/dist/types/generator/cosmetic/cosmetic-rule-body-generator.d.ts +7 -5
- package/dist/types/generator/cosmetic/cosmetic-rule-generator.d.ts +3 -2
- package/dist/types/generator/cosmetic/cosmetic-rule-pattern-generator.d.ts +4 -2
- package/dist/types/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.d.ts +1 -1
- package/dist/types/generator/cosmetic/html-filtering-body/html-filtering-body-generator.d.ts +1 -1
- package/dist/types/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.d.ts +2 -2
- package/dist/types/generator/cosmetic/scriptlet-body/abp-snippet-injection-body-generator.d.ts +5 -3
- package/dist/types/generator/cosmetic/scriptlet-body/adg-scriptlet-injection-body-generator.d.ts +5 -3
- package/dist/types/generator/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-generator.d.ts +7 -5
- package/dist/types/generator/css/adg-css-injection-generator.d.ts +4 -0
- package/dist/types/generator/css/ubo-selector-generator.d.ts +4 -3
- package/dist/types/generator/filterlist-generator.d.ts +3 -2
- package/dist/types/generator/misc/list-items-generator.d.ts +4 -2
- package/dist/types/generator/misc/logical-expression-generator.d.ts +4 -3
- package/dist/types/generator/misc/modifier-generator.d.ts +3 -2
- package/dist/types/generator/misc/modifier-list-generator.d.ts +4 -3
- package/dist/types/generator/misc/parameter-list-generator.d.ts +5 -4
- package/dist/types/generator/misc/value-generator.d.ts +1 -0
- package/dist/types/generator/network/host-rule-generator.d.ts +1 -0
- package/dist/types/generator/network/network-rule-generator.d.ts +1 -0
- package/dist/types/generator/rule-generator.d.ts +5 -3
- package/dist/types/index.d.ts +1 -2
- package/dist/types/nodes/index.d.ts +55 -54
- package/dist/types/parser/comment/agent-comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/agent-parser.d.ts +7 -4
- package/dist/types/parser/comment/comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/config-comment-parser.d.ts +5 -2
- package/dist/types/parser/comment/hint-comment-parser.d.ts +11 -6
- package/dist/types/parser/comment/hint-parser.d.ts +6 -3
- package/dist/types/parser/comment/metadata-comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/preprocessor-parser.d.ts +9 -6
- package/dist/types/parser/comment/simple-comment-parser.d.ts +3 -0
- package/dist/types/parser/cosmetic/cosmetic-rule-parser.d.ts +9 -6
- package/dist/types/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.d.ts +3 -3
- package/dist/types/parser/cosmetic/html-filtering-body/html-filtering-body-parser.d.ts +4 -4
- package/dist/types/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.d.ts +4 -4
- package/dist/types/parser/cosmetic/scriptlet-body/abp-snippet-injection-body-parser.d.ts +8 -5
- package/dist/types/parser/cosmetic/scriptlet-body/adg-scriptlet-injection-body-parser.d.ts +9 -6
- package/dist/types/parser/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-parser.d.ts +8 -5
- package/dist/types/parser/cosmetic/selector/context.d.ts +2 -2
- package/dist/types/parser/cosmetic/selector/selector-list-parser.d.ts +2 -2
- package/dist/types/parser/css/adg-css-injection-parser.d.ts +1 -0
- package/dist/types/parser/css/balancing.d.ts +17 -12
- package/dist/types/parser/css/css-token-stream.d.ts +11 -0
- package/dist/types/parser/css/ubo-selector-parser.d.ts +3 -0
- package/dist/types/parser/filterlist-parser.d.ts +5 -2
- package/dist/types/parser/misc/app-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/domain-list-parser.d.ts +5 -3
- package/dist/types/parser/misc/list-items-parser.d.ts +5 -3
- package/dist/types/parser/misc/logical-expression-parser.d.ts +9 -5
- package/dist/types/parser/misc/method-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/modifier-list.d.ts +2 -1
- package/dist/types/parser/misc/modifier-parser.d.ts +2 -1
- package/dist/types/parser/misc/parameter-list-parser.d.ts +3 -2
- package/dist/types/parser/misc/stealth-option-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/ubo-parameter-list-parser.d.ts +2 -1
- package/dist/types/parser/misc/value-parser.d.ts +1 -1
- package/dist/types/parser/network/host-rule-parser.d.ts +10 -2
- package/dist/types/parser/network/network-rule-parser.d.ts +5 -3
- package/dist/types/parser/options.d.ts +1 -1
- package/dist/types/parser/rule-parser.d.ts +6 -2
- package/dist/types/tokenizer/tokenizer.d.ts +2 -2
- package/dist/types/utils/adblockers.d.ts +9 -6
- package/dist/types/utils/clone.d.ts +4 -3
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/cosmetic-rule-separator.d.ts +13 -10
- package/dist/types/utils/deep-freeze.d.ts +4 -4
- package/dist/types/utils/domain.d.ts +3 -2
- package/dist/types/utils/logical-expression.d.ts +9 -5
- package/dist/types/utils/multi-value-map.d.ts +3 -3
- package/dist/types/utils/position-provider.d.ts +3 -2
- package/dist/types/utils/quotes.d.ts +48 -42
- package/dist/types/utils/regexp.d.ts +24 -17
- package/dist/types/utils/string.d.ts +135 -103
- package/dist/types/utils/type-guards.d.ts +1 -0
- package/dist/types/validator/helpers.d.ts +1 -1
- package/dist/types/validator/index.d.ts +3 -3
- package/dist/types/version.d.ts +1 -1
- package/dist/utils/adblockers.js +10 -7
- package/dist/utils/bit-count.js +1 -1
- package/dist/utils/categorizer.js +2 -2
- package/dist/utils/clone.js +5 -4
- package/dist/utils/constants.js +2 -2
- package/dist/utils/cosmetic-rule-separator.js +15 -11
- package/dist/utils/deep-freeze.js +5 -5
- package/dist/utils/domain.js +4 -3
- package/dist/utils/error.js +3 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/logical-expression.js +10 -6
- package/dist/utils/multi-value-map.js +4 -4
- package/dist/utils/noop-modifier.js +1 -1
- package/dist/utils/position-provider.js +2 -1
- package/dist/utils/quotes.js +49 -43
- package/dist/utils/regexp.js +25 -18
- package/dist/utils/string.js +136 -104
- package/dist/utils/type-guards.js +2 -1
- package/dist/validator/constants.js +1 -1
- package/dist/validator/helpers.js +1 -1
- package/dist/validator/index.js +8 -8
- package/dist/validator/value.js +6 -6
- package/dist/version.js +2 -2
- package/package.json +3 -1
- package/dist/errors/binary-schema-mismatch-error.js +0 -37
- package/dist/types/errors/binary-schema-mismatch-error.d.ts +0 -23
|
@@ -1,35 +1,37 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { StringUtils } from '../../utils/string.js';
|
|
7
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
9
8
|
import { RuleCategory, CommentRuleType } from '../../nodes/index.js';
|
|
10
|
-
import { HintParser } from './hint-parser.js';
|
|
11
9
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { HINT_MARKER, OPEN_PARENTHESIS, BACKSLASH, CLOSE_PARENTHESIS, HINT_MARKER_LEN } from '../../utils/constants.js';
|
|
11
|
+
import { StringUtils } from '../../utils/string.js';
|
|
14
12
|
import { BaseParser } from '../base-parser.js';
|
|
13
|
+
import { defaultParserOptions } from '../options.js';
|
|
14
|
+
import { HintParser } from './hint-parser.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* `HintRuleParser` is responsible for parsing AdGuard hint rules.
|
|
18
18
|
*
|
|
19
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
|
|
20
|
+
*
|
|
19
21
|
* @example
|
|
20
22
|
* The following hint rule
|
|
21
23
|
* ```adblock
|
|
22
24
|
* !+ NOT_OPTIMIZED PLATFORM(windows)
|
|
23
25
|
* ```
|
|
24
26
|
* contains two hints: `NOT_OPTIMIZED` and `PLATFORM`.
|
|
25
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
|
|
26
27
|
*/
|
|
27
28
|
class HintCommentParser extends BaseParser {
|
|
28
29
|
/**
|
|
29
30
|
* Checks if the raw rule is a hint rule.
|
|
30
31
|
*
|
|
31
|
-
* @param raw Raw rule
|
|
32
|
-
*
|
|
32
|
+
* @param raw Raw rule.
|
|
33
|
+
*
|
|
34
|
+
* @returns `true` if the rule is a hint rule, `false` otherwise.
|
|
33
35
|
*/
|
|
34
36
|
static isHintRule(raw) {
|
|
35
37
|
return raw.trim().startsWith(HINT_MARKER);
|
|
@@ -37,12 +39,15 @@ class HintCommentParser extends BaseParser {
|
|
|
37
39
|
/**
|
|
38
40
|
* Parses a raw rule as a hint comment.
|
|
39
41
|
*
|
|
42
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints-1}
|
|
43
|
+
*
|
|
40
44
|
* @param raw Raw input to parse.
|
|
41
45
|
* @param options Global parser options.
|
|
42
46
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
43
|
-
*
|
|
44
|
-
* @
|
|
45
|
-
*
|
|
47
|
+
*
|
|
48
|
+
* @returns Hint AST or null (if the raw rule cannot be parsed as a hint comment).
|
|
49
|
+
*
|
|
50
|
+
* @throws If the input matches the HINT pattern but syntactically invalid.
|
|
46
51
|
*/
|
|
47
52
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
48
53
|
// Ignore non-hint rules
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
7
8
|
import { OPEN_PARENTHESIS, SPACE, UNDERSCORE, EMPTY, CLOSE_PARENTHESIS, COMMA } from '../../utils/constants.js';
|
|
8
9
|
import { StringUtils } from '../../utils/string.js';
|
|
9
|
-
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
10
|
-
import { ParameterListParser } from '../misc/parameter-list-parser.js';
|
|
11
|
-
import { defaultParserOptions } from '../options.js';
|
|
12
10
|
import { BaseParser } from '../base-parser.js';
|
|
11
|
+
import { ParameterListParser } from '../misc/parameter-list-parser.js';
|
|
13
12
|
import { ValueParser } from '../misc/value-parser.js';
|
|
13
|
+
import { defaultParserOptions } from '../options.js';
|
|
14
14
|
|
|
15
15
|
/* eslint-disable no-param-reassign */
|
|
16
16
|
/**
|
|
17
|
-
* @file AdGuard Hints
|
|
17
|
+
* @file AdGuard Hints.
|
|
18
|
+
*
|
|
18
19
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
|
|
19
20
|
*/
|
|
20
21
|
/**
|
|
@@ -36,8 +37,10 @@ class HintParser extends BaseParser {
|
|
|
36
37
|
* @param raw Raw input to parse.
|
|
37
38
|
* @param options Global parser options.
|
|
38
39
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
40
|
+
*
|
|
41
|
+
* @returns Hint rule AST or null.
|
|
42
|
+
*
|
|
43
|
+
* @throws If the syntax is invalid.
|
|
41
44
|
*/
|
|
42
45
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
43
46
|
let offset = 0;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { CommentMarker, RuleCategory, CommentRuleType } from '../../nodes/index.js';
|
|
8
8
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
9
9
|
import { COLON } from '../../utils/constants.js';
|
|
10
|
-
import {
|
|
11
|
-
import { defaultParserOptions } from '../options.js';
|
|
10
|
+
import { StringUtils } from '../../utils/string.js';
|
|
12
11
|
import { BaseParser } from '../base-parser.js';
|
|
13
12
|
import { ValueParser } from '../misc/value-parser.js';
|
|
13
|
+
import { defaultParserOptions } from '../options.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @file Metadata comments
|
|
16
|
+
* @file Metadata comments.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
19
|
* Set of known metadata headers. This helps to quickly identify and validate
|
|
@@ -37,6 +37,8 @@ const KNOWN_METADATA_HEADERS = new Set([
|
|
|
37
37
|
* `MetadataParser` is responsible for parsing metadata comments.
|
|
38
38
|
* Metadata comments are special comments that specify some properties of the list.
|
|
39
39
|
*
|
|
40
|
+
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#special-comments}
|
|
41
|
+
*
|
|
40
42
|
* @example
|
|
41
43
|
* For example, in the case of
|
|
42
44
|
* ```adblock
|
|
@@ -44,7 +46,6 @@ const KNOWN_METADATA_HEADERS = new Set([
|
|
|
44
46
|
* ```
|
|
45
47
|
* the name of the header is `Title`, and the value is `My List`, which means that
|
|
46
48
|
* the list title is `My List`, and it can be used in the adblocker UI.
|
|
47
|
-
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#special-comments}
|
|
48
49
|
*/
|
|
49
50
|
class MetadataCommentParser extends BaseParser {
|
|
50
51
|
/**
|
|
@@ -53,7 +54,8 @@ class MetadataCommentParser extends BaseParser {
|
|
|
53
54
|
* @param raw Raw input to parse.
|
|
54
55
|
* @param options Global parser options.
|
|
55
56
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
56
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* @returns Metadata comment AST or null (if the raw rule cannot be parsed as a metadata comment).
|
|
57
59
|
*/
|
|
58
60
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
59
61
|
// Fast check to avoid unnecessary work
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
8
|
+
import { RuleCategory, CommentRuleType } from '../../nodes/index.js';
|
|
7
9
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
8
10
|
import { PREPROCESSOR_MARKER, PREPROCESSOR_MARKER_LEN, HASHMARK, PREPROCESSOR_SEPARATOR, OPEN_PARENTHESIS, SAFARI_CB_AFFINITY, CLOSE_PARENTHESIS, COMMA, IF, INCLUDE } from '../../utils/constants.js';
|
|
9
11
|
import { StringUtils } from '../../utils/string.js';
|
|
10
|
-
import {
|
|
12
|
+
import { BaseParser } from '../base-parser.js';
|
|
11
13
|
import { LogicalExpressionParser } from '../misc/logical-expression-parser.js';
|
|
12
|
-
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
13
14
|
import { ParameterListParser } from '../misc/parameter-list-parser.js';
|
|
14
|
-
import { defaultParserOptions } from '../options.js';
|
|
15
|
-
import { BaseParser } from '../base-parser.js';
|
|
16
15
|
import { ValueParser } from '../misc/value-parser.js';
|
|
16
|
+
import { defaultParserOptions } from '../options.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Pre-processor directives
|
|
19
|
+
* Pre-processor directives.
|
|
20
20
|
*
|
|
21
21
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
22
22
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
@@ -27,6 +27,9 @@ import { ValueParser } from '../misc/value-parser.js';
|
|
|
27
27
|
* Please note that this parser only handles general syntax for now, and does not validate the parameters at
|
|
28
28
|
* the parsing stage.
|
|
29
29
|
*
|
|
30
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
31
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
32
|
+
*
|
|
30
33
|
* @example
|
|
31
34
|
* If your rule is
|
|
32
35
|
* ```adblock
|
|
@@ -34,15 +37,14 @@ import { ValueParser } from '../misc/value-parser.js';
|
|
|
34
37
|
* ```
|
|
35
38
|
* then the directive's name is `if` and its value is `(adguard)`, but the parameter list
|
|
36
39
|
* is not parsed / validated further.
|
|
37
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
38
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
39
40
|
*/
|
|
40
41
|
class PreProcessorCommentParser extends BaseParser {
|
|
41
42
|
/**
|
|
42
43
|
* Determines whether the rule is a pre-processor rule.
|
|
43
44
|
*
|
|
44
|
-
* @param raw Raw rule
|
|
45
|
-
*
|
|
45
|
+
* @param raw Raw rule.
|
|
46
|
+
*
|
|
47
|
+
* @returns `true` if the rule is a pre-processor rule, `false` otherwise.
|
|
46
48
|
*/
|
|
47
49
|
static isPreProcessorRule(raw) {
|
|
48
50
|
const trimmed = raw.trim();
|
|
@@ -55,8 +57,9 @@ class PreProcessorCommentParser extends BaseParser {
|
|
|
55
57
|
* @param raw Raw input to parse.
|
|
56
58
|
* @param options Global parser options.
|
|
57
59
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
60
|
+
*
|
|
58
61
|
* @returns
|
|
59
|
-
* Pre-processor comment AST or null (if the raw rule cannot be parsed as a pre-processor comment)
|
|
62
|
+
* Pre-processor comment AST or null (if the raw rule cannot be parsed as a pre-processor comment).
|
|
60
63
|
*/
|
|
61
64
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
62
65
|
// Ignore non-pre-processor rules
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { CommentMarker, CommentRuleType, RuleCategory } from '../../nodes/index.js';
|
|
7
8
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
8
9
|
import { CosmeticRuleSeparatorUtils } from '../../utils/cosmetic-rule-separator.js';
|
|
9
10
|
import { StringUtils } from '../../utils/string.js';
|
|
10
|
-
import { CommentMarker, CommentRuleType, RuleCategory } from '../../nodes/index.js';
|
|
11
11
|
import { BaseParser } from '../base-parser.js';
|
|
12
12
|
import { ValueParser } from '../misc/value-parser.js';
|
|
13
13
|
import { defaultParserOptions } from '../options.js';
|
|
@@ -29,7 +29,9 @@ class SimpleCommentParser extends BaseParser {
|
|
|
29
29
|
* Checks if the raw rule is a simple comment.
|
|
30
30
|
*
|
|
31
31
|
* @param raw Raw input to check.
|
|
32
|
+
*
|
|
32
33
|
* @returns `true` if the input is a simple comment, `false` otherwise.
|
|
34
|
+
*
|
|
33
35
|
* @note This method does not check for adblock agent comments.
|
|
34
36
|
*/
|
|
35
37
|
static isSimpleComment(raw) {
|
|
@@ -65,6 +67,7 @@ class SimpleCommentParser extends BaseParser {
|
|
|
65
67
|
* @param raw Raw input to parse.
|
|
66
68
|
* @param options Global parser options.
|
|
67
69
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
70
|
+
*
|
|
68
71
|
* @returns Comment rule node or null (if the raw rule cannot be parsed as a simple comment).
|
|
69
72
|
*/
|
|
70
73
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { sprintf } from 'sprintf-js';
|
|
8
7
|
import { hasToken, TokenType } from '@adguard/css-tokenizer';
|
|
9
|
-
import {
|
|
8
|
+
import { sprintf } from 'sprintf-js';
|
|
9
|
+
import { UboPseudoName } from '../../common/ubo-selector-common.js';
|
|
10
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
11
|
+
import { RuleCategory, CosmeticRuleType } from '../../nodes/index.js';
|
|
10
12
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
11
|
-
import { DomainListParser } from '../misc/domain-list-parser.js';
|
|
12
|
-
import { ModifierListParser } from '../misc/modifier-list.js';
|
|
13
13
|
import { OPEN_SQUARE_BRACKET, DOLLAR_SIGN, CLOSE_SQUARE_BRACKET, CSS_BLOCK_OPEN, CSS_BLOCK_CLOSE, UBO_SCRIPTLET_MASK, UBO_SCRIPTLET_MASK_LEGACY, ADG_SCRIPTLET_MASK, UBO_HTML_MASK } from '../../utils/constants.js';
|
|
14
|
-
import {
|
|
15
|
-
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
14
|
+
import { CosmeticRuleSeparatorUtils } from '../../utils/cosmetic-rule-separator.js';
|
|
16
15
|
import { StringUtils } from '../../utils/string.js';
|
|
16
|
+
import { BaseParser } from '../base-parser.js';
|
|
17
17
|
import { CommentParser } from '../comment/comment-parser.js';
|
|
18
|
-
import { defaultParserOptions } from '../options.js';
|
|
19
|
-
import { UboSelectorParser } from '../css/ubo-selector-parser.js';
|
|
20
18
|
import { AdgCssInjectionParser } from '../css/adg-css-injection-parser.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
19
|
+
import { UboSelectorParser } from '../css/ubo-selector-parser.js';
|
|
20
|
+
import { DomainListParser } from '../misc/domain-list-parser.js';
|
|
21
|
+
import { ModifierListParser } from '../misc/modifier-list.js';
|
|
22
|
+
import { defaultParserOptions } from '../options.js';
|
|
24
23
|
import { AdgHtmlFilteringBodyParser } from './html-filtering-body/adg-html-filtering-body-parser.js';
|
|
25
24
|
import { UboHtmlFilteringBodyParser } from './html-filtering-body/ubo-html-filtering-body-parser.js';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
25
|
+
import { AbpSnippetInjectionBodyParser } from './scriptlet-body/abp-snippet-injection-body-parser.js';
|
|
26
|
+
import { AdgScriptletInjectionBodyParser } from './scriptlet-body/adg-scriptlet-injection-body-parser.js';
|
|
27
|
+
import { UboScriptletInjectionBodyParser } from './scriptlet-body/ubo-scriptlet-injection-body-parser.js';
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Possible error messages for uBO selectors. Formatted with {@link sprintf}.
|
|
@@ -44,7 +44,7 @@ const ADG_CSS_INJECTION_PATTERN = /^(?:.+){(?:.+)}$/;
|
|
|
44
44
|
* Where possible, it automatically detects the difference between supported syntaxes:
|
|
45
45
|
* - AdGuard
|
|
46
46
|
* - uBlock Origin
|
|
47
|
-
* - Adblock Plus
|
|
47
|
+
* - Adblock Plus.
|
|
48
48
|
*
|
|
49
49
|
* If the syntax is common / cannot be determined, the parser gives `Common` syntax.
|
|
50
50
|
*
|
|
@@ -59,8 +59,9 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
59
59
|
* Determines whether a rule is a cosmetic rule. The rule is considered cosmetic if it
|
|
60
60
|
* contains a cosmetic rule separator.
|
|
61
61
|
*
|
|
62
|
-
* @param raw Raw rule
|
|
63
|
-
*
|
|
62
|
+
* @param raw Raw rule.
|
|
63
|
+
*
|
|
64
|
+
* @returns `true` if the rule is a cosmetic rule, `false` otherwise.
|
|
64
65
|
*/
|
|
65
66
|
static isCosmeticRule(raw) {
|
|
66
67
|
const trimmed = raw.trim();
|
|
@@ -73,14 +74,16 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
73
74
|
* Parses a cosmetic rule. The structure of the cosmetic rules:
|
|
74
75
|
* - pattern (AdGuard pattern can have modifiers, other syntaxes don't)
|
|
75
76
|
* - separator
|
|
76
|
-
* - body
|
|
77
|
+
* - body.
|
|
77
78
|
*
|
|
78
79
|
* @param raw Raw input to parse.
|
|
79
80
|
* @param options Global parser options.
|
|
80
81
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
82
|
+
*
|
|
81
83
|
* @returns
|
|
82
|
-
* Parsed cosmetic rule AST or null if it failed to parse based on the known cosmetic rules
|
|
83
|
-
*
|
|
84
|
+
* Parsed cosmetic rule AST or null if it failed to parse based on the known cosmetic rules.
|
|
85
|
+
*
|
|
86
|
+
* @throws If the input matches the cosmetic rule pattern but syntactically invalid.
|
|
84
87
|
*/
|
|
85
88
|
// TODO: Split to smaller functions
|
|
86
89
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
@@ -158,6 +161,10 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
158
161
|
* Ensures that the rule syntax is common or the expected one. This function is used to prevent mixing
|
|
159
162
|
* different syntaxes in the same rule.
|
|
160
163
|
*
|
|
164
|
+
* @param expectedSyntax Expected syntax.
|
|
165
|
+
*
|
|
166
|
+
* @throws If the rule syntax is not common or the expected one.
|
|
167
|
+
*
|
|
161
168
|
* @example
|
|
162
169
|
* The following rule mixes AdGuard and uBO syntaxes, because it uses AdGuard modifier list and uBO
|
|
163
170
|
* CSS injection:
|
|
@@ -166,9 +173,6 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
166
173
|
* ```
|
|
167
174
|
* In this case, parser sets syntax to AdGuard, because it detects the AdGuard modifier list, but
|
|
168
175
|
* when parsing the rule body, it detects uBO CSS injection, which is not compatible with AdGuard.
|
|
169
|
-
*
|
|
170
|
-
* @param expectedSyntax Expected syntax
|
|
171
|
-
* @throws If the rule syntax is not common or the expected one
|
|
172
176
|
*/
|
|
173
177
|
const expectCommonOrSpecificSyntax = (expectedSyntax) => {
|
|
174
178
|
if (syntax !== AdblockSyntax.Common && syntax !== expectedSyntax) {
|
|
@@ -313,9 +317,9 @@ class CosmeticRuleParser extends BaseParser {
|
|
|
313
317
|
};
|
|
314
318
|
/**
|
|
315
319
|
* Parses Adb CSS injection rules
|
|
316
|
-
* eg: example.com##.foo { display: none; }
|
|
320
|
+
* eg: example.com##.foo { display: none; }.
|
|
317
321
|
*
|
|
318
|
-
* @returns
|
|
322
|
+
* @returns Parsed rule.
|
|
319
323
|
*/
|
|
320
324
|
const parseAbpCssInjection = () => {
|
|
321
325
|
if (!options.parseAbpSpecificRules) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
@@ -13,12 +13,12 @@ import { HtmlFilteringBodyParser } from './html-filtering-body-parser.js';
|
|
|
13
13
|
* `AdgHtmlFilteringBodyParser` is responsible for parsing the body of an AdGuard-style HTML filtering rule.
|
|
14
14
|
*
|
|
15
15
|
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
16
|
-
* For example, it will parse this
|
|
16
|
+
* For example, it will parse this:.
|
|
17
17
|
* ```adblock
|
|
18
18
|
* example.com$$div[special-attr="value"]
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* But it didn't check if the attribute `special-attr` actually supported by any adblocker..
|
|
22
22
|
*
|
|
23
23
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
24
24
|
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
@@ -12,14 +12,14 @@ import { SelectorListParser } from '../selector/selector-list-parser.js';
|
|
|
12
12
|
* Class responsible for parsing HTML filtering rule body.
|
|
13
13
|
*
|
|
14
14
|
* Please note that the parser will parse any HTML filtering rule body if it is syntactically correct.
|
|
15
|
-
* For example, it will parse this
|
|
15
|
+
* For example, it will parse this:.
|
|
16
16
|
* ```adblock
|
|
17
17
|
* span[special-attr="Example"]
|
|
18
18
|
* div:special-pseudo(Example)
|
|
19
19
|
* ```
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* the attribute selector `special-attr` actually supported by any adblocker
|
|
21
|
+
* But it didn't check if the pseudo selector `special-pseudo` or if
|
|
22
|
+
* the attribute selector `special-attr` actually supported by any adblocker..
|
|
23
23
|
*
|
|
24
24
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
25
25
|
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
7
|
import { TokenType, getFormattedTokenName } from '@adguard/css-tokenizer';
|
|
8
8
|
import { sprintf } from 'sprintf-js';
|
|
9
|
+
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
10
|
+
import { UBO_RESPONSEHEADER_FN } from '../../../utils/constants.js';
|
|
9
11
|
import { BaseParser } from '../../base-parser.js';
|
|
10
12
|
import { CssTokenStream } from '../../css/css-token-stream.js';
|
|
11
|
-
import { defaultParserOptions } from '../../options.js';
|
|
12
|
-
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
13
13
|
import { ValueParser } from '../../misc/value-parser.js';
|
|
14
|
-
import {
|
|
14
|
+
import { defaultParserOptions } from '../../options.js';
|
|
15
15
|
import { HtmlFilteringBodyParser } from './html-filtering-body-parser.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -19,14 +19,14 @@ import { HtmlFilteringBodyParser } from './html-filtering-body-parser.js';
|
|
|
19
19
|
* an uBlock-style HTML filtering rule, and also uBlock-style response header removal rule.
|
|
20
20
|
*
|
|
21
21
|
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
22
|
-
* For example, it will parse this
|
|
22
|
+
* For example, it will parse this:.
|
|
23
23
|
* ```adblock
|
|
24
24
|
* example.com##^script:pseudo(content)
|
|
25
25
|
* example.com##^responseheader(header-name)
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
* the header name `header-name` actually supported by any adblocker
|
|
28
|
+
* But it didn't check if the pseudo selector `pseudo` or if
|
|
29
|
+
* the header name `header-name` actually supported by any adblocker..
|
|
30
30
|
*
|
|
31
31
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
32
32
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AbpSnippetInjectionBodyCommon } from '../../../common/abp-snippet-injection-body-common.js';
|
|
8
|
+
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
7
9
|
import { SEMICOLON, SPACE } from '../../../utils/constants.js';
|
|
8
10
|
import { StringUtils } from '../../../utils/string.js';
|
|
9
|
-
import {
|
|
11
|
+
import { BaseParser } from '../../base-parser.js';
|
|
10
12
|
import { ParameterListParser } from '../../misc/parameter-list-parser.js';
|
|
11
13
|
import { defaultParserOptions } from '../../options.js';
|
|
12
|
-
import { BaseParser } from '../../base-parser.js';
|
|
13
|
-
import { AbpSnippetInjectionBodyCommon } from '../../../common/abp-snippet-injection-body-common.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @file
|
|
16
|
+
* @file UBlock scriptlet injection body parser.
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
19
|
* `AbpSnippetInjectionBodyParser` is responsible for parsing the body of an Adblock Plus-style snippet rule.
|
|
20
20
|
*
|
|
21
21
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
22
|
-
* For example, it will parse this
|
|
22
|
+
* For example, it will parse this:.
|
|
23
23
|
* ```adblock
|
|
24
24
|
* example.com#$#snippet0 arg0
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* But it didn't check if the scriptlet `snippet0` actually supported by any adblocker..
|
|
28
28
|
*
|
|
29
29
|
* @see {@link https://help.eyeo.com/adblockplus/snippet-filters-tutorial}
|
|
30
30
|
*/
|
|
@@ -35,8 +35,11 @@ class AbpSnippetInjectionBodyParser extends BaseParser {
|
|
|
35
35
|
* @param raw Raw input to parse.
|
|
36
36
|
* @param options Global parser options.
|
|
37
37
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
38
|
+
*
|
|
39
|
+
* @returns Node of the parsed scriptlet call body.
|
|
40
|
+
*
|
|
41
|
+
* @throws If the body is syntactically incorrect.
|
|
42
|
+
*
|
|
40
43
|
* @example
|
|
41
44
|
* ```
|
|
42
45
|
* #$#snippet0 arg0
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
7
|
import { sprintf } from 'sprintf-js';
|
|
8
|
+
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
8
9
|
import { CLOSE_PARENTHESIS, OPEN_PARENTHESIS, ADG_SCRIPTLET_MASK, SPACE, ESCAPE_CHARACTER, COMMA, SINGLE_QUOTE, DOUBLE_QUOTE } from '../../../utils/constants.js';
|
|
9
10
|
import { StringUtils } from '../../../utils/string.js';
|
|
10
|
-
import {
|
|
11
|
-
import { defaultParserOptions } from '../../options.js';
|
|
11
|
+
import { isNull } from '../../../utils/type-guards.js';
|
|
12
12
|
import { BaseParser } from '../../base-parser.js';
|
|
13
13
|
import { ValueParser } from '../../misc/value-parser.js';
|
|
14
|
-
import {
|
|
14
|
+
import { defaultParserOptions } from '../../options.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @file AdGuard scriptlet injection body parser
|
|
17
|
+
* @file AdGuard scriptlet injection body parser.
|
|
18
18
|
*/
|
|
19
19
|
/**
|
|
20
20
|
* `AdgScriptletInjectionBodyParser` is responsible for parsing the body of an AdGuard-style scriptlet rule.
|
|
21
21
|
*
|
|
22
22
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
23
|
-
* For example, it will parse this
|
|
23
|
+
* For example, it will parse this:.
|
|
24
24
|
* ```adblock
|
|
25
25
|
* example.com#%#//scriptlet('scriptlet0', 'arg0')
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
-
*
|
|
28
|
+
* But it didn't check if the scriptlet `scriptlet0` actually supported by any adblocker..
|
|
29
29
|
*
|
|
30
30
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#scriptlets}
|
|
31
31
|
*/
|
|
@@ -49,8 +49,11 @@ class AdgScriptletInjectionBodyParser extends BaseParser {
|
|
|
49
49
|
* @param raw Raw input to parse.
|
|
50
50
|
* @param options Global parser options.
|
|
51
51
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
52
|
+
*
|
|
53
|
+
* @returns Node of the parsed scriptlet call body.
|
|
54
|
+
*
|
|
55
|
+
* @throws If the body is syntactically incorrect.
|
|
56
|
+
*
|
|
54
57
|
* @example
|
|
55
58
|
* ```
|
|
56
59
|
* //scriptlet('scriptlet0', 'arg0')
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
7
8
|
import { CLOSE_PARENTHESIS, OPEN_PARENTHESIS, UBO_SCRIPTLET_MASK, UBO_SCRIPTLET_MASK_LEGACY, SPACE, ESCAPE_CHARACTER, COMMA } from '../../../utils/constants.js';
|
|
8
9
|
import { StringUtils } from '../../../utils/string.js';
|
|
9
|
-
import { AdblockSyntaxError } from '../../../errors/adblock-syntax-error.js';
|
|
10
|
-
import { defaultParserOptions } from '../../options.js';
|
|
11
10
|
import { BaseParser } from '../../base-parser.js';
|
|
12
11
|
import { UboParameterListParser } from '../../misc/ubo-parameter-list-parser.js';
|
|
12
|
+
import { defaultParserOptions } from '../../options.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @file
|
|
15
|
+
* @file UBlock scriptlet injection body parser.
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
* `UboScriptletInjectionBodyParser` is responsible for parsing the body of a uBlock-style scriptlet rule.
|
|
19
19
|
*
|
|
20
20
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
21
|
-
* For example, it will parse this
|
|
21
|
+
* For example, it will parse this:.
|
|
22
22
|
* ```adblock
|
|
23
23
|
* example.com##+js(scriptlet0, arg0)
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* But it didn't check if the scriptlet `scriptlet0` actually supported by any adblocker..
|
|
27
27
|
*
|
|
28
28
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#scriptlet-injection}
|
|
29
29
|
*/
|
|
@@ -44,8 +44,11 @@ class UboScriptletInjectionBodyParser extends BaseParser {
|
|
|
44
44
|
* @param raw Raw input to parse.
|
|
45
45
|
* @param options Global parser options.
|
|
46
46
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
47
|
-
*
|
|
48
|
-
* @
|
|
47
|
+
*
|
|
48
|
+
* @returns Node of the parsed scriptlet call body.
|
|
49
|
+
*
|
|
50
|
+
* @throws If the body is syntactically incorrect.
|
|
51
|
+
*
|
|
49
52
|
* @example
|
|
50
53
|
* ```
|
|
51
54
|
* ##+js(scriptlet0, arg0)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|