Is it possible to enable/disable the enabled flag before the extension is loaded? we want to have a button in our app which controls the availability of the content blocker ruleSet in declarative_net_request in manifest (version 2).
"declarative_net_request": { "rule_resources": [ { "id": "ruleset_1", "enabled": true, "path": "ruleset_1.json" } ] },
It sounds like the error might be due to exceeding the rule limit because the previous dynamic rules haven’t been removed before adding new ones. To address this, ensure that you’re clearing out the old dynamic rules first. You can do this by calling browser.declarativeNetRequest.getDynamicRules()
to inspect the current rules and then removing any unneeded ones with updateDynamicRules()
.
If you’re looking to toggle the enabled state of a static rule set directly from the manifest, you can use browser.declarativeNetRequest.updateEnabledRulesets()
. This will allow you to enable or disable static rule sets without dealing with the limits imposed on dynamic rules.
Since you mentioned working with thousands of rules, using static rules might be a more stable approach if the rule set won’t change dynamically too often. This way, you can toggle their availability via a button, ensuring you remain within the limits.