Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/declarativenetrequest/getmatchedrules/index.md
6556 views
---
title: declarativeNetRequest.getMatchedRules slug: Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/getMatchedRules tags: - API - Add-ons - Extensions - Reference - WebExtensions - Method - declarativeNetRequest - getMatchedRules browser-compat: webextensions.api.declarativeNetRequest.getMatchedRules
---

{{AddonSidebar()}}

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 that 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 returned.

Syntax

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

Parameters

  • filter {{optional_inline}}

    • : An object to filter the list of matched rules.

      • minTimeStamp {{optional_inline}}

        • : A number. If specified, only matches rules after the specified timestamp.

      • tabId {{optional_inline}}

        • : 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

    • : {{WebExtAPIRef("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

{{WebExtExamples}}

Browser compatibility

{{Compat}}