webRequest.RequestFilter
An object describing filters to apply to webRequest events.
Type
Values of this type are objects. They contain the following properties:
urls-
arrayofstring. An array of match patterns. The listener will only be called for requests whose targets match any of the given patterns. Only requests made using HTTP or HTTPS will trigger events, other protocols (such as data: and file:) supported by pattern matching do not trigger events.view-source:requests may be matched based on its inner URL. -
typesOptional -
arrayof. A list of resource types (for example, stylesheets, images, scripts). The listener will only be called for requests for resources which are one of the given types.webRequest.ResourceType -
tabIdOptional -
integer. The listener will only be called for requests from thetabidentified by this ID. -
windowIdOptional -
integer. The listener will only be called for requests from thewindowidentified by this ID. -
incognitoOptional -
boolean. If provided, requests that do not match the incognito state (trueorfalse) will be filtered out.
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
RequestFilter |
Yes
If a filter contains unrecognized values in its
types property, addListener() throws an exception. |
14
If a filter contains unrecognized values in its
types property, addListener() throws an exception. |
45
["From Firefox 78 onwards, if a filter contains unrecognized values in its
types property, then these values are ignored and addListener() proceeds.", "Before Firefox 78, if a filter contains unrecognized values in its types property, addListener() throws an exception."] |
? |
Yes
If a filter contains unrecognized values in its
types property, addListener() throws an exception. |
14 |
? |
? |
48
If a filter contains unrecognized values in its
types property, addListener() throws an exception. |
? |
? |
? |
tabId |
Yes |
14 |
53 |
? |
Yes |
14 |
? |
? |
53 |
? |
? |
? |
urls |
Yes |
14 |
45
Before Firefox 56, moz-extension:// URLs were not allowed.
|
? |
Yes |
14 |
? |
? |
48
Before Firefox 56, moz-extension:// URLs were not allowed.
|
? |
? |
? |
view-source |
Yes |
14 |
84 |
? |
Yes |
No |
? |
? |
No |
? |
? |
? |
windowId |
Yes |
14 |
53 |
? |
Yes |
14 |
? |
? |
53 |
? |
? |
? |
Note: This API is based on Chromium's chrome.webRequest API. This documentation is derived from web_request.json in the Chromium code.
© 2005–2021 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/webRequest/RequestFilter