@adguard/dnr-converter 1.0.0-alpha.2 → 1.1.0

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/dist/cli.cjs CHANGED
@@ -30,7 +30,7 @@ function _interopNamespaceDefault(e) {
30
30
 
31
31
  var v__namespace = /*#__PURE__*/_interopNamespaceDefault(v);
32
32
 
33
- var version = "1.0.0-alpha.2";
33
+ var version = "1.1.0";
34
34
 
35
35
  /**
36
36
  * Version of the `@adguard/dnr-converter` package.
@@ -654,7 +654,7 @@ var version = "1.0.0-alpha.2";
654
654
  });
655
655
 
656
656
  /*
657
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
657
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
658
658
  * (c) 2026 Adguard Software Ltd.
659
659
  * Released under the MIT license
660
660
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -680,7 +680,7 @@ var version = "1.0.0-alpha.2";
680
680
  }
681
681
 
682
682
  /*
683
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
683
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
684
684
  * (c) 2026 Adguard Software Ltd.
685
685
  * Released under the MIT license
686
686
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -802,7 +802,7 @@ var version = "1.0.0-alpha.2";
802
802
  };
803
803
 
804
804
  /*
805
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
805
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
806
806
  * (c) 2026 Adguard Software Ltd.
807
807
  * Released under the MIT license
808
808
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -872,7 +872,7 @@ var version = "1.0.0-alpha.2";
872
872
  };
873
873
 
874
874
  /*
875
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
875
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
876
876
  * (c) 2026 Adguard Software Ltd.
877
877
  * Released under the MIT license
878
878
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -914,7 +914,7 @@ const BASE_MESSAGE = 'Not implemented';
914
914
  }
915
915
 
916
916
  /*
917
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
917
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
918
918
  * (c) 2026 Adguard Software Ltd.
919
919
  * Released under the MIT license
920
920
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -934,7 +934,7 @@ const BASE_MESSAGE = 'Not implemented';
934
934
  });
935
935
 
936
936
  /*
937
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
937
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
938
938
  * (c) 2026 Adguard Software Ltd.
939
939
  * Released under the MIT license
940
940
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -949,7 +949,7 @@ const SPACE = ' ';
949
949
  const TAB$1 = '\t';
950
950
  const COLON = ':';
951
951
  const COMMA = ',';
952
- const DOT = '.';
952
+ const DOT$1 = '.';
953
953
  const SEMICOLON = ';';
954
954
  const AMPERSAND = '&';
955
955
  const ASTERISK = '*';
@@ -1729,7 +1729,7 @@ const DOUBLE_QUOTE_MARKER = '"';
1729
1729
  }
1730
1730
 
1731
1731
  /*
1732
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
1732
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
1733
1733
  * (c) 2026 Adguard Software Ltd.
1734
1734
  * Released under the MIT license
1735
1735
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -4477,7 +4477,7 @@ function requireSprintf () {
4477
4477
  var sprintfExports = requireSprintf();
4478
4478
 
4479
4479
  /*
4480
- * CSSTokenizer v1.2.0 (build date: Tue, 14 Jul 2026 18:55:51 GMT)
4480
+ * CSSTokenizer v1.2.0 (build date: Wed, 29 Jul 2026 07:19:42 GMT)
4481
4481
  * (c) 2026 Adguard Software Ltd.
4482
4482
  * Released under the MIT license
4483
4483
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/css-tokenizer#readme
@@ -6074,7 +6074,7 @@ const XPATH_HASH = 196571984; // getStringHash('xpath')
6074
6074
  };
6075
6075
 
6076
6076
  /*
6077
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
6077
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
6078
6078
  * (c) 2026 Adguard Software Ltd.
6079
6079
  * Released under the MIT license
6080
6080
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -6088,7 +6088,7 @@ const XPATH_HASH = 196571984; // getStringHash('xpath')
6088
6088
  };
6089
6089
 
6090
6090
  /*
6091
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
6091
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
6092
6092
  * (c) 2026 Adguard Software Ltd.
6093
6093
  * Released under the MIT license
6094
6094
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -6179,7 +6179,7 @@ const XPATH_HASH = 196571984; // getStringHash('xpath')
6179
6179
  */ const REMOVE_VALUE = 'true';
6180
6180
 
6181
6181
  /*
6182
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
6182
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
6183
6183
  * (c) 2026 Adguard Software Ltd.
6184
6184
  * Released under the MIT license
6185
6185
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -8221,7 +8221,7 @@ const ERROR_MESSAGES$6 = {
8221
8221
  }
8222
8222
 
8223
8223
  /*
8224
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
8224
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
8225
8225
  * (c) 2026 Adguard Software Ltd.
8226
8226
  * Released under the MIT license
8227
8227
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -8519,7 +8519,7 @@ const ERROR_MESSAGES$6 = {
8519
8519
  break;
8520
8520
  }
8521
8521
  // Class selector ('.)
8522
- case DOT:
8522
+ case DOT$1:
8523
8523
  {
8524
8524
  ClassSelectorHandler.handle(context);
8525
8525
  break;
@@ -8830,7 +8830,7 @@ const ERROR_MESSAGES$6 = {
8830
8830
  }
8831
8831
 
8832
8832
  /*
8833
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
8833
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
8834
8834
  * (c) 2026 Adguard Software Ltd.
8835
8835
  * Released under the MIT license
8836
8836
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -23078,7 +23078,7 @@ function getDomain(url, options = {}) {
23078
23078
  *
23079
23079
  * @returns String representation of the class selector.
23080
23080
  */ static generate(node) {
23081
- return DOT + node.value;
23081
+ return DOT$1 + node.value;
23082
23082
  }
23083
23083
  }
