Skip to content

Commit 1f0bcc6

Browse files
Merge pull request #751 from AdguardTeam/feature/AG-43463
Add description of the new $reason modifier
2 parents 1fbb015 + 078a2ef commit 1f0bcc6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/general/ad-filtering/create-own-filters.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,7 @@ These modifiers are able to completely change the behavior of basic rules.
14181418
| [$removeparam](#removeparam-modifier) |||[*[6]](#removeparam-modifier-limitations) |||||
14191419
| [$replace](#replace-modifier) ||||||||
14201420
| [$urltransform](#urltransform-modifier) ||||||||
1421+
| [$reason](#reason-modifier) ||||||||
14211422
| [noop](#noop-modifier) ||||||||
14221423
| [$empty 👎](#empty-modifier "deprecated") ||||||||
14231424
| [$mp4 👎](#mp4-modifier "deprecated") ||||||||
@@ -3012,6 +3013,42 @@ Rules with the `$urltransform` modifier are supported by AdGuard for Windows, Ad
30123013
30133014
:::
30143015
3016+
#### **`$reason`** {#reason-modifier}
3017+
3018+
The `$reason` modifier allows you to add a custom explanation message that will be displayed on the blocking page when a request is blocked by this rule.
3019+
This modifier only works with the `$document` content-type modifier.
3020+
3021+
**Character limitations and escaping requirements:**
3022+
3023+
- There is no maximum length limit for the reason text
3024+
- All characters are allowed in the reason text
3025+
- Special characters (such as quotes, commas, and backslashes) must be properly escaped using the backslash (`\`)
3026+
3027+
**Predefined localizable tokens:**
3028+
3029+
Instead of custom text, you can use predefined tokens that will be automatically localized:
3030+
3031+
- `malicious`for malicious content
3032+
- `tracker`for tracking content
3033+
- `disreputable`for disreputable content
3034+
3035+
**Examples**
3036+
3037+
```adblock
3038+
||example.com^$document,reason="Tracker"
3039+
||example.com^$document,reason="Malicious site blocked by security filter"
3040+
||ads.example.com^$document,reason="This site contains tracking scripts"
3041+
||malware.example.com^$document,reason="Site blocked: \"Known malware distributor\""
3042+
||tracking.example.com^$document,reason=disreputable
3043+
||analytics.example.com^$document,reason=tracker
3044+
```
3045+
3046+
:::info Compatibility
3047+
3048+
AdGuard for Windows, AdGuard for Mac, AdGuard for Android, and AdGuard for Linux with CoreLibs v1.20 or later support rules with the `$reason` modifier. AdGuard Content Blocker does not support these rules.
3049+
3050+
:::
3051+
30153052
#### **`noop`** {#noop-modifier}
30163053
30173054
`noop` modifier does nothing and can be used solely to increase rules' readability. It consists of a sequence of underscore characters (`_`) of arbitrary length and can appear in a rule as often as needed.

0 commit comments

Comments
 (0)