Update Safari Web Extension RuleSet files dynamically

If I build a Safari Web Extension and specify some rule set files for blocking in my manifest, is there any way to update either the manifest or the rule set files dynamically?

Or do I have to do a new app release every time the ruleset changes?

Thanks!

Answered by in 678681022

Hi brindy666!

Safari implements the JavaScript API browser.declarativeNetRequest.updateEnabledRulesets. This API lets you enable or disable individual rulesets declared in the manifest. 

There’s another API called browser.declarativeNetRequest.updateDynamicRules which lets you add content blocking rules without having to specify them in the manifest. (There’s also browser.declarativeNetRequest.updateSessionRules which adds rules that aren’t persisted across launches of the browser). Safari does not currently implement these APIs but if you’d like to see them implemented, please file feedback at feedbackassistant.apple.com.

Accepted Answer

Hi brindy666!

Safari implements the JavaScript API browser.declarativeNetRequest.updateEnabledRulesets. This API lets you enable or disable individual rulesets declared in the manifest. 

There’s another API called browser.declarativeNetRequest.updateDynamicRules which lets you add content blocking rules without having to specify them in the manifest. (There’s also browser.declarativeNetRequest.updateSessionRules which adds rules that aren’t persisted across launches of the browser). Safari does not currently implement these APIs but if you’d like to see them implemented, please file feedback at feedbackassistant.apple.com.

Update Safari Web Extension RuleSet files dynamically
 
 
Q