23084
23084
 
@@ -23866,7 +23866,7 @@ function getDomain(url, options = {}) {
23866
23866
  }
23867
23867
 
23868
23868
  /*
23869
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
23869
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
23870
23870
  * (c) 2026 Adguard Software Ltd.
23871
23871
  * Released under the MIT license
23872
23872
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -23887,7 +23887,7 @@ function getDomain(url, options = {}) {
23887
23887
  }
23888
23888
 
23889
23889
  /*
23890
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
23890
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
23891
23891
  * (c) 2026 Adguard Software Ltd.
23892
23892
  * Released under the MIT license
23893
23893
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -23935,7 +23935,7 @@ function getDomain(url, options = {}) {
23935
23935
  };
23936
23936
 
23937
23937
  /*
23938
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
23938
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
23939
23939
  * (c) 2026 Adguard Software Ltd.
23940
23940
  * Released under the MIT license
23941
23941
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -24318,7 +24318,7 @@ const GenericPlatform = {
24318
24318
  }
24319
24319
 
24320
24320
  /*
24321
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
24321
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
24322
24322
  * (c) 2026 Adguard Software Ltd.
24323
24323
  * Released under the MIT license
24324
24324
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -42362,7 +42362,7 @@ var cloneDeep = /*@__PURE__*/getDefaultExportFromCjs(cloneDeepExports);
42362
42362
  }
42363
42363
 
42364
42364
  /*
42365
- * AGTree v4.1.1 (build date: Tue, 14 Jul 2026 18:56:22 GMT)
42365
+ * AGTree v4.2.0 (build date: Wed, 29 Jul 2026 07:20:04 GMT)
42366
42366
  * (c) 2026 Adguard Software Ltd.
42367
42367
  * Released under the MIT license
42368
42368
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -42956,7 +42956,7 @@ var GlobToRegExp = /*@__PURE__*/getDefaultExportFromCjs(globToRegexpExports);
42956
42956
  */ // Special RegExp constants
42957
42957
  const REGEX_START = CARET; // '^'
42958
42958
  const REGEX_END = DOLLAR_SIGN; // '$'
42959
- const REGEX_ANY_CHARACTERS = DOT + ASTERISK; // '.*'
42959
+ const REGEX_ANY_CHARACTERS = DOT$1 + ASTERISK; // '.*'
42960
42960
  // Special adblock pattern symbols and their RegExp equivalents
42961
42961
  const ADBLOCK_URL_START = PIPE + PIPE; // '||'
42962
42962
  const ADBLOCK_URL_START_REGEX = '^(http|https|ws|wss)://([a-z0-9-_.]+\\.)?';
@@ -42978,7 +42978,7 @@ const REGEX_NEGATION_SUFFIX = ').)*$';
42978
42978
  CLOSE_PARENTHESIS,
42979
42979
  CLOSE_SQUARE_BRACKET,
42980
42980
  DOLLAR_SIGN,
42981
- DOT,
42981
+ DOT$1,
42982
42982
  ESCAPE_CHARACTER,
42983
42983
  OPEN_CURLY_BRACKET,
42984
42984
  OPEN_PARENTHESIS,
@@ -44549,6 +44549,12 @@ const ADG_PREVENT_FETCH_WILDCARD = '*';
44549
44549
  const UBO_NO_FETCH_IF_WILDCARD = '/^/';
44550
44550
  const UBO_REMOVE_CLASS_NAME = 'remove-class.js';
44551
44551
  const UBO_REMOVE_ATTR_NAME = 'remove-attr.js';
44552
+ const UBO_JSON_PRUNE_FETCH_RESPONSE_NAME = 'json-prune-fetch-response.js';
44553
+ const UBO_JSON_PRUNE_XHR_RESPONSE_NAME = 'json-prune-xhr-response.js';
44554
+ const UBO_PRUNE_RESPONSE_PROPS_TO_MATCH_KEY = 'propsToMatch';
44555
+ const UBO_PRUNE_RESPONSE_STACK_TO_MATCH_KEY = 'stackToMatch';
44556
+ const ADG_PRUNE_FETCH_RESPONSE_NAME = UBO_JSON_PRUNE_FETCH_RESPONSE_NAME.slice(0, -UBO_SCRIPTLET_JS_SUFFIX_LENGTH);
44557
+ const ADG_PRUNE_XHR_RESPONSE_NAME = UBO_JSON_PRUNE_XHR_RESPONSE_NAME.slice(0, -UBO_SCRIPTLET_JS_SUFFIX_LENGTH);
44552
44558
  const setConstantAdgToUboMap = {
44553
44559
  [ADG_SET_CONSTANT_EMPTY_STRING]: UBO_SET_CONSTANT_EMPTY_STRING,
44554
44560
  [ADG_SET_CONSTANT_EMPTY_ARRAY]: UBO_SET_CONSTANT_EMPTY_ARRAY,
@@ -44663,6 +44669,11 @@ const REMOVE_ATTR_CLASS_APPLYING = new Set([
44663
44669
  });
44664
44670
  }
