Details of the condition that determines whether a rule matches a request.
Details of the condition that determines whether a rule matches a request.
Values of this type are objects. They contain these properties:
domainType Optional
A string. Specifies whether the network request is first-party or third-party to the domain from where it originated. If omitted, all requests are accepted. Possible values are "firstParty" and "thirdParty".
domains Deprecated Optional
An array of string. Use initiatorDomains instead. The rule only matches network requests originating from this list of domains.
excludedDomains Deprecated Optional
An array of string. Use excludedInitiatorDomains instead. The rule does not match network requests originating from this list of domains.
initiatorDomains Optional
An array of string. The rule only matches network requests originating from this list of domains. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed. A canonical domain should be used. This matches against the request initiator and not the request URL.
excludedInitiatorDomains Optional
An array of string. The rule does not match network requests originating from this list of domains. If the list is empty or omitted, no domains are excluded. This takes precedence over initiatorDomains. A canonical domain should be used. This matches against the request initiator and not the request URL.
isUrlFilterCaseSensitive Optional
A boolean. Whether the urlFilter or regexFilter (whichever is specified) is case sensitive. Default is true in (older) versions of Chrome and Safari, and false in Firefox. There is consensus on defaulting to true across browsers in WECG issue 269.
regexFilter Optional
A string. Regular expression to match against the network request URL. Note that:
urlFilter or regexFilter can be specified.regexFilter must be composed of only ASCII characters. This is matched against a URL where the host is encoded in the punycode format (in case of internationalized domains) and any other non-ascii characters are URL encoded in utf-8.requestDomains Optional
An array of string. The rule only matches network requests when the domain matches one from this list. If the list is omitted, the rule is applied to requests from all domains. An empty list is not allowed. A canonical domain should be used.
excludedRequestDomains Optional
An array of string. The rule does not match network requests when the domains matches one from this list. If the list is empty or omitted, no domains are excluded. This takes precedence over requestDomains. A canonical domain should be used.
requestMethods Optional
An array of string. List of HTTP request methods that the rule matches. An empty list is not allowed. Specifying a requestMethods rule condition also excludes non-HTTP(s) requests, whereas specifying excludedRequestMethods does not.
excludedRequestMethods Optional
An array of string. List of request methods that the rule does not match on. Only one of requestMethods and excludedRequestMethods should be specified. If neither of them is specified, all request methods are matched.
resourceTypes Optional
An array of declarativeNetRequest.ResourceType. List of resource types that the rule matches with. An empty list is not allowed. This must be specified for "allowAllRequests" rules and may only include the "sub_frame" and "main_frame" resource types.
excludedResourceTypes Optional
An array of declarativeNetRequest.ResourceType. List of resource types that the rule does not match on. Only one of resourceTypes and excludedResourceTypes should be specified. If neither of them is specified, all resource types except "main_frame" are blocked.
tabIds Optional
An array of number. List of tabs.Tab.id that the rule should match. An ID of tabs.TAB_ID_NONE matches requests that don't originate from a tab. An empty list is not allowed. Only supported for session-scoped rules.
excludedTabIds Optional
An array of number. List of tabs.Tab.id that the rule should not match. An ID of tabs.TAB_ID_NONE excludes requests that do not originate from a tab. Only supported for session-scoped rules.
urlFilter Optional
A string. The pattern that is matched against the network request URL. Supported constructs:
^ may also match the end of the URL instead of a separator character. urlFilter is composed of the following parts: (optional left/domain name anchor) + pattern + (optional right anchor). If omitted, all URLs are matched. An empty string is not allowed. A pattern beginning with ||* is not allowed. Use * instead. Note that: urlFilter or regexFilter can be specified.urlFilter must be composed of only ASCII characters. This is matched against a URL where the host is encoded in the punycode format (in case of internationalized domains) and any other non-ASCII characters are URL encoded in utf-8. For example, when the request URL is http://abc.рф?q=ф, the urlFilter is matched against the URL http://abc.xn--p1ai/?q=%D1%84.Domains specified in initiatorDomains, excludedInitiatorDomains, requestDomains, or excludedRequestDomains should comply with the following:
To programmatically generate the canonical domain for a URL, use the URL API and read its hostname property, i.e., new URL(url).hostname.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
RuleCondition |
84 | 84 | No | ? | 70 | 15 | ? | ? | No | ? | 15 | ? |
domains |
84Deprecated in Chrome 101, useinitiatorDomains instead. |
84Deprecated in Edge 101, useinitiatorDomains instead. |
No | ? | 70Deprecated in Opera 87, useinitiatorDomains instead. |
15 | ? | ? | No | ? | 15 | ? |
excludedDomains |
84Deprecated in Chrome 101, useexcludedInitiatorDomains instead. |
84Deprecated in Edge 101, useexcludedInitiatorDomains instead. |
No | ? | 70Deprecated in Opera 87, useexcludedInitiatorDomains instead. |
15 | ? | ? | No | ? | 15 | ? |
excludedInitiatorDomains |
101 | 101 | No | ? | 87 | No | ? | ? | No | ? | No | ? |
excludedRequestDomains |
101 | 101 | No | ? | 87 | preview | ? | ? | No | ? | No | ? |
excludedRequestMethods |
91 | 91 | No | ? | 77 | No | ? | ? | No | ? | No | ? |
requestDomains |
101 | 101 | No | ? | 87 | 16.4 | ? | ? | No | ? | 16.4 | ? |
requestMethods |
91 | 91 | No | ? | 77 | No | ? | ? | No | ? | No | ? |
tabIds |
92 | 92 | No | ? | 78 | No | ? | ? | No | ? | No | ? |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/RuleCondition