Details of the action to take if a rule is matched.
On this page
declarativeNetRequest.RuleAction
Type
Values of this type are objects. They contain these properties:
redirect
Optional-
declarativeNetRequest.Redirect
. Describes how the redirect should be performed. Only valid for redirect rules. requestHeaders
Optional-
declarativeNetRequest.ModifyHeaderInfo
. The request headers to modify for the request. Only valid ifRuleActionType
is"modifyHeaders"
. responseHeaders
Optional-
declarativeNetRequest.ModifyHeaderInfo
. The response headers to modify for the request. Only valid ifRuleActionType
is"modifyHeaders"
. type
Optional-
A
string
. The type of action to perform. Possible values are"block"
,"redirect"
,"allow"
,"upgradeScheme"
,"modifyHeaders"
, and"allowAllRequests"
. The use of the"redirect"
and"modifyHeaders"
actions require host permissions for the request and request initiator. The "block" and "upgradeScheme" actions also require host permissions unless the "declarativeNetRequest" permission is specified. Without these permissions, matching rules are ignored. See Permissions at declarativeNetRequest. for more information.
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 | |
RuleAction |
84 | 84 | No | ? | 70 | 15 | ? | ? | No | ? | 15 | ? |
requestHeaders |
86 | 86 | No | ? | 72 | 16.4 | ? | ? | No | ? | 16.4 | ? |
responseHeaders |
86 | 86 | No | ? | 72 | 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/RuleAction