Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add declarativeNetRequest #22644

Merged
merged 43 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
59611bd
Add declarativeNetRequest
rebloor Nov 30, 2022
b73189a
Added properties
rebloor Dec 2, 2022
0aef595
Add functions and events
rebloor Dec 5, 2022
d5750c5
Added manifest and permissions details
rebloor Dec 6, 2022
1005f78
Added API narrative + corrections
rebloor Dec 8, 2022
fd67a1e
Function > Method, deleted unused DomainType
rebloor Dec 8, 2022
6f75ef7
Merge branch 'main' into add-declarativeNetRequest
rebloor Dec 8, 2022
ac598a6
Suggestions from review
rebloor Dec 9, 2022
1b0d933
Removed references to MV3 and source boilerplate note
rebloor Dec 9, 2022
4b60d4e
Minor feedback updates
rebloor Dec 9, 2022
a8e4706
Dropping RequestMethod
rebloor Dec 9, 2022
d0a72a4
UpdateRuleOptions moved to updateDynamicRules and updateSessionRules
rebloor Dec 9, 2022
eef29ca
Merge branch 'main' into add-declarativeNetRequest
rebloor Dec 9, 2022
75928fc
correct folder name
rebloor Dec 9, 2022
47195a4
Merge branch 'main' into add-declarativeNetRequest
rebloor Dec 12, 2022
61d5928
testing + rule scope clarifications
rebloor Dec 12, 2022
fa603c0
Merge branch 'main' into add-declarativeNetRequest
rebloor Dec 13, 2022
4ea4944
nested type to additional object
rebloor Dec 15, 2022
c9fec37
Suggestions from review
rebloor Jan 25, 2023
1ad44ac
Deleted redundant files
rebloor Jan 26, 2023
e20426f
Tweaks to rules content
rebloor Jan 26, 2023
c18b1e8
Added extensionId to MatchedRule
rebloor Jan 27, 2023
2966fcf
Suggestions from review
rebloor Jan 30, 2023
d91086d
Added `options` & `includeOtherExtensions` to `testMatchOutcome`
rebloor Jan 30, 2023
346a58f
Merge branch 'main' into add-declarativeNetRequest
rebloor Feb 1, 2023
2133a45
Fix markdown issues
rebloor Feb 1, 2023
aac62de
Enable testing details links
rebloor Feb 1, 2023
453b060
RuleCondition feedback
rebloor Feb 1, 2023
75a53f3
Added details of types to ResourceType
rebloor Feb 1, 2023
15552f0
MatchedRule.rulesetId return value clarification
rebloor Feb 1, 2023
e52fd1d
Removed xbl from ResourceType in webRequest & declarativeNetRequest
rebloor Feb 3, 2023
d36fb76
Moved modify header precedence details
rebloor Feb 5, 2023
3769bbd
Apply suggestions from review
rebloor Feb 6, 2023
415f04f
Merge branch 'main' into add-declarativeNetRequest
rebloor Feb 6, 2023
524c495
Correct list markdown
rebloor Feb 7, 2023
dc0e5c5
Note about ModifyHeaderInfo.operation limitations
rebloor Feb 8, 2023
b6a0f4b
ModifyHeaderInfo BCD added to RuleAction
rebloor Feb 8, 2023
b236295
typo `redirect` to `responseHeaders`
rebloor Feb 10, 2023
a70ccae
Apply suggestions from review
rebloor Feb 10, 2023
2789805
BCD for ModifyHeaderInfo represented by RuleAction.requestHeaders & R…
rebloor Feb 12, 2023
98c2f98
Merge branch 'main' into add-declarativeNetRequest
rebloor Feb 12, 2023
7173fd6
Apply suggestions from review
rebloor Feb 12, 2023
3f5d857
Testing required preference comment
rebloor Feb 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: declarativeNetRequest.DYNAMIC_RULESET_ID
slug: Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/DYNAMIC_RULESET_ID
tags:
- DYNAMIC_RULESET_ID
- API
- Add-ons
- Extensions
- Reference
- WebExtensions
- Property
- declarativeNetRequest
- DYNAMIC_RULESET_ID
browser-compat: webextensions.api.declarativeNetRequest.DYNAMIC_RULESET_ID
---

{{AddonSidebar()}}

Ruleset ID for the dynamic rules added by the extension using {{WebExtAPIRef("declarativeNetRequest.updateDynamicRules","updateDynamicRules")}}.

Its value is `"_dynamic"`.

{{WebExtExamples}}

## Browser compatibility

{{Compat}}

<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: declarativeNetRequest.getAvailableStaticRuleCount
slug: Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/getAvailableStaticRuleCount
tags:
- API
- Add-ons
- Extensions
- Reference
- WebExtensions
- Method
- declarativeNetRequest
- getAvailableStaticRuleCount
browser-compat: webextensions.api.declarativeNetRequest.getAvailableStaticRuleCount
---

{{AddonSidebar()}}

Returns the number of static rules that can be activated before the global static rule limit is reached.

## Syntax

```js-nolint
let count = await browser.declarativeNetRequest.getAvailableStaticRuleCount();
```

### Parameters

This function takes no parameters.

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with a number that indicates how many static rules can enable before the global static rule limit is reached. If the request fails, the promise is rejected with an error message.

## Examples

{{WebExtExamples}}

## Browser compatibility

{{Compat}}

<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: declarativeNetRequest.getAvailableStaticRuleCount
slug: Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/getDynamicRules
tags:
- API
- Add-ons
- Extensions
- Reference
- WebExtensions
- Method
- declarativeNetRequest
- getDynamicRules
browser-compat: webextensions.api.declarativeNetRequest.getDynamicRules
---

{{AddonSidebar()}}

Returns the set of dynamic rules for the extension.

## Syntax

```js-nolint
let gettingDynamicRules = browser.declarativeNetRequest.getDynamicRules();
```

### Parameters

This function takes no parameters.

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) is fulfilled with an array of {{WebExtAPIRef("declarativeNetRequest.Rule")}} objects. Each of these represents a rule that belongs to the extension. If no rules are active, the array is empty. If the request fails, the promise is rejected with an error message.

## Examples

{{WebExtExamples}}

## Browser compatibility

{{Compat}}

<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: declarativeNetRequest.getEnabledRulesets
slug: Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest/getEnabledRulesets
tags:
- API
- Add-ons
- Extensions
- Reference
- WebExtensions
- Method
- declarativeNetRequest
- getEnabledRulesets
browser-compat: webextensions.api.declarativeNetRequest.getEnabledRulesets
---

{{AddonSidebar()}}

Returns the IDs for the set of activated static rulesets.

## Syntax

```js-nolint
let rulesetIds = await browser.declarativeNetRequest.getEnabledRulesets();
```

### Parameters

This function takes no parameters.

### Return value

A [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) fulfilled with an array of string containing static rulesets IDs. If no rules are active, the array is empty. If the request fails, the promise is rejected with an error message.

## Examples

{{WebExtExamples}}

## Browser compatibility

{{Compat}}

<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
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

```js-nolint
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`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/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}}

<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Loading