From a1cefe0f63f51aa5b6958cc97fa0339d0f682b09 Mon Sep 17 00:00:00 2001 From: Andrey Yakushin Date: Thu, 16 Jan 2025 12:30:03 +0400 Subject: [PATCH 1/4] Add description for attributes without value in selector for html filtering rules --- .../general/ad-filtering/create-own-filters.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index d0598ae5930..5ea55b68f57 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3915,14 +3915,14 @@ HTML filtering rules are supported by AdGuard for Windows, AdGuard for Mac, AdGu combinator = ">" rule = [domains] "$$" selector *(combinator selector) domains = [domain0, domain1[, ...[, domainN]]] - attributes = "[" name0 = value0 "]" "[" name1 = value2 "]" ... "[" nameN = valueN "]" + attributes = "[" name0[ = value0] "]" "[" name1[ = value2] "]" ... "[" nameN[ = valueN] "]" pseudoClasses = pseudoClass *pseudoClass pseudoClass = ":" pseudoName [ "(" pseudoArgs ")" ] ``` - **`tagName`** — name of the element in lower case, for example, `div` or `script`. - **`domains`** — domain restriction for the rule. Same principles as in [element hiding rule syntax](#cosmetic-elemhide-rules). -- **`attributes`** — a list of attributes that limit the selection of elements. `name` — attribute name, `value` — substring, that is contained in attribute value. +- **`attributes`** — a list of attributes that limit the selection of elements. `name` — attribute name, `value` — substring, that is contained in attribute value. `value` might not be specified. - **`pseudoName`** — the name of a pseudo-class. - **`pseudoArgs`** — the arguments of a function-style pseudo-class. - **`combinator`** — an operator that works similarly to the [CSS child combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator): that is, the `selector` on the right of the `combinator` will only match an element whose direct parent matches the `selector` on the left of the `combinator`. @@ -3943,6 +3943,20 @@ example.org$$script[data-src="banner"] This rule removes all `script` elements with the attribute `data-src` containing the substring `banner`. The rule applies only to `example.org` and all its subdomains. +If the value of the attribute is omitted in the rule, then the element will be removed if it contains the specified attribute no matter what its value is. +This is also the way to remove the elements those attributes don't have any value at all. + +```html +
+
+``` + +```adblock +example.org$$div[some_attribute] +``` + +This rule removes all `div` elements with the attribute `some_attribute` on `example.org` and all its subdomains. So, the both `div` elements from the example above will be removed. + ### Special attributes In addition to usual attributes, which value is every element checked for, there is a set of special attributes that change the way a rule works. Below there is a list of these attributes: From d8d78dce57f3ef2165b28abaa7586cb71f14ec4b Mon Sep 17 00:00:00 2001 From: anyakushin <164042313+anyakushin@users.noreply.github.com> Date: Tue, 28 Jan 2025 17:10:20 +0400 Subject: [PATCH 2/4] Better English Co-authored-by: Slava <45171506+slavaleleka@users.noreply.github.com> Co-authored-by: Helen <58733007+el-termikael@users.noreply.github.com> --- docs/general/ad-filtering/create-own-filters.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index 5ea55b68f57..4f0a4040cf8 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3922,7 +3922,7 @@ pseudoClasses = pseudoClass *pseudoClass - **`tagName`** — name of the element in lower case, for example, `div` or `script`. - **`domains`** — domain restriction for the rule. Same principles as in [element hiding rule syntax](#cosmetic-elemhide-rules). -- **`attributes`** — a list of attributes that limit the selection of elements. `name` — attribute name, `value` — substring, that is contained in attribute value. `value` might not be specified. +- **`attributes`** — a list of attributes that limit the selection of elements. `name` — required, attribute name; `value` — optional (may not be specified), substring that is contained in attribute value. - **`pseudoName`** — the name of a pseudo-class. - **`pseudoArgs`** — the arguments of a function-style pseudo-class. - **`combinator`** — an operator that works similarly to the [CSS child combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator): that is, the `selector` on the right of the `combinator` will only match an element whose direct parent matches the `selector` on the left of the `combinator`. @@ -3943,8 +3943,8 @@ example.org$$script[data-src="banner"] This rule removes all `script` elements with the attribute `data-src` containing the substring `banner`. The rule applies only to `example.org` and all its subdomains. -If the value of the attribute is omitted in the rule, then the element will be removed if it contains the specified attribute no matter what its value is. -This is also the way to remove the elements those attributes don't have any value at all. +If the value of the attribute is omitted in the rule, then the element will be removed if it contains the specified attribute, regardless of its value. +This is also the way to remove the elements whose attributes don't have any value at all. ```html
From 886a17ea385d23c405fed919f6b6cfc48fa43dd7 Mon Sep 17 00:00:00 2001 From: Andrey Yakushin Date: Tue, 28 Jan 2025 17:22:09 +0400 Subject: [PATCH 3/4] Specify minimal CoreLibs version supporting optional value in selector --- docs/general/ad-filtering/create-own-filters.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index 4f0a4040cf8..d22e767dad4 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -3906,6 +3906,8 @@ In most cases, the basis and cosmetic rules are enough to filter ads. But someti HTML filtering rules are supported by AdGuard for Windows, AdGuard for Mac, AdGuard for Android, and AdGuard Browser Extension for Firefox. Such rules do not work in extensions for other browsers because they are unable to modify content on network level. +The syntax with optional `value` in the `attributes` is supported by AdGuard for Windows, AdGuard for Mac, and AdGuard for Android with [CoreLibs] v1.18 or later. For the other products and previous versions `value` **must** always be specified. + ::: ### Syntax From 97ae835fa29873b0dc18d0c334dd6cc7335878cc Mon Sep 17 00:00:00 2001 From: anyakushin <164042313+anyakushin@users.noreply.github.com> Date: Wed, 19 Feb 2025 13:03:29 +0400 Subject: [PATCH 4/4] Apply suggested Co-authored-by: Helen <58733007+el-termikael@users.noreply.github.com> --- docs/general/ad-filtering/create-own-filters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/general/ad-filtering/create-own-filters.md b/docs/general/ad-filtering/create-own-filters.md index b19e6cfedfe..e203c8444c7 100644 --- a/docs/general/ad-filtering/create-own-filters.md +++ b/docs/general/ad-filtering/create-own-filters.md @@ -4037,7 +4037,7 @@ In most cases, the basis and cosmetic rules are enough to filter ads. But someti HTML filtering rules are supported by AdGuard for Windows, AdGuard for Mac, AdGuard for Android, and AdGuard Browser Extension for Firefox. Such rules do not work in extensions for other browsers because they are unable to modify content on network level. -The syntax with optional `value` in the `attributes` is supported by AdGuard for Windows, AdGuard for Mac, and AdGuard for Android with [CoreLibs] v1.18 or later. For the other products and previous versions `value` **must** always be specified. +The syntax with optional `value` in the `attributes` is supported by AdGuard for Windows, AdGuard for Mac, and AdGuard for Android with [CoreLibs] v1.18 or later. For the other products and previous versions `value` must **always** be specified. Otherwise, the rule will be treated as incorrect and ignored. :::