Merge pull request #1067 from AdguardTeam/fix/#1049

Describe $all modifier
This commit is contained in:
Andrey Meshkov 2022-05-29 18:06:36 +03:00 committed by GitHub
commit 86378504cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 322 additions and 294 deletions

View File

@ -34,7 +34,6 @@ visible: true
* [$stylesheet](#stylesheet-modifier)
* [$script](#script-modifier)
* [$object](#object-modifier)
* [$object-subrequest](#object-subrequest-modifier)
* [$font](#font-modifier)
* [$media](#media-modifier)
* [$subdocument](#subdocument-modifier)
@ -43,6 +42,7 @@ visible: true
* [$websocket](#websocket-modifier)
* [$webrtc](#webrtc-modifier)
* [$other](#other-modifier)
* [$object-subrequest (deprecated)](#object-subrequest-modifier)
* [Exception rules modifiers](#exceptions-modifiers)
* [$elemhide](#elemhide-modifier)
* [$content](#content-modifier)
@ -55,21 +55,22 @@ visible: true
* [$genericblock](#genericblock-modifier)
* [$specifichide](#specifichide-modifier)
* [Advanced capabilities](#advanced-modifiers)
* [$removeparam](#removeparam-modifier)
* [$important](#important-modifier)
* [$badfilter](#badfilter-modifier)
* [$empty](#empty-modifier)
* [$mp4](#mp4-modifier)
* [$replace](#replace-modifier)
* [$csp](#csp-modifier)
* [$all](#all-modifier)
* [$cookie](#cookie-modifier)
* [$network](#network-modifier)
* [$app](#app-modifier)
* [$redirect](#redirect-modifier)
* [$redirect-rule](#redirect-rule-modifier)
* [$denyallow](#denyallow-modifier)
* [noop](#noop-modifier)
* [$removeparam](#removeparam-modifier)
* [$removeheader](#removeheader-modifier)
* [noop](#noop-modifier)
* [$empty (deprecated)](#empty-modifier)
* [$mp4 (deprecated)](#mp4-modifier)
* [Non-basic rules](#non-basic-rules)
* [Cosmetic rules](#cosmetic-rules)
* [Element hiding rules](#cosmetic-elemhide-rules)
@ -471,13 +472,6 @@ The rule corresponds to script requests, e.g. javascript, vbscript.
The rule corresponds to browser plugins resources, e.g. Java or Flash.
<a id="object-subrequest-modifier"></a>
##### **`object-subrequest`**
> **Deprecation notice.** `object-subrequest` modifier is deprecated and no longer supported. Rules with it are considered as invalid.
The rule corresponds to requests by browser plugins (it's usually Flash).
<a id="font-modifier"></a>
##### **`font`**
@ -535,6 +529,13 @@ The rule applies only to WebRTC connections.
The rule applies to requests for which the type has not been determined or doesn't match the types listed above.
<a id="object-subrequest-modifier"></a>
##### **`object-subrequest` (deprecated)**
> **Deprecation notice.** `object-subrequest` modifier is deprecated and no longer supported. Rules with it are considered as invalid.
The rule corresponds to requests by browser plugins (it's usually Flash).
<a id="exceptions-modifiers"></a>
#### Exception modifiers
@ -655,111 +656,6 @@ Has an opposite effect to [`$generichide`](#generichide-modifier). Disables all
These modifiers are able to completely change the behaviour of basic rules.
<a id="removeparam-modifier"></a>
#### **`removeparam`**
> `$queryprune` is an alias of `$removeparam`. Since `$queryprune` is deprecated, avoid using it and use `$removeparam` instead.
Rules with `$removeparam` modifier are intended to to strip query parameters from requests' URLs. Please note that such rules are only applied to `GET`, `HEAD`, and `OPTIONS` requests.
> `$removeparam` rules that do not have any content-type modifiers will match only requests where content type is `document`.
##### Syntax
###### Basic syntax
* `$removeparam=param` — removes query parameter with the name `param` from URLs of any request, e.g. a request to `http://example.com/page?param=1&another=2` will be transformed to `http://example.com/page?another=2`.
> `$removeparam` basic syntax is supported starting with v1.7 of [CoreLibs](https://adguard.com/en/blog/introducing-corelibs.html) and v3.6 of AdGuard Browser Extension.
###### Regular expressions
You can also use regular expressions to match query parameters and/or their values:
* `$removeparam=/regex/[options]` — removes query parameters matching the regex regular expression from URLs of any request. Unlike basic syntax, it means *"remove query parameters normalized to a `name=value` string which match the regex regular expression"*. `[options]` here is the list of regular expression options. At the moment, the only supported option is `i` which makes matching case-insensitive.
> `$removeparam` syntax for regular expressions will be supported starting with v1.8 of CoreLibs and v4.0 of AdGuard Browser Extension. For now, use the simplified version: `$removeparam=param`.
> **Escaping special characters**: don't forget to escape special characters like `,`, `/` and `$` in the regular expressions. Use `\` character for that purpose. For example, an escaped comma should look like this: `\,`.
> Please note that regex-type rules target both parameter's name and value. In order to minimize the chance of mistakes, it is safer to start every regex with `/^` unless you specifically target parameter values.
> We will try to detect and ignore unescaped `$` automatically using a simple rule of thumb:
> It is not an options delimiter if all three are true:
> 1. It looks like `$/`,
> 2. There's another slash character (`/`) to the left of it,
> 3. There's another unescaped `$` character to the left of that slash character.
###### Remove all query parameters
Specify naked `$removeparam` to remove all query parameters:
* `||example.org^$removeparam` — removes all query parameters from URLs matching `||example.org^`.
###### Inversion
Use `~` to apply inversion:
* `$removeparam=~param` — removes all query parameters with the name different from `param`.
* `$removeparam=~/regex/` — removes all query parameters that do not match the regex regular expression.
###### Negating `$removeparam`
This sort of rules work pretty much the same way it works with [`$csp`](#csp-modifier) and [`$redirect`](#redirect-modifier) modifiers.
Use `@@` to negate `$removeparam`:
* `@@||example.org^$removeparam` — negates all `$removeparam` rules for URLs that match `||example.org^`.
* `@@||example.org^$removeparam=param` — negates the rule with `$removeparam=param` for any request matching `||example.org^`.
* `@@||example.org^$removeparam=/regex/` — negates the rule with `$removeparam=/regex/` for any request matching `||example.org^`.
>**Multiple rules matching a single request**
>In the case when multiple `$removeparam` rules match a single request, each of them will be applied one by one.
##### Examples
```
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
With these rules some [UTM parameters](https://en.wikipedia.org/wiki/UTM_parameters) will be stripped out from any request, except that requests to `example.com` won't be stripped at all, e.g. `http://google.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` will be transformed to `http://google.com/page`, but `http://example.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` won't be affected by the blocking rule.
* `$removeparam=utm_source` — removes `utm_source` query parameter from all requests.
* `$removeparam=/utm_.*/` — removes all `utm_* query` parameters from URL queries of any request, e.g. a request to `http://example.com/page?utm_source=test` will be transformed to `http://example.com/page`.
* `$removeparam=/^utm_source=campaign$/` — removes `utm_source` query parameter with the value equal to `campaign`. It does not touch other `utm_source` parameters.
Negating one `$removeparam` rule and replacing it with a different rule:
```
$removeparam=/^(gclid|yclid|fbclid)=/
@@||example.com^$removeparam=/^(gclid|yclid|fbclid)=/
||example.com^$removeparam=/^(yclid|fbclid)=/
```
With these rules, Google, Yandex, and Facebook Click IDs will be removed from all requests. There's one exception: Google Click ID (gclid) will not be removed from requests to example.com.
Negating `$removeparam` for all parameters:
```
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
With these rules, specified UTM parameters will be removed from any request save for requests to example.org.
> **Compatibility with other modifiers**
> `$removeparam` rules are compatible with [basic modifiers](#basic-rules-common-modifiers), [content-type modifiers](#content-type-modifiers), and with `$important` and `$app` modifiers. The rules which have any other modifiers are considered invalid and will be discarded.
> Please note that `$removeparam` rules can also be disabled by `$document` and `$urlblock` exception rules. But basic exception rules without modifiers don't do that. For example, `@@||example.com^` will not disable `$removeparam=p` for requests to **example.com**, but `@@||example.com^$urlblock` will.
> **Compatibility with different versions of AdGuard.** Rules with `$removeparam` modifier are supported by AdGuard for Windows, Mac, Android, and AdGuard Browser extension for Chrome, Firefox, Edge.
> **Restrictions.** Rules with `$removeparam` modifier can be used **only in trusted filters**. This category includes your own **User rules** and all the filters created by AdGuard Team.
<a id="important-modifier"></a>
#### **`important`**
@ -817,32 +713,6 @@ In that case, the `$badfilter` rule will disable the corresponding rule for doma
* `/some$domain=example.*` is disabled for `example.com` and `example.org` by `/some$domain=example.com|example.org,badfilter`
* `/some$domain=example.com|example.org|example.io` is NOT disabled for `example.com` by `/some$domain=example.com|~example.org,badfilter` because the value of `domain` modifier contains a negated domain
<a id="empty-modifier"></a>
#### **`empty`**
> **Deprecation notice.** This modifier is deprecated in favor of the [`$redirect` modifier](#redirect-modifier). Rules with `$empty` are converting into `$redirect=nooptext` now.
Usually, blocked requests look like a server error to browser. If you use `empty` modifier, AdGuard will emulate a blank response from the server with` 200 OK` status.
##### `empty` example
* `||example.org^$empty` — returns an empty response to all requests to `example.org` and all subdomains.
> **Compatibility with different versions of AdGuard.** Rules with `empty` modifier are not supported by AdGuard Content Blocker, AdGuard for iOS and Safari.
<a id="mp4-modifier"></a>
#### **`mp4`**
> **Deprecation notice.** This modifier is deprecated in favor of the [`$redirect` modifier](#redirect-modifier). Rules with `$mp4` are converting into `$redirect=noopmp4-1s,media` now.
As a response to blocked request AdGuard returns a short video placeholder.
##### `mp4` example
* `||example.com/videos/$mp4` — block a video downloads from `||example.com/videos/*` and changes the response to a video placeholder.
> **Compatibility with different versions of AdGuard.** Rules with `mp4` modifier are not supported by AdGuard Content Blocker, AdGuard for iOS and Safari.
<a id="replace-modifier"></a>
#### **`replace`**
@ -943,6 +813,18 @@ For the requests matching a `$csp` rule, we will strengthen response's security
> **Compatibility with different versions of AdGuard.** Rules with `$csp` modifier are not supported by AdGuard Content Blocker, AdGuard for iOS and Safari.
<a id="all-modifier"></a>
##### **`all`**
`$all` modifier is made of [`$document`](#document-modifier), [`$popup`](#popup-modifier), [`$csp`](#csp-modifier) modifiers. E.g. rule `||example.org^$all` is converting into such set of rules:
```
||example.org^$document,popup
||example.org^$csp=script-src 'self' 'unsafe-eval' http: https: data: blob: mediastream: filesystem:
||example.org^$csp=font-src 'self' 'unsafe-eval' http: https: data: blob: mediastream: filesystem:
||example.org^
```
<a id="cookie-modifier"></a>
#### **`cookie`**
@ -1117,19 +999,110 @@ or to these three:
> **Compatibility with different versions of AdGuard.** Rules with `$denyallow` modifier are not supported by AdGuard Content Blocker.
<a id="noop-modifier"></a>
#### **`noop`**
<a id="removeparam-modifier"></a>
#### **`removeparam`**
`noop` modifier does nothing and can be used solely to increase rules' readability. It consists of a sequence of underscore characters (`_`) of any length and can appear in a rule as many times as needed.
> `$queryprune` is an alias of `$removeparam`. Since `$queryprune` is deprecated, avoid using it and use `$removeparam` instead.
##### `noop` examples:
Rules with `$removeparam` modifier are intended to to strip query parameters from requests' URLs. Please note that such rules are only applied to `GET`, `HEAD`, and `OPTIONS` requests.
> `$removeparam` rules that do not have any content-type modifiers will match only requests where content type is `document`.
##### Syntax
###### Basic syntax
* `$removeparam=param` — removes query parameter with the name `param` from URLs of any request, e.g. a request to `http://example.com/page?param=1&another=2` will be transformed to `http://example.com/page?another=2`.
> `$removeparam` basic syntax is supported starting with v1.7 of [CoreLibs](https://adguard.com/en/blog/introducing-corelibs.html) and v3.6 of AdGuard Browser Extension.
###### Regular expressions
You can also use regular expressions to match query parameters and/or their values:
* `$removeparam=/regex/[options]` — removes query parameters matching the regex regular expression from URLs of any request. Unlike basic syntax, it means *"remove query parameters normalized to a `name=value` string which match the regex regular expression"*. `[options]` here is the list of regular expression options. At the moment, the only supported option is `i` which makes matching case-insensitive.
> `$removeparam` syntax for regular expressions will be supported starting with v1.8 of CoreLibs and v4.0 of AdGuard Browser Extension. For now, use the simplified version: `$removeparam=param`.
> **Escaping special characters**: don't forget to escape special characters like `,`, `/` and `$` in the regular expressions. Use `\` character for that purpose. For example, an escaped comma should look like this: `\,`.
> Please note that regex-type rules target both parameter's name and value. In order to minimize the chance of mistakes, it is safer to start every regex with `/^` unless you specifically target parameter values.
> We will try to detect and ignore unescaped `$` automatically using a simple rule of thumb:
> It is not an options delimiter if all three are true:
> 1. It looks like `$/`,
> 2. There's another slash character (`/`) to the left of it,
> 3. There's another unescaped `$` character to the left of that slash character.
###### Remove all query parameters
Specify naked `$removeparam` to remove all query parameters:
* `||example.org^$removeparam` — removes all query parameters from URLs matching `||example.org^`.
###### Inversion
Use `~` to apply inversion:
* `$removeparam=~param` — removes all query parameters with the name different from `param`.
* `$removeparam=~/regex/` — removes all query parameters that do not match the regex regular expression.
###### Negating `$removeparam`
This sort of rules work pretty much the same way it works with [`$csp`](#csp-modifier) and [`$redirect`](#redirect-modifier) modifiers.
Use `@@` to negate `$removeparam`:
* `@@||example.org^$removeparam` — negates all `$removeparam` rules for URLs that match `||example.org^`.
* `@@||example.org^$removeparam=param` — negates the rule with `$removeparam=param` for any request matching `||example.org^`.
* `@@||example.org^$removeparam=/regex/` — negates the rule with `$removeparam=/regex/` for any request matching `||example.org^`.
>**Multiple rules matching a single request**
>In the case when multiple `$removeparam` rules match a single request, each of them will be applied one by one.
##### Examples
```
||example.com$_,removeparam=/^ss\\$/,_,image
||example.com$replace=/bad/good/,___,~third-party
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
With these rules some [UTM parameters](https://en.wikipedia.org/wiki/UTM_parameters) will be stripped out from any request, except that requests to `example.com` won't be stripped at all, e.g. `http://google.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` will be transformed to `http://google.com/page`, but `http://example.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` won't be affected by the blocking rule.
* `$removeparam=utm_source` — removes `utm_source` query parameter from all requests.
* `$removeparam=/utm_.*/` — removes all `utm_* query` parameters from URL queries of any request, e.g. a request to `http://example.com/page?utm_source=test` will be transformed to `http://example.com/page`.
* `$removeparam=/^utm_source=campaign$/` — removes `utm_source` query parameter with the value equal to `campaign`. It does not touch other `utm_source` parameters.
Negating one `$removeparam` rule and replacing it with a different rule:
```
$removeparam=/^(gclid|yclid|fbclid)=/
@@||example.com^$removeparam=/^(gclid|yclid|fbclid)=/
||example.com^$removeparam=/^(yclid|fbclid)=/
```
> **Compatibility with different versions of AdGuard.** Rules with `noop` modifier are not supported by AdGuard Content Blocker.
With these rules, Google, Yandex, and Facebook Click IDs will be removed from all requests. There's one exception: Google Click ID (gclid) will not be removed from requests to example.com.
Negating `$removeparam` for all parameters:
```
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
With these rules, specified UTM parameters will be removed from any request save for requests to example.org.
> **Compatibility with other modifiers**
> `$removeparam` rules are compatible with [basic modifiers](#basic-rules-common-modifiers), [content-type modifiers](#content-type-modifiers), and with `$important` and `$app` modifiers. The rules which have any other modifiers are considered invalid and will be discarded.
> Please note that `$removeparam` rules can also be disabled by `$document` and `$urlblock` exception rules. But basic exception rules without modifiers don't do that. For example, `@@||example.com^` will not disable `$removeparam=p` for requests to **example.com**, but `@@||example.com^$urlblock` will.
> **Compatibility with different versions of AdGuard.** Rules with `$removeparam` modifier are supported by AdGuard for Windows, Mac, Android, and AdGuard browser extensions for Chrome, Firefox, Edge.
> **Restrictions.** Rules with `$removeparam` modifier can be used **only in trusted filters**. This category includes your own **User rules** and all the filters created by AdGuard Team.
<a id="removeheader-modifier"></a>
#### **`$removeheader`**
@ -1230,6 +1203,47 @@ Use `@@` to negate `$removeheader`:
> **Compatibility with different versions of AdGuard.** Rules with `$removeparam` modifier are supported by AdGuard for Windows, Mac, Android, and AdGuard Browser extension for Chrome, Firefox, Edge.
<a id="noop-modifier"></a>
#### **`noop`**
`noop` modifier does nothing and can be used solely to increase rules' readability. It consists of a sequence of underscore characters (`_`) of any length and can appear in a rule as many times as needed.
##### `noop` examples:
```
||example.com$_,removeparam=/^ss\\$/,_,image
||example.com$replace=/bad/good/,___,~third-party
```
> **Compatibility with different versions of AdGuard.** Rules with `noop` modifier are not supported by AdGuard Content Blocker.
<a id="empty-modifier"></a>
#### **`empty` (deprecated)**
> **Deprecation notice.** This modifier is deprecated in favor of the [`$redirect` modifier](#redirect-modifier). Rules with `$empty` are converting into `$redirect=nooptext` now.
Usually, blocked requests look like a server error to browser. If you use `empty` modifier, AdGuard will emulate a blank response from the server with` 200 OK` status.
##### `empty` example
* `||example.org^$empty` — returns an empty response to all requests to `example.org` and all subdomains.
> **Compatibility with different versions of AdGuard.** Rules with `empty` modifier are not supported by AdGuard Content Blocker, AdGuard for iOS and Safari.
<a id="mp4-modifier"></a>
#### **`mp4` (deprecated)**
> **Deprecation notice.** This modifier is deprecated in favor of the [`$redirect` modifier](#redirect-modifier). Rules with `$mp4` are converting into `$redirect=noopmp4-1s,media` now.
As a response to blocked request AdGuard returns a short video placeholder.
##### `mp4` example
* `||example.com/videos/$mp4` — block a video downloads from `||example.com/videos/*` and changes the response to a video placeholder.
> **Compatibility with different versions of AdGuard.** Rules with `mp4` modifier are not supported by AdGuard Content Blocker, AdGuard for iOS and Safari.
<a id="non-basic-rules"></a>
# Non-basic rules

View File

@ -34,7 +34,6 @@ visible: true
* [$stylesheet](#stylesheet-modifier)
* [$script](#script-modifier)
* [$object](#object-modifier)
* [$object-subrequest](#object-subrequest-modifier)
* [$font](#font-modifier)
* [$media](#media-modifier)
* [$subdocument](#subdocument-modifier)
@ -43,6 +42,7 @@ visible: true
* [$websocket](#websocket-modifier)
* [$webrtc](#webrtc-modifier)
* [$other](#other-modifier)
* [$object-subrequest (устаревший)](#object-subrequest-modifier)
* [Модификаторы правил-исключений](#exceptions-modifiers)
* [$elemhide](#elemhide-modifier)
* [$content](#content-modifier)
@ -55,21 +55,22 @@ visible: true
* [$genericblock](#genericblock-modifier)
* [$specifichide](#specifichide-modifier)
* [Расширенные возможности](#advanced-modifiers)
* [$removeparam](#removeparam-modifier)
* [$important](#important-modifier)
* [$badfilter](#badfilter-modifier)
* [$empty](#empty-modifier)
* [$mp4](#mp4-modifier)
* [$replace](#replace-modifier)
* [$csp](#csp-modifier)
* [$all](#all-modifier)
* [$cookie](#cookie-modifier)
* [$network](#network-modifier)
* [$app](#app-modifier)
* [$redirect](#redirect-modifier)
* [$denyallow](#denyallow-modifier)
* [$redirect-rule](#redirect-rule-modifier)
* [noop](#noop-modifier)
* [$denyallow](#denyallow-modifier)
* [$removeparam](#removeparam-modifier)
* [$removeheader](#removeheader-modifier)
* [noop](#noop-modifier)
* [$empty (устаревший)](#empty-modifier)
* [$mp4 (устаревший)](#mp4-modifier)
* [Другие правила](#non-basic-rules)
* [Косметические правила](#cosmetic-rules)
* [Правила скрытия элементов](#cosmetic-elemhide-rules)
@ -472,13 +473,6 @@ AdGuard будет пытаться закрыть браузерную вкла
Правило применяется к ресурсам, управляемым браузерными плагинами, например, Java или Flash.
<a id="object-subrequest-modifier"></a>
##### **`object-subrequest`**
> **Предупреждение об устаревании.** Модификатор `$object-subrequest` устарел и больше не поддерживается. Правила с его использованием не работают.
Запросы, инициированные плагинами (чаще всего это Flash).
<a id="font-modifier"></a>
##### **`font`**
@ -536,6 +530,14 @@ AdGuard будет пытаться закрыть браузерную вкла
Правило применяется к запросам, для которых не был определен ни один из перечисленных выше типов.
<a id="object-subrequest-modifier"></a>
##### **`object-subrequest` (устаревший)**
> **Предупреждение об устаревании.** Модификатор `$object-subrequest` устарел и больше не поддерживается. Правила с его использованием не работают.
Запросы, инициированные плагинами (чаще всего это Flash).
<a id="exceptions-modifiers"></a>
#### Модификаторы правил-исключений
@ -656,104 +658,6 @@ domain.com###banner
Модификаторы, описанные в этом разделе, полностью меняют поведение базовых правил, к которым эти модификаторы применены.
<a id="removeparam-modifier"></a>
#### **`removeparam`**
> Модификатор `$removeparam` является полным аналогом модификатора `$queryprune`. При этом модификатор `$queryprune` считается устаревшим, мы рекомендуем везде использовать только модификатор `$removeparam`.
Правила с модификатором `$removeparam` предназначены для того, чтобы убирать параметры из URL запросов. Такие правила применяются *только* к запросам типов `GET`, `HEAD`, и `OPTIONS`.
> Правила с модификатором `$removeparam`, не содержащие модификаторов типа контента, будут соответствовать только тем запросам, которые имеют тип контента `document`.
##### Синтаксис
###### Базовый синтаксис
* `$removeparam=param` — убирает параметр запроса с именем `param` из URL любого запроса. Например, запрос к `http://example.com/page?param=1&another=2` будет преобразован в `http://example.com/page?another=2`.
> Базовый синтаксис `$removeparam` поддерживается начиная с версии 1.7 [CoreLibs](https://adguard.com/ru/blog/introducing-corelibs.html) и версии 3.6 Браузерного расширения AdGuard.
###### Регулярные выражения
Вы также можете использовать регулярные выражения для соответствия параметрам запроса и/или их значениям:
* `$removeparam=/regex/[options]` — убирает все параметры, соответствующие регулярному выражению из URL любого запроса. В отличие от базового синтаксиса, это означает *"убрать параметры запроса, нормализованные к строке `name=value`, которая соответствует регулярному выражению"*. Здесь `[options]` — это список опций регулярного выражения. На данный момент, единственная поддерживаемая опция — это `i`, делающая соответствие нечувствительным к регистру.
> Синтаксис `$removeparam` для регулярных выражений будет доступен начиная с версии 1.8 CoreLibs и версии 4.0. Браузерного расширения AdGuard, а пока используйте упрощенный вариант: `$removeparam=param`.
> **Экранирование специальных символов**: не забудьте экранировать специальные символы в регулярных выражениях, такие как `,`, `/` и `$`. Для этой цели используйте символ `\`. Например, экранированная запятая должна выглядеть так: `\,`.
> Обратите внимание, что правила с регулярными выражениями смотрят как на имя, так и на значение параметра. Чтобы минимизировать риск ошибки, рекомендуем начинать регулярное выражение с `/^`, если только вы не хотите специально работать с значениями параметров.
> Мы будем стараться обнаруживать и игнорировать неэкранированные символы `$` автоматически, используя следующее правило большого пальца:
> Это не является разделителем опций, если:
> Оно выглядит как `$/`,
> Существует другой символ слеша (`/`) слева от него,
> Существует другой неэкранированный символ `$` слева от этого символа слеша.
###### Убрать все параметры запроса
Укажите "голый" `$removeparam`, чтобы убрать все параметры запроса:
* `||example.org^$removeparam` — убирает все параметры запроса из URL, соответствующего `||example.org^`.
###### Инверсия
Используйте символ `~`, чтобы применить инверсию:
* `$removeparam=~param` — убирает все параметры запроса с именем, отличным от `param`.
* `$removeparam=~/regex/` — убирает все параметры запроса, которые не соответствуют регулярному выражению.
###### Отмена `$removeparam`
Этот тип правил работает практически так же, как и в случае с модификаторами [`$csp`](#csp-modifier) и [`$redirect`](#redirect-modifier).
Используйте `@@`, чтобы отменить `$removeparam`:
* `@@||example.org^$removeparam` — отменяет все правила `$removeparam` для URL, соответствующих `||example.org^`.
* `@@||example.org^$removeparam=param` — отменяет правило с `$removeparam=param` для любого запроса, соответствующего `||example.org^`.
* `@@||example.org^$removeparam=/regex/` — отменяет правило с `$removeparam=/regex/` для любого запроса, соответствующего `||example.org^`.
> **Многочисленные правила, соответствующие одному запросу**
> В случае, когда несколько правил с `$removeparam` соответствуют одному запросу, они все будут применены по очереди.
##### Примеры
* `$removeparam=utm_source` — убирает параметр `utm_source` из всех запросов.
* `$removeparam=/utm_.*/` — убирает все параметры `utm_* query` из URL любого запроса, например, запрос `http://example.com/page?utm_source=test` будет трансформирован в `http://example.com/page`.
* `$removeparam=/^utm_source=campaign$/` — убирает параметр `utm_source` с значением `campaign`. Не затрагивает другие параметры `utm_source`.
Отмена одного правила `$removeparam` и замена его другим:
```
$removeparam=/^(gclid|yclid|fbclid)=/
@@||example.com^$removeparam=/^(gclid|yclid|fbclid)=/
||example.com^$removeparam=/^(yclid|fbclid)=/
```
При помощи этих правил из всех запросов убираются Click ID от Google, Yandex, и Facebook. Есть одно исключение: Google Click ID (gclid) не будет убран для запросов к example.com.
Отмена `$removeparam` для всех параметров:
```
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
С этими правилами некоторые [utm-параметры](https://ru.wikipedia.org/wiki/UTM-%D0%BC%D0%B5%D1%82%D0%BA%D0%B8) будут удалены из любого запроса, но в запросах к `example.com` не будут удаляться совсем. Например: `http://google.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` будет преобразован в `http://google.com/page`, но `http://example.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` вообще не будет затронут этим правилом блокировки.
> **Совместимость с другими модификаторами**
> Правила с `$removeparam` совместимы с [базовыми модификаторами](#basic-rules-common-modifiers), [модификаторами с ограничением по типу контента](#content-type-modifiers), а также с модификаторами `$important` и `$app`. Правила, содержащие другие типы модификаторов, будут считаться некорректными и не будут применены.
> **Обратите внимание**, что блокировку правил `$removeparam` также можно отключить с помощью правил исключений `$document` и `$urlblock`. Но базовые правила исключений без модификаторов не могут этого сделать. Например, `@@||example.com^` не отключит `$removeparam=p` для запросов к example.com, а вот `@@||example.com^$urlblock` — отключит.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$removeparam` поддерживаются в AdGuard для Windows, Mac, Android и Браузерном расширении AdGuard для Chrome, Firefox, Edge.
> **Ограничения.** Правила с модификатором `$removeparam` могут быть использованы **только в доверенных фильтрах** — то есть в **Пользовательских правилах** и всех фильтрах, разработанных командой AdGuard.
<a id="important-modifier"></a>
##### **`important`**
@ -811,32 +715,6 @@ $removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
* `/some$domain=example.*` отключено для `example.com` и `example.org` правилом `/some$domain=example.com|example.org,badfilter`
* `/some$domain=example.com|example.org|example.io` НЕ отключено для `example.com` правилом `/some$domain=example.com|~example.org,badfilter`, поскольку в значении модификатора `domain` содержится отрицание домена
<a id="empty-modifier"></a>
##### **`empty`**
> **Предупреждение об устаревании.** Этот модификатор считаются устаревшими. Вместо него теперь используется [модификатор `$redirect`](#redirect-modifier). Правила с `$empty` конвертируются в `$redirect=nooptext`.
Обычно заблокированный запрос выглядит для браузера как ошибка сервера. В случае применения модификатора `$empty`, AdGuard эмулирует пустой ответ сервера со статусом `200 OK`.
###### Примеры `empty`
* `||example.org^$empty` — возвращает пустой ответ для всех запросов к домену `example.org` и всех его поддоменов.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$empty` не поддерживаются в AdGuard Content Blocker, AdGuard для Safari и для iOS.
<a id="mp4-modifier"></a>
##### **`mp4`**
> **Предупреждение об устаревании.** Этот модификатор считаются устаревшими. Вместо него теперь используется [модификатор `$redirect`](#redirect-modifier). Правила с `$mp4` конвертируются в `$redirect=noopmp4-1s,media`.
В качестве ответа на заблокированный запрос AdGuard возвращает короткую видео-заглушку.
###### Примеры `mp4`
* `||example.com/videos/$mp4` — блокирует загрузку видео с адресов `||example.com/videos/*` и заменяет ответ на видео-заглушку.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$mp4` не поддерживаются в AdGuard Content Blocker, AdGuard для Safari и для iOS.
<a id="replace-modifier"></a>
##### **`replace`**
@ -936,6 +814,18 @@ http://regexr.com/3cesk
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$csp` не поддерживается в AdGuard Content Blocker, AdGuard для iOS и для Safari.
<a id="all-modifier"></a>
##### **`all`**
Модификатор `$all` является сборным из модификаторов [`$document`](#document-modifier), [`$popup`](#popup-modifier), [`$csp`](#csp-modifier). Например, правило `||example.org^$all` конвертируется в такой набор правил:
```
||example.org^$document,popup
||example.org^$csp=script-src 'self' 'unsafe-eval' http: https: data: blob: mediastream: filesystem:
||example.org^$csp=font-src 'self' 'unsafe-eval' http: https: data: blob: mediastream: filesystem:
||example.org^
```
<a id="cookie-modifier"></a>
##### **`cookie`**
@ -1106,19 +996,103 @@ AdGuard использует тот же синтаксис правил фил
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$denyallow` не поддерживаются в AdGuard Content Blocker.
<a id="noop-modifier"></a>
#### **`noop`**
<a id="removeparam-modifier"></a>
#### **`removeparam`**
Модификатор `noop` не делает ничего и может быть использован исключительно в целях улучшения читабельности правил. Он состоит из последовательности символов нижнего подчёркивания (`_`) любой длины и может фигурировать в правиле столько раз, сколько требуется.
> Модификатор `$removeparam` является полным аналогом модификатора `$queryprune`. При этом модификатор `$queryprune` считается устаревшим, мы рекомендуем везде использовать только модификатор `$removeparam`.
##### Примеры `noop`:
Правила с модификатором `$removeparam` предназначены для того, чтобы убирать параметры из URL запросов. Такие правила применяются *только* к запросам типов `GET`, `HEAD`, и `OPTIONS`.
> Правила с модификатором `$removeparam`, не содержащие модификаторов типа контента, будут соответствовать только тем запросам, которые имеют тип контента `document`.
##### Синтаксис
###### Базовый синтаксис
* `$removeparam=param` — убирает параметр запроса с именем `param` из URL любого запроса. Например, запрос к `http://example.com/page?param=1&another=2` будет преобразован в `http://example.com/page?another=2`.
> Базовый синтаксис `$removeparam` поддерживается начиная с версии 1.7 [CoreLibs](https://adguard.com/ru/blog/introducing-corelibs.html) и версии 3.6 Браузерного расширения AdGuard.
###### Регулярные выражения
Вы также можете использовать регулярные выражения для соответствия параметрам запроса и/или их значениям:
* `$removeparam=/regex/[options]` — убирает все параметры, соответствующие регулярному выражению из URL любого запроса. В отличие от базового синтаксиса, это означает *"убрать параметры запроса, нормализованные к строке `name=value`, которая соответствует регулярному выражению"*. Здесь `[options]` — это список опций регулярного выражения. На данный момент, единственная поддерживаемая опция — это `i`, делающая соответствие нечувствительным к регистру.
> Синтаксис `$removeparam` для регулярных выражений будет доступен начиная с версии 1.8 CoreLibs и версии 4.0. Браузерного расширения AdGuard, а пока используйте упрощенный вариант: `$removeparam=param`.
> **Экранирование специальных символов**: не забудьте экранировать специальные символы в регулярных выражениях, такие как `,`, `/` и `$`. Для этой цели используйте символ `\`. Например, экранированная запятая должна выглядеть так: `\,`.
> Обратите внимание, что правила с регулярными выражениями смотрят как на имя, так и на значение параметра. Чтобы минимизировать риск ошибки, рекомендуем начинать регулярное выражение с `/^`, если только вы не хотите специально работать с значениями параметров.
> Мы будем стараться обнаруживать и игнорировать неэкранированные символы `$` автоматически, используя следующее правило большого пальца:
> Это не является разделителем опций, если:
> Оно выглядит как `$/`,
> Существует другой символ слеша (`/`) слева от него,
> Существует другой неэкранированный символ `$` слева от этого символа слеша.
###### Убрать все параметры запроса
Укажите "голый" `$removeparam`, чтобы убрать все параметры запроса:
* `||example.org^$removeparam` — убирает все параметры запроса из URL, соответствующего `||example.org^`.
###### Инверсия
Используйте символ `~`, чтобы применить инверсию:
* `$removeparam=~param` — убирает все параметры запроса с именем, отличным от `param`.
* `$removeparam=~/regex/` — убирает все параметры запроса, которые не соответствуют регулярному выражению.
###### Отмена `$removeparam`
Этот тип правил работает практически так же, как и в случае с модификаторами [`$csp`](#csp-modifier) и [`$redirect`](#redirect-modifier).
Используйте `@@`, чтобы отменить `$removeparam`:
* `@@||example.org^$removeparam` — отменяет все правила `$removeparam` для URL, соответствующих `||example.org^`.
* `@@||example.org^$removeparam=param` — отменяет правило с `$removeparam=param` для любого запроса, соответствующего `||example.org^`.
* `@@||example.org^$removeparam=/regex/` — отменяет правило с `$removeparam=/regex/` для любого запроса, соответствующего `||example.org^`.
> **Многочисленные правила, соответствующие одному запросу**
> В случае, когда несколько правил с `$removeparam` соответствуют одному запросу, они все будут применены по очереди.
##### Примеры
* `$removeparam=utm_source` — убирает параметр `utm_source` из всех запросов.
* `$removeparam=/utm_.*/` — убирает все параметры `utm_* query` из URL любого запроса, например, запрос `http://example.com/page?utm_source=test` будет трансформирован в `http://example.com/page`.
* `$removeparam=/^utm_source=campaign$/` — убирает параметр `utm_source` с значением `campaign`. Не затрагивает другие параметры `utm_source`.
Отмена одного правила `$removeparam` и замена его другим:
```
||example.com$_,removeparam=/^ss\\$/,_,image
||example.com$replace=/bad/good/,___,~third-party
$removeparam=/^(gclid|yclid|fbclid)=/
@@||example.com^$removeparam=/^(gclid|yclid|fbclid)=/
||example.com^$removeparam=/^(yclid|fbclid)=/
```
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `noop` не поддерживаются в AdGuard Content Blocker.
При помощи этих правил из всех запросов убираются Click ID от Google, Yandex, и Facebook. Есть одно исключение: Google Click ID (gclid) не будет убран для запросов к example.com.
Отмена `$removeparam` для всех параметров:
```
$removeparam=/^(utm_source|utm_medium|utm_term)=/
$removeparam=/^(utm_content|utm_campaign|utm_referrer)=/
@@||example.com^$removeparam
```
С этими правилами некоторые [utm-параметры](https://ru.wikipedia.org/wiki/UTM-%D0%BC%D0%B5%D1%82%D0%BA%D0%B8) будут удалены из любого запроса, но в запросах к `example.com` не будут удаляться совсем. Например: `http://google.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` будет преобразован в `http://google.com/page`, но `http://example.com/page?utm_source=s&utm_referrer=fb.com&utm_content=img` вообще не будет затронут этим правилом блокировки.
> **Совместимость с другими модификаторами**
> Правила с `$removeparam` совместимы с [базовыми модификаторами](#basic-rules-common-modifiers), [модификаторами с ограничением по типу контента](#content-type-modifiers), а также с модификаторами `$important` и `$app`. Правила, содержащие другие типы модификаторов, будут считаться некорректными и не будут применены.
> **Обратите внимание**, что блокировку правил `$removeparam` также можно отключить с помощью правил исключений `$document` и `$urlblock`. Но базовые правила исключений без модификаторов не могут этого сделать. Например, `@@||example.com^` не отключит `$removeparam=p` для запросов к example.com, а вот `@@||example.com^$urlblock` — отключит.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$removeparam` поддерживаются в AdGuard для Windows, Mac, Android, а также браузерными расширениями AdGuard для Chrome, Firefox, Edge.
> **Ограничения.** Правила с модификатором `$removeparam` могут быть использованы **только в доверенных фильтрах** — то есть в **Пользовательских правилах** и всех фильтрах, разработанных командой AdGuard.
<a id="removeheader-modifier"></a>
#### **`$removeheader`**
@ -1219,6 +1193,46 @@ AdGuard использует тот же синтаксис правил фил
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$removeheader` поддерживаются в AdGuard для Windows, Mac, Android и Браузерном расширении AdGuard для Chrome, Firefox, Edge.
<a id="noop-modifier"></a>
#### **`noop`**
Модификатор `noop` не делает ничего и может быть использован исключительно в целях улучшения читабельности правил. Он состоит из последовательности символов нижнего подчёркивания (`_`) любой длины и может фигурировать в правиле столько раз, сколько требуется.
##### Примеры `noop`:
```
||example.com$_,removeparam=/^ss\\$/,_,image
||example.com$replace=/bad/good/,___,~third-party
```
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `noop` не поддерживаются в AdGuard Content Blocker.
<a id="empty-modifier"></a>
##### **`empty` (устаревший)**
> **Предупреждение об устаревании.** Этот модификатор считаются устаревшими. Вместо него теперь используется [модификатор `$redirect`](#redirect-modifier). Правила с `$empty` конвертируются в `$redirect=nooptext`.
Обычно заблокированный запрос выглядит для браузера как ошибка сервера. В случае применения модификатора `$empty`, AdGuard эмулирует пустой ответ сервера со статусом `200 OK`.
###### Примеры `empty`
* `||example.org^$empty` — возвращает пустой ответ для всех запросов к домену `example.org` и всех его поддоменов.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$empty` не поддерживаются в AdGuard Content Blocker, AdGuard для Safari и для iOS.
<a id="mp4-modifier"></a>
##### **`mp4` (устаревший)**
> **Предупреждение об устаревании.** Этот модификатор считаются устаревшими. Вместо него теперь используется [модификатор `$redirect`](#redirect-modifier). Правила с `$mp4` конвертируются в `$redirect=noopmp4-1s,media`.
В качестве ответа на заблокированный запрос AdGuard возвращает короткую видео-заглушку.
###### Примеры `mp4`
* `||example.com/videos/$mp4` — блокирует загрузку видео с адресов `||example.com/videos/*` и заменяет ответ на видео-заглушку.
> **Совместимость с разными версиями AdGuard.** Правила с модификатором `$mp4` не поддерживаются в AdGuard Content Blocker, AdGuard для Safari и для iOS.
<a id="non-basic-rules"></a>
# Другие правила