44665
44671
  }
44672
+ // Remap uBO prune-response scriptlet key/value args into ADG positional slots.
44673
+ // https://github.com/AdguardTeam/FiltersCompiler/issues/250
44674
+ if (scriptletData) {
44675
+ ScriptletRuleConverter.remapUboPruneResponseArgs(scriptletClone, scriptletData);
44676
+ }
44666
44677
  }
44667
44678
  // ADG scriptlet parameters should be quoted, and single quoted are preferred
44668
44679
  setScriptletQuoteType(scriptletClone, QuoteType.Single);
@@ -44832,6 +44843,10 @@ const REMOVE_ATTR_CLASS_APPLYING = new Set([
44832
44843
  return value;
44833
44844
  });
44834
44845
  break;
44846
+ case ADG_PRUNE_FETCH_RESPONSE_NAME:
44847
+ case ADG_PRUNE_XHR_RESPONSE_NAME:
44848
+ ScriptletRuleConverter.remapAdgToUboPruneResponseArgs(scriptletClone);
44849
+ break;
44835
44850
  }
44836
44851
  convertedScriptlets.push(scriptletClone);
44837
44852
  }
@@ -44880,6 +44895,138 @@ const REMOVE_ATTR_CLASS_APPLYING = new Set([
44880
44895
  return res;
44881
44896
  }), true);
44882
44897
  }
