From 2a02638dbf1546925a1eb2b31a972efa25c36904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Wr=C3=B3blewski?= Date: Wed, 8 May 2024 14:50:48 +0300 Subject: [PATCH] Update modifiers compatibility table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit 2ad793fbfdd2a90a5bf90fbd6834c94472a2211a Author: Adam Wróblewski Date: Wed May 8 12:03:48 2024 +0200 Update `$to` modifier commit c8a7d67e101a32216cd417040eb65b04d8589cba Author: Adam Wróblewski Date: Wed May 8 11:53:09 2024 +0200 Rename defined variable to common_props commit ba6622d82feb1272d4b2b00127f94973a6973d51 Author: Adam Wróblewski Date: Wed May 8 11:42:18 2024 +0200 Use re-useable blocks commit 1fa6ad2e9cca18f56272f57045e0852028d5d993 Author: Adam Wróblewski Date: Wed May 8 10:11:14 2024 +0200 Update modifiers compatibility table `$to` modifier is now supported by AdGuard `$replace` modifier is supported by uBlock Origin for Firefox --- .../scripts/check-compatibility-tables.ts | 3 ++ .../modifiers/replace.yml | 47 +++++-------------- .../src/compatibility-tables/modifiers/to.yml | 27 ++++++++--- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/packages/agtree/scripts/check-compatibility-tables.ts b/packages/agtree/scripts/check-compatibility-tables.ts index 94311b469..4edbab567 100644 --- a/packages/agtree/scripts/check-compatibility-tables.ts +++ b/packages/agtree/scripts/check-compatibility-tables.ts @@ -250,6 +250,9 @@ for (const [globPattern, schema] of Object.entries(SCHEMA_MAP)) { // In order to avoid type errors, we need to cast the schema to 'Struct'. // It is safe to do so because we don't use create()'s return value. // TODO: Better way to do this? Is it necessary? + if (typeof data === 'object' && data !== null && 'define' in data) { + delete data.define; + } ss.create(data, schema as ss.Struct); } catch (error: unknown) { if (error instanceof Error) { diff --git a/packages/agtree/src/compatibility-tables/modifiers/replace.yml b/packages/agtree/src/compatibility-tables/modifiers/replace.yml index 5c226fa71..32c702952 100644 --- a/packages/agtree/src/compatibility-tables/modifiers/replace.yml +++ b/packages/agtree/src/compatibility-tables/modifiers/replace.yml @@ -1,9 +1,7 @@ -adg_os_any: - name: replace +define: &common_props description: |- This modifier completely changes the rule behavior. If it is applied, the rule will not block the request. The response is going to be modified instead. - docs: https://adguard.app/kb/general/ad-filtering/create-own-filters/#replace-modifier conflicts: - app - domain @@ -35,38 +33,17 @@ adg_os_any: ([gimuy]*)? $ +adg_os_any: + name: replace + docs: https://adguard.app/kb/general/ad-filtering/create-own-filters/#replace-modifier + <<: *common_props + adg_ext_firefox: name: replace - description: |- - This modifier completely changes the rule behavior. - If it is applied, the rule will not block the request. The response is going to be modified instead. docs: https://adguard.app/kb/general/ad-filtering/create-own-filters/#replace-modifier - conflicts: - - domain - - document - - subdocument - - script - - stylesheet - - other - - xmlhttprequest - - first-party - - third-party - - important - - badfilter - inverse_conflicts: true - assignable: true - negatable: false - value_format: |- - (?xi) - ^ - \/ - # the regexp to match by - (.+) - # separator - \/ - # replacement - (.+)? - \/ - # flags - ([gimuy]*)? - $ + <<: *common_props + +ubo_ext_firefox: + name: replace + docs: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#replace + <<: *common_props diff --git a/packages/agtree/src/compatibility-tables/modifiers/to.yml b/packages/agtree/src/compatibility-tables/modifiers/to.yml index 999705709..833ac1af2 100644 --- a/packages/agtree/src/compatibility-tables/modifiers/to.yml +++ b/packages/agtree/src/compatibility-tables/modifiers/to.yml @@ -1,12 +1,27 @@ -# TODO: add adg_os_any after CoreLibs 1.13 release -# https://adguard.app/kb/general/ad-filtering/create-own-filters/#to-modifier +define: + - &common_props + name: to + conflicts: + - denyallow + assignable: true + negatable: false + value_format: pipe_separated_domains + - &common_adg_props + <<: *common_props + description: |- + `$to` limits the rule scope to requests made to the specified domains and their subdomains. + To add multiple domains to one rule, use the `|` character as a separator. + docs: https://adguard.com/kb/general/ad-filtering/create-own-filters/#to-modifier + +adg_os_any: + <<: *common_adg_props + +adg_ext_any: + <<: *common_adg_props ubo_ext_any: - name: to + <<: *common_props description: |- The main motivation of this option is to give static network filtering engine an equivalent of DNR's `requestDomains` and `excludedRequestDomains`. docs: https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#to - assignable: true - negatable: false - value_format: pipe_separated_domains