MDN self-hosted library · e01.org

declarativeNetRequest.getMatchedRules()

Returns all the rules matched for the extension. Callers can filter the list of matched rules by specifying a filter. This method is only available to extensions with the "declarativeNetRequestFeedback" permission or have the activeTab permission granted for the tabId specified in filter. Rules not associated with an active document that were matched more than five minutes ago are not returned.

no runnable cells webextension-api-function upstream source

Returns all the rules matched for the extension. Callers can filter the list of matched rules by specifying a filter. This method is only available to extensions with the "declarativeNetRequestFeedback" permission or have the activeTab permission granted for the tabId specified in filter. Rules not associated with an active document that were matched more than five minutes ago are not returned.

Syntax

let gettingMatchedRules = await browser.declarativeNetRequest.getMatchedRules(
    filter                // object
);

Parameters

  • filter
  • : An object to filter the list of matched rules.
    • minTimeStamp
    • : A number. If specified, only matches rules after the specified timestamp.
    • tabId
    • : A number. If specified, only matches rules for the specified tab. Matches rules not associated with any active tab if set to -1.

Return value

A Promise that fulfills with an object with these properties:

  • rule
  • : declarativeNetRequest.MatchedRule. Details of a matched rule.
  • tabId
  • : number The tabId of the tab the request originated from if the tab is still active. Otherwise, -1.
  • timeStamp
  • : number The time the rule was matched. Timestamps correspond to the JavaScript convention for times, i.e., the number of milliseconds since the epoch.

If no rules are matched, the object is empty. If the request fail, the promise is rejected with an error message

Examples

Browser compatibility