44898
+ /**
44899
+ * Remaps uBO key/value args of `json-prune-fetch-response` and
44900
+ * `json-prune-xhr-response` into AdGuard positional argument slots.
44901
+ *
44902
+ * These uBO variants accept only two positional args (`propsToRemove`,
44903
+ * `obligatoryProps`); args 3+ are key/value pairs parsed by uBO's
44904
+ * `getExtraArgs` (even index = key, odd index = value). Recognized keys:
44905
+ * `propsToMatch`, `stackToMatch`. ADG's equivalents use positional
44906
+ * `propsToMatch` (arg 3) and `stack` (arg 4), so the pairs are remapped into
44907
+ * positional slots. Unknown keys are dropped, because uBO ignores keys it
44908
+ * does not read and they cannot be mapped to an ADG positional slot. When a
44909
+ * recognized key repeats, the last value wins.
44910
+ *
44911
+ * Besides remapping arguments, this method also sets the scriptlet node's
44912
+ * name to the AdGuard native name (the uBO canonical name without the
44913
+ * `.js` suffix). This overrides the `ubo-` prefix that `convertToAdg`
44914
+ * adds earlier in its main flow for these two scriptlets, so the final
44915
+ * output uses the native AdGuard name with positional argument semantics.
44916
+ *
44917
+ * @see https://github.com/AdguardTeam/FiltersCompiler/issues/250
44918
+ *
44919
+ * @param scriptletClone Cloned scriptlet node to remap in place.
44920
+ * @param scriptletData Compatibility data for the matched uBO scriptlet.
44921
+ */ static remapUboPruneResponseArgs(scriptletClone, scriptletData) {
44922
+ // Only the two prune-response scriptlets need key/value → positional remapping.
44923
+ if (scriptletData.name !== UBO_JSON_PRUNE_FETCH_RESPONSE_NAME && scriptletData.name !== UBO_JSON_PRUNE_XHR_RESPONSE_NAME) {
44924
+ return;
44925
+ }
44926
+ const propsToRemove = scriptletClone.children[1]?.value ?? EMPTY;
44927
+ const obligatoryProps = scriptletClone.children[2]?.value ?? EMPTY;
44928
+ // Whether the source had an explicit 2nd positional arg (children[2]).
44929
+ const hadObligatoryProps = scriptletClone.children.length > 2;
44930
+ let propsToMatch = EMPTY;
44931
+ let stack = EMPTY;
44932
+ const unknownKeys = [];
44933
+ // Varargs start at index 3 (children[0] is the scriptlet name).
44934
+ for(let i = 3; i < scriptletClone.children.length; i += 2){
44935
+ const key = scriptletClone.children[i]?.value ?? EMPTY;
44936
+ const val = scriptletClone.children[i + 1]?.value ?? EMPTY;
44937
+ if (key === UBO_PRUNE_RESPONSE_PROPS_TO_MATCH_KEY) {
44938
+ propsToMatch = val;
44939
+ } else if (key === UBO_PRUNE_RESPONSE_STACK_TO_MATCH_KEY) {
44940
+ stack = val;
44941
+ } else if (key !== EMPTY) {
44942
+ // Unknown keys are dropped: uBO ignores keys it does not read,
44943
+ // and they cannot be mapped to an ADG positional slot.
44944
+ unknownKeys.push(key);
44945
+ }
44946
+ }
44947
+ if (unknownKeys.length > 0) {
44948
+ // eslint-disable-next-line no-console
44949
+ console.warn(`[agtree] Dropped unknown extra args for ${scriptletData.name}: ${unknownKeys.join(', ')}`);
44950
+ }
44951
+ // Translate to the ADG native name (uBO canonical name without the
44952
+ // `.js` suffix): the arguments are now in ADG positional semantics.
44953
+ const adgName = scriptletData.name.slice(0, -UBO_SCRIPTLET_JS_SUFFIX_LENGTH);
44954
+ setScriptletName(scriptletClone, adgName);
44955
+ // Rebuild children: name, propsToRemove, then the obligatoryProps,
44956
+ // propsToMatch and stack slots. `obligatoryProps` is emitted only when
44957
+ // it was present in the source or when a positional propsToMatch/stack
44958
+ // slot follows, so the output never gains a trailing empty arg the
44959
+ // source never had.
44960
+ // eslint-disable-next-line no-param-reassign
44961
+ scriptletClone.children = [
44962
+ scriptletClone.children[0],
44963
+ {
44964
+ type: 'Value',
44965
+ value: propsToRemove
44966
+ }
44967
+ ];
44968
+ if (hadObligatoryProps || propsToMatch !== EMPTY || stack !== EMPTY) {
44969
+ scriptletClone.children.push({
44970
+ type: 'Value',
44971
+ value: obligatoryProps
44972
+ });
44973
+ }
44974
+ if (propsToMatch !== EMPTY || stack !== EMPTY) {
44975
+ scriptletClone.children.push({
44976
+ type: 'Value',
44977
+ value: propsToMatch
44978
+ });
44979
+ }
44980
+ if (stack !== EMPTY) {
44981
+ scriptletClone.children.push({
44982
+ type: 'Value',
44983
+ value: stack
44984
+ });
44985
+ }
44986
+ }
44987
+ /**
44988
+ * Inverse of {@link ScriptletRuleConverter.remapUboPruneResponseArgs}:
44989
+ * remaps AdGuard positional `propsToMatch`/`stack` args of
44990
+ * `json-prune-fetch-response` / `json-prune-xhr-response` back into uBO
44991
+ * key/value pairs (`propsToMatch`, `stackToMatch`).
44992
+ *
44993
+ * `children` layout (AdGuard, before this method): `[name, propsToRemove,
44994
+ * obligatoryProps, propsToMatch, stack]`. `propsToMatch` and `stack` are
44995
+ * optional; empty values are not re-emitted, so the output never has
44996
+ * trailing empty key/value pairs. ADG rules that already use the
44997
+ * `ubo-`-prefixed name keep key/value args and are not handled here (they
44998
+ * take the `ubo-` prefix branch in `convertToUbo`, not this `switch`).
44999
+ *
45000
+ * @param scriptletClone Cloned scriptlet node to remap in place.
45001
+ */ static remapAdgToUboPruneResponseArgs(scriptletClone) {
45002
+ // Read the positional propsToMatch/stack before truncating children.
45003
+ const propsToMatchVal = scriptletClone.children[3]?.value;
45004
+ const stackVal = scriptletClone.children[4]?.value;
45005
+ // Keep the name and the two positional args; drop the positional
45006
+ // propsToMatch/stack slots — they are re-emitted as uBO key/value pairs.
45007
+ // eslint-disable-next-line no-param-reassign
45008
+ scriptletClone.children = scriptletClone.children.slice(0, Math.min(3, scriptletClone.children.length));
45009
+ if (propsToMatchVal && propsToMatchVal !== EMPTY) {
45010
+ scriptletClone.children.push({
45011
+ type: 'Value',
45012
+ value: UBO_PRUNE_RESPONSE_PROPS_TO_MATCH_KEY
45013
+ });
45014
+ scriptletClone.children.push({
45015
+ type: 'Value',
45016
+ value: propsToMatchVal
45017
+ });
45018
+ }
45019
+ if (stackVal && stackVal !== EMPTY) {
45020
+ scriptletClone.children.push({
45021
+ type: 'Value',
45022
+ value: UBO_PRUNE_RESPONSE_STACK_TO_MATCH_KEY
45023
+ });
45024
+ scriptletClone.children.push({
45025
+ type: 'Value',
45026
+ value: stackVal
45027
+ });
45028
+ }
45029
+ }
44883
45030
  }
44884
45031
 
44885
45032
  /**
@@ -45604,6 +45751,9 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
45604
45751
  * This is a wildcard character. It is used to represent "any set of characters".
45605
45752
  * This can also be an empty string or a string of any length.
45606
45753
  */ const MASK_ANY_CHARACTER = '*';
45754
+ /**
45755
+ * Dot character, used as a domain label separator.
45756
+ */ const DOT = '.';
45607
45757
  /**
45608
45758
  * Space character.
45609
45759
  */ const SPACE_CHARACTER = ' ';
@@ -46105,6 +46255,9 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
46105
46255
  * Weight for `$important` modifier (Category 7).
46106
46256
  */ RulePriority.CATEGORY_SEVEN_WEIGHT = 1000000;
46107
46257
 
