Static filter syntax·续1
Filter will match on requests to other than currently visited domain.
all
New in 1.20.0.
The all option is equivalent to specifying all network-based types + popup, document, inline-font and inline-script.
Example:
||bet365.com^$all
Above will block all network requests, block all popups and prevent inline fonts/scripts from bet365.com. The EasyList-compatible syntax does not allow this when using only ||bet365.com^.
badfilter
Used to disable an existing filter. Occasionally disabling a blocking filter is better than creating an exception filter. Just for example's sake, let's say that a mind-absent filter list maintainer added the following filter to their list:
*$image
Now all images from everywhere are blocked on your side. An exception filter (@@*$image) is not a good solution because it would also cause images that should get blocked legitimately to no longer be blocked. In such case, the badfilter option is best:
*$image,badfilter
It will cause the *$image filter to get discarded. Appending the badfilter option to any instance of static network filter will prevent the loading of that filter.
After 1.19.0, any filter which fulfills ALL the following conditions:
-
Is of the form
|https://or|http://or*; and -
Does have a
domain=option; and -
Does not have a negated domain in its
domain=option; and -
Does not have
cspoption; and -
Does not have a
redirect=option
Will process in a certain way:
-
The
domain=option will be decomposed to create as many distinct filters as there are values in thedomain=option. -
It now becomes possible to
badfilteronly one of the distinct filters without having tobadfilterthem all. -
The logger will always report these special filters with only a single hostname in the
domain=option.
css
Equivalent to stylesheet option. For convenience.
cname
<sup>Framework compatibility: Firefox MV2-only</sup>
New in 1.26.0.
When used in an exception filter, it will bypass blocking CNAME uncloaked requests for the current (specified) document.
Network requests resulting from resolving a canonical name are subject to filtering. Creating exception filters using the cname option can bypass this filtering.
Example:
@@*$cname
The filter above tells the network filtering engine to accept network requests which fulfill all the following conditions:
-
network request is blocked
-
network request is that of an unaliased hostname
Filter list authors are discouraged from using exception filters of the cname type unless there is no other practical solution such that the maintenance burden becomes the more significant issue. These exception filters should be as narrow as possible. For example, they apply to a specific domain, etc.
denyallow
New in 1.26.0.
The purpose of denyallow is to bring default-deny/allow-exceptionally ability into the static network filtering arsenal.
Example:
*$3p,script,denyallow=x.com|y.com,domain=a.com|b.com
The above filter tells the network filtering engine when the context is a.com or b.com; it needs to block all 3rd-party scripts except those from x.com and y.com.
Note that the domain= option is required!
Essentially, the new denyallow option makes it easier to implement default-deny/allow-exceptionally in static filter lists. It had to be done before with unwieldy regular expressions[1] or through the mix of broadly blocking and exception filters[2].
"Entity" wildcard matching is not supported.
[1] https://hg.adblockplus.org/ruadlist/rev/f362910bc9a0
[2] Typically filters whose patterns are of the form |http*://
See also: to
document
Alias: doc
It is a type option (like image or script) that specifies the main frame (a.k.a. the root document) of a web page. This option is automatically enabled in filters indicating only the host part of the URL (see "HOSTS files" section), causing web pages that match the filter to get subjected to "Strict blocking".
See also: all
domain
Alias: from
Restrict the filter to be applied only on the specified domain(s).
Use the | symbol to join multiple domains.
Preceding the domain name by ~ will prevent the filter from being applied on this domain.
Starting with 1.28.0 support for "entity" matching has been added. You can now use filter$domain=google.* to apply a filter to pages on all top-level domains of the specified domain.
Example:
||doubleclick.net^$script,domain=auto-motor-und-sport.de
||adnxs.com^$domain=bz-berlin.de|metal-hammer.de|musikexpress.de|rollingstone.de|stylebook.de
/adsign.$domain=~adsign.no
Starting with 1.46.1b17 support for regex-based values has been added. Example of usage:
@@*$ghide,domain=/img[a-z]{3,5}\.buzz/
Related discussion: uBlockOrigin/uBlock-issues#2234
Regex-based domain values can be negated just like plain or entity-based values:
*$domain=~/regex.../
elemhide
Alias: ehide
Before uBO 1.23.0, this was being translated internally to generichide.
When used in an exception filter, this will turn off all cosmetic filtering on matching pages.
first-party
Equivalent to ~third-party option. Provided strictly for convenience (0.9.9.0).
frame
Equivalent to subdocument option. For convenience.
from
New in 1.46.1b0.
It is just an alias for the domain= option. The logger will render domain= network filters using the from= version.
See: domain
generichide
Alias: ghide.
When used in an exception filter, it will turn off generic cosmetic filtering on matching pages.
Generic cosmetic filters are hiding filters that apply to all pages - ##.ad-class.
header
New in 1.32.0. As of 1.52.3b16 it is enabled by default<sup>[1]</sup>
Ability to filter network responses according to whether a specific response header is present and whether or not it matches a distinct value.
For example:
*$script,header=via:1.1 google
The above filter blocks network requests of type script, which has a response HTTP header named via, which value matches the string 1.1 google literally.
The header value can get set to a regex literal by bracing the header value with the usual forward slashes, /.../:
*$script,header=via:/1\.1\s+google/
The header value can be prepended with ~ to reverse the comparison:
*$script,header=via:~1.1 google
The header value is optional and may be left out to test only for the presence of a specific header:
*$script,header=via
Using generic exception filters to disable specific block header= filters, i.e. @@*$script,header will override the block header= filters given in the example above.
Important: Filter authors must use as many narrowing filter options as possible when using the header= option and only use the header= option when other filter options are insufficient.
A potential use case is to block Google Tag Manager scripts proxied as the first party in the subdomain of the websites:
*$1p,strict3p,script,header=via:1.1 google
Where connection:
-
is weakly 1st-party to the context.
-
is not strictly 1st-party to the context.
-
is of type
script. -
has a response HTTP header named
viawhose value matches1.1 google.
Block requests whose responses have the Set-Cookie header with any value:
||example.com^$header=set-cookie
Unblock requests whose responses have the Set-Cookieheader with value matching the foo, bar$ regular expression:
@@||example.com^$header=set-cookie:/foo\, bar\$/
To remove response headers, see: Response header filtering.
important
The filter option important means to ignore all exception filters (those prefixed with @@). It will allow you to block specific network requests with 100% certainty.
It applies only to network block filters
Example: ||google-analytics.com^$important,third-party will block all network requests to google-analytics.com, disregarding any existing network exception filters.
inline-script
Disable inline script tags in the main page via CSP: ||example.com^$inline-script.
See also: csp
inline-font
Disable inline font tags in the main page via CSP: ||example.com^$inline-font.
ipaddress
<sup>Framework compatibility: Firefox MV2-only</sup>
New in 1.60.0.
The purpose is to block according to the IP address of a network request.
Firefox-based browsers: full support. Chromium-based browsers: only when the IP address is used directly in the URL in lieu of a hostname.
The value assigned to ipaddress can be ...
- ... a plain string which must match exactly a given IP address<br>
e.g. ipaddress=192.168.1.1 to match exactly IP address 192.168.1.1
- ... a plain string followed by a wildcard at the end to match IP addresses starting with the pattern<br>
e.g. ipaddress=192.168.* to match IP addresses starting with 192.168. (wildcards inside: 192.168.*.1 or at the beginning: *.168.1.1 are not supported, but a regex can be used in such cases)
- ... a regex which will be matched against the IP address<br>
e.g. ipaddress=/^192.168.1.\d{1-2}/ to match IP address between 192.168.1.0 and 192.168.1.99.
-
...
lanto match IP addresses reserved for private networks<br> -
...
loopbackto match IP addresses reserved for loopback
Examples:
*$script,ipaddress=93.184.215.14
||xyz/|$xhr,3p,method=head,ipaddress=/^139\.45\.19[5-7]\./
*$all,ipaddress=::,domain=~0.0.0.0|~127.0.0.1|~[::1]|~[::]|~local|~localhost
*$ipaddress=93.184.*
*$method=post,ipaddress=lan
Cached resources do not have a valid IP address and thus can't be a match to ipaddress option.
The ipaddress value is not validated, so you can enter anything. Only one ipv4 or ipv6 address or regex is valid.
Exclusions ~ and | operators are not supported, e.g. ipaddress=~192.168.1.1 or ipaddress=192.168.1.1|192.168.8.4, however as partial solution a regex can be used, examples:
(...) ipaddress=/^(?!95\.216\.7\.22|9\.9\.9\.9).*$/
(...) ipaddress=/^((?!95\.216\.7\.22|9\.9\.9\.9).)*$/
but the above regex solution is not perfect:
-
the first above regex excludes too much:
95.216.7.22ywhich is unwanted (whereyis any digit, for example95.216.7.228) -
the second above regex even worse, excludes too much:
x95.216.7.22y(wherexand/oryis any digit, for example195.216.7.22or95.216.7.221or195.216.7.221)
But still some users might find them useful.
<details><summary>Technical notes</summary>
First commit in 1.59.1b15. Related commit: 1.59.1b17, 1.59.1b19, 1.59.1rc1, 1.59.1rc4*.
Lan/loopback values are supported (since 1.59.1b17), related issue: Possibility of Blocking Requests to localhost and Reserved IP Addresses by websockets?.
Browser-provided 0.0.0.0 IP address will be ignored when DNS is proxied (since 1.59.1rc1), related issue: Some rules may break websites that use socks proxy in Firefox.
Cname uncloaking code has been rewritten to account for the ipaddress option (since 1.59.1b19), related issue: Add AdGuard's $network support on Firefox. This commit makes the DNS resolution code better suited for both filtering on cname and IP address. The change allows early availability of IP address so that ipaddress option can be matched at onBeforeRequest time. As a result, it is now possible to block root document using ipaddress option -- so long as an IP address can be extracted before first onBeforeRequest() call.
</details>
match-case
New in 1.31.1b8.
It is only for Regular Expression filters. Using this with any other filter will cause uBO to discard the filter.
Instructs uBO filtering engine to perform a case-sensitive match.
method
New in 1.46.1b0.
Related issue: uBlockOrigin/uBlock-issues#2117.
Ability to filter network requests according to their HTTP method.
This option supports a list of |-separated lowercased method names. Negated method names are allowed.
