Use the declarativeNetRequest API to block or modify network requests by specifying declarative rules.

Permissions: declarativeNetRequest, declarativeNetRequestWithHostAccess

Not allowed in: Content scripts, Devtools pages

_IsRegexSupportedRegexOptions
_IsRegexSupportedReturnResult
_RuleAction
_RuleActionRedirect
_RuleActionRequestHeaders
_RuleActionResponseHeaders
_RuleCondition
_TestMatchOutcomeOptions
_TestMatchOutcomeRequest
_TestMatchOutcomeReturnResult
_UpdateDynamicRulesOptions
_UpdateEnabledRulesetsUpdateRulesetOptions
_UpdateSessionRulesOptions
_URLTransformQueryTransform
_URLTransformQueryTransformAddOrReplaceParams
MatchedRule
Rule
URLTransform
_RuleActionRequestHeadersOperation
_RuleActionResponseHeadersOperation
_RuleActionType
_RuleConditionDomainType
_URLTransformScheme
ResourceType
UnsupportedRegexReason
DYNAMIC_RULESET_ID
GUARANTEED_MINIMUM_STATIC_RULES
MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES
MAX_NUMBER_OF_ENABLED_STATIC_RULESETS
MAX_NUMBER_OF_REGEX_RULES
MAX_NUMBER_OF_STATIC_RULESETS
SESSION_RULESET_ID
getAvailableStaticRuleCount
getDynamicRules
getEnabledRulesets
getSessionRules
isRegexSupported
testMatchOutcome
updateDynamicRules
updateEnabledRulesets
updateSessionRules
_RuleActionRequestHeadersOperation: "append" | "set" | "remove"

The operation to be performed on a header.

_RuleActionResponseHeadersOperation: "append" | "set" | "remove"

The operation to be performed on a header.

_RuleActionType:
    | "block"
    | "redirect"
    | "allow"
    | "upgradeScheme"
    | "modifyHeaders"
    | "allowAllRequests"
_RuleConditionDomainType: "firstParty" | "thirdParty"

Specifies whether the network request is first-party or third-party to the domain from which it originated. If omitted, all requests are matched.

_URLTransformScheme: "http" | "https" | "moz-extension"

The new scheme for the request.

ResourceType:
    | "main_frame"
    | "sub_frame"
    | "stylesheet"
    | "script"
    | "image"
    | "object"
    | "object_subrequest"
    | "xmlhttprequest"
    | "xslt"
    | "ping"
    | "beacon"
    | "xml_dtd"
    | "font"
    | "media"
    | "websocket"
    | "csp_report"
    | "imageset"
    | "web_manifest"
    | "speculative"
    | "other"

How the requested resource will be used. Comparable to the webRequest.ResourceType type.

UnsupportedRegexReason: "syntaxError" | "memoryLimitExceeded"

Describes the reason why a given regular expression isn't supported.

DYNAMIC_RULESET_ID: string

Ruleset ID for the dynamic rules added by the extension.

GUARANTEED_MINIMUM_STATIC_RULES: number

The minimum number of static rules guaranteed to an extension across its enabled static rulesets. Any rules above this limit will count towards the global static rule limit.

MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES: number

The maximum number of dynamic and session rules an extension can add. NOTE: in the Firefox we are enforcing this limit to the session and dynamic rules count separately, instead of enforcing it to the rules count for both combined as the Chrome implementation does.

MAX_NUMBER_OF_ENABLED_STATIC_RULESETS: number

The maximum number of static Rulesets an extension can enable at any one time.

MAX_NUMBER_OF_REGEX_RULES: number

The maximum number of regular expression rules that an extension can add. This limit is evaluated separately for the set of session rules, dynamic rules and those specified in the rule_resources file.

MAX_NUMBER_OF_STATIC_RULESETS: number

The maximum number of static Rulesets an extension can specify as part of the rule_resources manifest key.

SESSION_RULESET_ID: string

Ruleset ID for the session-scoped rules added by the extension.

  • Returns the remaining number of static rules an extension can enable

    Returns Promise<number>

  • Returns the ids for the current set of enabled static rulesets.

    Returns Promise<string[]>

  • Modifies the current set of dynamic rules for the extension. The rules with IDs listed in options.removeRuleIds are first removed, and then the rules given in options.addRules are added. These rules are persisted across browser sessions and extension updates.

    Parameters

    Returns Promise<void>

  • Modifies the current set of session scoped rules for the extension. The rules with IDs listed in options.removeRuleIds are first removed, and then the rules given in options.addRules are added. These rules are not persisted across sessions and are backed in memory.

    Parameters

    Returns Promise<void>