46258
+ /**
46259
+ * Separator used in network-rule modifier domain lists (`$domain=a|b`).
46260
+ */ const DOMAIN_LIST_PIPE_SEPARATOR = '|';
46108
46261
  /**
46109
46262
  * Maps canonical content-type modifier names to their DNR `ResourceType`
46110
46263
  * equivalents. Only modifier names that correspond to adblock filter syntax
@@ -46411,6 +46564,32 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
46411
46564
  isRequest
46412
46565
  };
46413
46566
  }
46567
+ /**
46568
+ * Parses a pipe-separated domain list, keeping `/regex/` tokens intact
46569
+ * (so `|` inside a regexp is not treated as a domain separator).
46570
+ *
46571
+ * @param value Raw `$domain` / `$to` / `$denyallow` modifier value.
46572
+ *
46573
+ * @returns Permitted and restricted domain lists.
46574
+ */ static parseDomainList(value) {
46575
+ const permitted = [];
46576
+ const restricted = [];
46577
+ const node = DomainListParser.parse(value, undefined, 0, DOMAIN_LIST_PIPE_SEPARATOR);
46578
+ for (const { exception, value: domain } of node.children){
46579
+ if (!domain) {
46580
+ continue;
46581
+ }
46582
+ if (exception) {
46583
+ restricted.push(domain);
46584
+ } else {
46585
+ permitted.push(domain);
46586
+ }
46587
+ }
46588
+ return {
46589
+ permitted,
46590
+ restricted
46591
+ };
46592
+ }
46414
46593
  /**
46415
46594
  * Parses the `$header` modifier value into an {@link HttpHeaderMatcher}.
46416
46595
  *
@@ -46758,16 +46937,7 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
46758
46937
  }
46759
46938
  case OPTION_NAMES.DOMAIN:
46760
46939
  {
46761
- const parts = value.split('|').filter(Boolean);
46762
- const permitted = [];
46763
- const restricted = [];
46764
- for (const part of parts){
46765
- if (part.startsWith('~')) {
46766
- restricted.push(part.slice(1));
46767
- } else {
46768
- permitted.push(part);
46769
- }
46770
- }
46940
+ const { permitted, restricted } = Rule.parseDomainList(value);
46771
46941
  if (permitted.length > 0) {
46772
46942
  this.permittedDomains = permitted;
46773
46943
  meta.permittedDomainCount = permitted.length;
@@ -46780,33 +46950,24 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
46780
46950
  }
46781
46951
  case OPTION_NAMES.DENYALLOW:
46782
46952
  {
46783
- const parts = value.split('|').filter(Boolean);
46784
- if (parts.some((p)=>p.startsWith('~'))) {
46785
- throw new SyntaxError('Modifier $denyallow domains cannot be negated');
46953
+ const { permitted, restricted } = Rule.parseDomainList(value);
46954
+ if (restricted.length > 0) {
46955
+ throw new SyntaxError('modifier $denyallow domains cannot be negated');
46786
46956
  }
46787
- if (parts.length > 0) {
46788
- this.denyAllowDomains = parts;
46957
+ if (permitted.length > 0) {
46958
+ this.denyAllowDomains = permitted;
46789
46959
  meta.baseModifierCount += 1;
46790
46960
  }
46791
46961
  break;
46792
46962
  }
46793
46963
  case OPTION_NAMES.TO:
46794
46964
  {
46795
- const parts = value.split('|').filter(Boolean);
46796
- const toPermitted = [];
46797
- const toRestricted = [];
46798
- for (const part of parts){
46799
- if (part.startsWith('~')) {
46800
- toRestricted.push(part.slice(1));
46801
- } else {
46802
- toPermitted.push(part);
46803
- }
46804
- }
46805
- if (toPermitted.length > 0) {
46806
- this.permittedToDomains = toPermitted;
46965
+ const { permitted, restricted } = Rule.parseDomainList(value);
46966
+ if (permitted.length > 0) {
46967
+ this.permittedToDomains = permitted;
46807
46968
  }
46808
- if (toRestricted.length > 0) {
46809
- this.restrictedToDomains = toRestricted;
46969
+ if (restricted.length > 0) {
46970
+ this.restrictedToDomains = restricted;
46810
46971
  }
46811
46972
  meta.baseModifierCount += 1;
46812
46973
  break;
@@ -46850,6 +47011,7 @@ const CSP_SEPARATOR = SEMICOLON + SPACE;
46850
47011
  case OPTION_NAMES.HLS:
46851
47012
  case OPTION_NAMES.REFERRERPOLICY:
46852
47013
  case OPTION_NAMES.PERMISSIONS:
47014
+ case OPTION_NAMES.URLTRANSFORM:
46853
47015
  this.enabledModifiers.add(name);
46854
47016
  this.advancedModifierName = rawName;
46855
47017
  this.advancedModifierValue = value || null;
@@ -50570,7 +50732,7 @@ var redirectsMap = {
50570
50732
  "googletagmanager-gtm": "google-analytics.js",
50571
50733
  "ubo-googletagmanager_gtm.js": "google-analytics.js",
50572
50734
  "googletagmanager_gtm.js": "google-analytics.js",
50573
- "google-ima3-dai": "google-ima3-dai.ts",
50735
+ "google-ima3-dai": "google-ima3-dai.js",
50574
50736
  "google-ima3": "google-ima3.js",
50575
50737
  "ubo-google-ima.js": "google-ima3.js",
50576
50738
  "google-ima.js": "google-ima3.js",
@@ -50597,12 +50759,6 @@ var redirectsMap = {
50597
50759
  "prebid-ads.js": "prebid-ads.js",
50598
50760
  prebid: "prebid.js",
50599
50761
  "prevent-bab": "prevent-bab.js",
50600
- "nobab.js": "prevent-bab.js",
50601
- "ubo-nobab.js": "prevent-bab.js",
50602
- "bab-defuser.js": "prevent-bab.js",
50603
- "ubo-bab-defuser.js": "prevent-bab.js",
50604
- "ubo-nobab": "prevent-bab.js",
50605
- "ubo-bab-defuser": "prevent-bab.js",
50606
50762
  "prevent-bab2": "prevent-bab2.js",
50607
50763
  "nobab2.js": "prevent-bab2.js",
50608
50764
  "prevent-fab-3.2.0": "prevent-fab-3.2.0.js",
@@ -50627,6 +50783,195 @@ var getRedirectFilename = function getRedirectFilename(name) {
50627
50783
  return redirectsMap[name];
50628
50784
  };
50629
50785
 
50786
+ /**
50787
+ * Popular TLD suffixes used to expand wildcard TLD domains for DNR.
50788
+ *
50789
+ * Source: manually curated from the IANA Root Zone Database
50790
+ * (https://www.iana.org/domains/root/db). "Popular" means broad practical
50791
+ * coverage for filter rules: common generic TLDs, commonly registered ccTLDs,
50792
+ * common new gTLDs, and TLDs observed in AdGuard filter domain modifiers. This
50793
+ * is not a ranked list or a full public suffix list; update it manually when
50794
+ * wildcard TLD coverage needs to change.
50795
+ *
50796
+ * Keep values lowercase, ASCII, and without a leading dot.
50797
+ */ const POPULAR_TLDS = [
50798
+ 'ac',
50799
+ 'ae',
50800
+ 'agency',
50801
+ 'ai',
50802
+ 'am',
50803
+ 'app',
50804
+ 'ar',
50805
+ 'art',
50806
+ 'at',
50807
+ 'au',
50808
+ 'az',
50809
+ 'bd',
50810
+ 'be',
50811
+ 'bg',
50812
+ 'biz',
50813
+ 'blog',
50814
+ 'br',
50815
+ 'by',
50816
+ 'ca',
50817
+ 'cam',
50818
+ 'cc',
50819
+ 'center',
50820
+ 'cfd',
50821
+ 'ch',
50822
+ 'cl',
50823
+ 'click',
50824
+ 'cloud',
50825
+ 'club',
50826
+ 'cn',
50827
+ 'co',
50828
+ 'co.in',
50829
+ 'co.jp',
50830
+ 'co.kr',
50831
+ 'co.nz',
50832
+ 'co.uk',
50833
+ 'com',
50834
+ 'com.au',
50835
+ 'com.br',
50836
+ 'com.cn',
50837
+ 'com.mx',
50838
+ 'com.pl',
50839
+ 'com.tr',
50840
+ 'com.ua',
50841
+ 'company',
50842
+ 'cz',
50843
+ 'de',
50844
+ 'dev',
50845
+ 'digital',
50846
+ 'dk',
50847
+ 'edu',
50848
+ 'ee',
50849
+ 'eg',
50850
+ 'email',
50851
+ 'es',
50852
+ 'eu',
50853
+ 'fi',
50854
+ 'fm',
50855
+ 'fr',
50856
+ 'fun',
50857
+ 'ge',
50858
+ 'gg',
50859
+ 'gov',
50860
+ 'gr',
50861
+ 'group',
50862
+ 'hk',
50863
+ 'hr',
50864
+ 'hu',
50865
+ 'icu',
50866
+ 'id',
50867
+ 'ie',
50868
+ 'il',
50869
+ 'im',
50870
+ 'in',
50871
+ 'info',
50872
+ 'ink',
50873
+ 'int',
50874
+ 'io',
50875
+ 'ir',
50876
+ 'is',
50877
+ 'it',
50878
+ 'jobs',
50879
+ 'jp',
50880
+ 'ke',
50881
+ 'kr',
50882
+ 'kz',
50883
+ 'la',
50884
+ 'li',
50885
+ 'life',
50886
+ 'link',
50887
+ 'live',
50888
+ 'lk',
50889
+ 'lol',
50890
+ 'lt',
50891
+ 'lu',
50892
+ 'lv',
50893
+ 'ma',
50894
+ 'md',
50895
+ 'me',
50896
+ 'media',
50897
+ 'mil',
50898
+ 'mobi',
50899
+ 'mx',
50900
+ 'my',
50901
+ 'name',
50902
+ 'net',
50903
+ 'net.au',
50904
+ 'network',
50905
+ 'news',
50906
+ 'ng',
50907
+ 'nl',
50908
+ 'no',
50909
+ 'np',
50910
+ 'nu',
50911
+ 'nz',
50912
+ 'one',
50913
+ 'onion',
50914
+ 'online',
50915
+ 'org',
50916
+ 'org.uk',
50917
+ 'pe',
50918
+ 'ph',
50919
+ 'pk',
50920
+ 'pl',
50921
+ 'plus',
50922
+ 'porn',
50923
+ 'pro',
50924
+ 'pt',
50925
+ 'pub',
50926
+ 'pw',
50927
+ 'ro',
50928
+ 'rs',
50929
+ 'ru',
50930
+ 'sa',
50931
+ 'sbs',
50932
+ 'se',
50933
+ 'sg',
50934
+ 'shop',
50935
+ 'si',
50936
+ 'site',
50937
+ 'sk',
50938
+ 'software',
50939
+ 'solutions',
50940
+ 'space',
50941
+ 'store',
50942
+ 'su',
50943
+ 'sx',
50944
+ 'systems',
50945
+ 'tech',
50946
+ 'th',
50947
+ 'to',
50948
+ 'today',
50949
+ 'tokyo',
50950
+ 'top',
50951
+ 'tr',
50952
+ 'travel',
50953
+ 'tube',
50954
+ 'tv',
50955
+ 'tw',
50956
+ 'ua',
50957
+ 'uk',
50958
+ 'us',
50959
+ 'video',
50960
+ 'vip',
50961
+ 'vn',
50962
+ 'website',
50963
+ 'wiki',
50964
+ 'win',
50965
+ 'work',
50966
+ 'world',
50967
+ 'ws',
50968
+ 'xn--p1ai',
50969
+ 'xxx',
50970
+ 'xyz',
50971
+ 'za',
50972
+ 'zone'
50973
+ ];
50974
+
50630
50975
  /**
50631
50976
  * Options for {@link chrome.declarativeNetRequest.isRegexSupported}.
50632
50977
  */ /**
@@ -50702,6 +51047,54 @@ var getRedirectFilename = function getRedirectFilename(name) {
50702
51047
  * {@link RegularRuleConverter.convertRule} and {@link RegularRuleConverter.groupConvertedRules}
50703
51048
  * methods, which contains the general logic of transformation and grouping of rules.
50704
51049
  */ class RegularRuleConverter {
51050
+ /**
51051
+ * Checks whether a domain uses wildcard TLD syntax.
51052
+ *
51053
+ * @param domain Domain to check.
51054
+ *
51055
+ * @returns True when domain ends with `.*` and has a non-empty prefix.
51056
+ */ static isWildcardTldDomain(domain) {
51057
+ return domain.length > RegularRuleConverter.WILDCARD_TLD.length && domain.endsWith(RegularRuleConverter.WILDCARD_TLD);
51058
+ }
51059
+ /**
51060
+ * Expands wildcard TLD domain into concrete popular TLD domains.
51061
+ *
51062
+ * @param domain Wildcard TLD domain.
51063
+ *
51064
+ * @returns Expanded domain list.
51065
+ */ static expandWildcardTldDomain(domain) {
51066
+ const domainPrefix = domain.slice(0, -RegularRuleConverter.WILDCARD_TLD.length);
51067
+ return POPULAR_TLDS.map((tld)=>`${domainPrefix}.${tld}`);
51068
+ }
51069
+ /**
51070
+ * Prepares domains for DNR condition arrays.
51071
+ *
51072
+ * Regex and non-TLD wildcard domains are not representable in DNR and are
51073
+ * dropped; wildcard TLD domains (e.g. `example.*`) are expanded to the
51074
+ * popular TLD list.
51075
+ *
51076
+ * @param domains Domains from network rule modifier.
51077
+ *
51078
+ * @returns ASCII-only unique domains supported by DNR.
51079
+ */ static prepareDeclarativeDomains(domains) {
51080
+ const expandedDomains = domains?.flatMap((domain)=>{
51081
+ if (isRegexPattern(domain)) {
51082
+ return [];
51083
+ }
51084
+ if (RegularRuleConverter.isWildcardTldDomain(domain)) {
51085
+ return RegularRuleConverter.expandWildcardTldDomain(domain);
51086
+ }
51087
+ if (domain.includes(MASK_ANY_CHARACTER)) {
51088
+ return [];
51089
+ }
51090
+ return [
51091
+ domain
51092
+ ];
51093
+ }) ?? [];
51094
+ return [
51095
+ ...new Set(toASCII(expandedDomains))
51096
+ ];
51097
+ }
50705
51098
  /**
50706
51099
  * Checks if {@link Rule} can be converted to {@link RuleActionType.AllowAllRequests}.
50707
51100
  *
@@ -51059,28 +51452,28 @@ var getRedirectFilename = function getRedirectFilename(name) {
51059
51452
  condition.domainType = DomainType.FirstParty;
51060
51453
  }
51061
51454
  // set `initiatorDomains`
51062
- const permittedDomains = rule.permittedDomains?.filter((domain)=>!domain.includes(MASK_ANY_CHARACTER) && !isRegexPattern(domain));
51063
- if (permittedDomains && permittedDomains.length > 0) {
51064
- condition.initiatorDomains = toASCII(permittedDomains);
51455
+ const permittedDomains = RegularRuleConverter.prepareDeclarativeDomains(rule.permittedDomains);
51456
+ if (permittedDomains.length > 0) {
51457
+ condition.initiatorDomains = permittedDomains;
51065
51458
  }
51066
51459
  // set `excludedInitiatorDomains`
51067
- const excludedDomains = rule.restrictedDomains;
51068
- if (excludedDomains && excludedDomains.length > 0) {
51069
- condition.excludedInitiatorDomains = toASCII(excludedDomains);
51460
+ const excludedDomains = RegularRuleConverter.prepareDeclarativeDomains(rule.restrictedDomains);
51461
+ if (excludedDomains.length > 0) {
51462
+ condition.excludedInitiatorDomains = excludedDomains;
51070
51463
  }
51071
51464
  // set `requestDomains`
51072
- const { permittedToDomains } = rule;
51073
- if (permittedToDomains && permittedToDomains.length > 0) {
51074
- condition.requestDomains = toASCII(permittedToDomains);
51465
+ const permittedToDomains = RegularRuleConverter.prepareDeclarativeDomains(rule.permittedToDomains);
51466
+ if (permittedToDomains.length > 0) {
51467
+ condition.requestDomains = permittedToDomains;
51075
51468
  }
51076
51469
  // Can be specified `$to` or `$denyallow`, but not together.
51077
- const { denyAllowDomains } = rule;
51078
- const { restrictedToDomains } = rule;
51470
+ const denyAllowDomains = RegularRuleConverter.prepareDeclarativeDomains(rule.denyAllowDomains);
51471
+ const restrictedToDomains = RegularRuleConverter.prepareDeclarativeDomains(rule.restrictedToDomains);
51079
51472
  // set `excludedRequestDomains`
51080
- if (denyAllowDomains && denyAllowDomains.length !== 0) {
51081
- condition.excludedRequestDomains = toASCII(denyAllowDomains);
51082
- } else if (restrictedToDomains && restrictedToDomains.length !== 0) {
51083
- condition.excludedRequestDomains = toASCII(restrictedToDomains);
51473
+ if (denyAllowDomains.length !== 0) {
51474
+ condition.excludedRequestDomains = denyAllowDomains;
51475
+ } else if (restrictedToDomains.length !== 0) {
51476
+ condition.excludedRequestDomains = restrictedToDomains;
51084
51477
  }
51085
51478
  // set `excludedResourceTypes`
51086
51479
  const { restrictedResourceTypes } = rule;
@@ -51137,7 +51530,7 @@ var getRedirectFilename = function getRedirectFilename(name) {
51137
51530
  * And if we specify {@link ResourceType.MainFrame}, then we also need to specify all
51138
51531
  * other types, so that it works not only for document requests, but
51139
51532
  * also for all other types of requests.
51140
- */ const shouldMatchAllResourcesTypes = rule.isModifierEnabled(OPTION_NAMES.REMOVEHEADER) || rule.isModifierEnabled(OPTION_NAMES.CSP) || rule.isModifierEnabled(OPTION_NAMES.COOKIE) || rule.isModifierEnabled(OPTION_NAMES.TO) || rule.isModifierEnabled(OPTION_NAMES.METHOD);
51533
+ */ const shouldMatchAllResourcesTypes = rule.isModifierEnabled(OPTION_NAMES.REMOVEHEADER) || rule.isModifierEnabled(OPTION_NAMES.CSP) || rule.isModifierEnabled(OPTION_NAMES.COOKIE) || rule.isModifierEnabled(OPTION_NAMES.TO) || rule.isModifierEnabled(OPTION_NAMES.METHOD) || rule.isModifierEnabled(OPTION_NAMES.URLTRANSFORM);
51141
51534
  /**
51142
51535
  * `$permissions` and `$removeparam` modifiers must be applied only to `document` content-type
51143
51536
  * ({@link ResourceType.MainFrame} and {@link ResourceType.SubFrame}) if they don't have resource types.
@@ -51460,6 +51853,9 @@ var getRedirectFilename = function getRedirectFilename(name) {
51460
51853
  * Pipe character used as a separator in $removeparam multi-value rules,
51461
51854
  * e.g. `$removeparam=utm_source|utm_medium`.
51462
51855
  */ RegularRuleConverter.PIPE_SEPARATOR = '|';
51856
+ /**
51857
+ * Wildcard TLD suffix (`.*`) used in domain modifiers, e.g. `example.*`.
51858
+ */ RegularRuleConverter.WILDCARD_TLD = `${DOT}${MASK_ANY_CHARACTER}`;
51463
51859
 
51464
51860
  /**
51465
51861
  * Keyword for Base64 decode transform.
@@ -51629,13 +52025,20 @@ var getRedirectFilename = function getRedirectFilename(name) {
51629
52025
  if (workPattern.startsWith('^')) {
51630
52026
  workPattern = workPattern.substring(1);
51631
52027
  }
51632
- // Check for end-of-string anchor (\$ in filter syntax, which
51633
- // becomes $ in regex). When present, we must NOT append the
51634
- // remainder-capturing group (.*) after the pattern.
52028
+ // Check for end-of-string anchor. It may be written either as `\$`
52029
+ // (escaped, because `$` is the modifier separator in AdGuard syntax)
52030
+ // or as a bare `$` when the modifier value is the last one in the rule.
52031
+ // Both forms mean the same regex end-of-string anchor. When present,
52032
+ // we must NOT append the remainder-capturing group `(.*)` after the
52033
+ // pattern — otherwise the anchor would end up in the middle of the
52034
+ // resulting regex, producing a rule that never matches.
51635
52035
  let hasEndAnchor = false;
51636
52036
  if (workPattern.endsWith('\\$')) {
51637
52037
  hasEndAnchor = true;
51638
52038
  workPattern = workPattern.substring(0, workPattern.length - 2);
52039
+ } else if (workPattern.endsWith('$')) {
52040
+ hasEndAnchor = true;
52041
+ workPattern = workPattern.substring(0, workPattern.length - 1);
51639
52042
  }
51640
52043
  const userGroupCount = countCaptureGroups(workPattern);
51641
52044
  // Determine if this is a query-targeting pattern