declarativeNetRequest.updateSessionRules
修改扩展的一组作用域规则。首先移除 options.removeRuleIds
中列出的规则的 ID,然后添加 options.addRules
中列出的规则。请注意:
- 此更新作为原子操作进行:要么所有指定的规则都添加和移除,要么返回错误。
- 这些规则不会跨浏览器会话保留。
MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES
是扩展可以添加的动态和会话规则的最大数量。
语法
js
let updatedRuleset = browser.declarativeNetRequest.updateSessionRules(
options // 对象
);
参数
options
-
包含要从动态规则中添加或删除的规则的详细信息的对象。
addRules
可选-
一个
declarativeNetRequest.Rule
数组。要添加的规则的详细信息。 removeRuleIds
可选-
一个
number
数组。要移除的规则的 ID。任何无效的 ID 都将被忽略。
返回值
一个 Promise
。如果请求成功,其会被兑现且不带参数。如果请求失败,则 promise 将被拒绝并带有错误消息。
示例
示例扩展
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
updateSessionRules |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.