From 7f734378aed323a953a7445192dd0a0ffe982bc3 Mon Sep 17 00:00:00 2001 From: Yuriy Selivanov Date: Tue, 14 Oct 2025 14:15:05 +0300 Subject: [PATCH 1/2] Added path-in-domain syntax --- .../ad-filtering/create-own-filters.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index 06975e04043..9c44f4b6cec 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3312,6 +3312,7 @@ The rules described in this section are created specifically for this purpose. | --- | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [Element hiding](#cosmetic-elemhide-rules) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | | [CSS rules](#cosmetic-css-rules) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| [Path-in-domain syntax](#cosmetic-path-in-domain) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | | [Extended CSS](#extended-css-selectors) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | | [HTML filtering](#html-filtering-rules) | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | | [JavaScript](#javascript-rules) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | @@ -3483,6 +3484,70 @@ example.org#@#body{remove:true;} ::: +### Path-in-domain syntax {#cosmetic-path-in-domain} + +AdGuard supports a simplified syntax for cosmetic rules that need to be applied only on specific paths of a website. Instead of using the `$path` modifier, you can specify the path directly in the domain part of the rule. + +**Syntax** + +```text +domain.com/path##selector +``` + +This is equivalent to: +```text +[$path=/path]domain.com##selector +``` + +**Examples** + +- `example.org/checkout##.promo-banner` — hides `.promo-banner` elements only on checkout pages +- `news.site.com/article##.sidebar-ad` — hides sidebar ads only on article pages +- `shop.com/product,~shop.com/product/reviews##.upsell` — hides upsell blocks on product pages but not on review pages + +**Multiple domains** + +Path-in-domain syntax works with multiple domains: +- `domain1.com,example.org/path##.banner` — applies to all pages on `domain1.com` and only `/path` pages on `example.org` + +**Regex domains** + +Path-in-domain syntax is also supported for regex domains: +- `/example\.org\/article\d+/##.ad` — hides ads on article pages with numeric IDs + +**All cosmetic rule types** + +Path-in-domain syntax works with all types of cosmetic rules: + +```adblock +! Element hiding +example.org/path##.banner + +! Element hiding exception +example.org/path#@#.banner + +! CSS injection +example.org/path#$#.banner { display: block !important; } + +! HTML filtering +example.org/path$$script[src*="ads"] + +! HTML filtering exception +example.org/path$@$script[src*="ads"] + +! JavaScript rules +example.org/path#%#//scriptlet('abort-on-property-read', 'ads') + +! JavaScript exception +example.org/path#@%#//scriptlet('abort-on-property-read', 'ads') +``` + +:::info Compatibility + +Path-in-domain syntax has been introduced in [CoreLibs] v1.21. + +::: + ### Extended CSS selectors {#extended-css-selectors} - [Limitations](#extended-css-limitations) @@ -4717,6 +4782,13 @@ Such rules with `$domain` modifier are supported by AdGuard for Windows, AdGuard `$path` modifier limits the rule application area to specific locations or pages on websites. +:::tip Alternative syntax + +For cosmetic rules, you can use a simplified [path-in-domain syntax](#cosmetic-path-in-domain) instead of the `$path` modifier: +- `example.org/path##.banner` instead of `[$path=/path]example.org##.banner` + +::: + **Syntax** ```text From 8437eb4be6bf95e2867a817153ad15b3e7ce058d Mon Sep 17 00:00:00 2001 From: Yuriy Selivanov Date: Tue, 14 Oct 2025 14:24:07 +0300 Subject: [PATCH 2/2] fix --- docs/general/ad-filtering/create-own-filters.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index 9c44f4b6cec..c0b0c571045 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3495,6 +3495,7 @@ domain.com/path##selector ``` This is equivalent to: + ```text [$path=/path]domain.com##selector ``` @@ -3502,17 +3503,19 @@ This is equivalent to: **Examples** - `example.org/checkout##.promo-banner` — hides `.promo-banner` elements only on checkout pages -- `news.site.com/article##.sidebar-ad` — hides sidebar ads only on article pages +- `news.site.com/article##.sidebar-ad` — hides sidebar ads only on article pages - `shop.com/product,~shop.com/product/reviews##.upsell` — hides upsell blocks on product pages but not on review pages **Multiple domains** Path-in-domain syntax works with multiple domains: + - `domain1.com,example.org/path##.banner` — applies to all pages on `domain1.com` and only `/path` pages on `example.org` **Regex domains** Path-in-domain syntax is also supported for regex domains: + - `/example\.org\/article\d+/##.ad` — hides ads on article pages with numeric IDs **All cosmetic rule types** @@ -4785,6 +4788,7 @@ Such rules with `$domain` modifier are supported by AdGuard for Windows, AdGuard :::tip Alternative syntax For cosmetic rules, you can use a simplified [path-in-domain syntax](#cosmetic-path-in-domain) instead of the `$path` modifier: + - `example.org/path##.banner` instead of `[$path=/path]example.org##.banner` :::