Content blocker using Safari web extensions.

We are trying to implement ad blockers using the Safari web extension, and we are implementing this using the declarativeNetRequest, with a manifest version 2. We have added a json file which contains a rule set for over 22000 URLs, does content blocker have a limit to the number of rules we set in json?

Although it does work fine, sometimes we see the behaviour different on simulators and on clearing the cache it works fine is this expected?

Answered by Engineer in 791182022

The rule limit for a Safari content blocker is 150,000 rules, Safari Web Extension declarativeNetRequest rules are translated into content blocker rules, and that limit is also 150,000 rules. Additionally for Web Extensions, we have a limit of: 100 static rulesets 50 enabled rulesets 30,000 dynamic and session rules

I would say using a content blocker vs Safari Web Extension depends on what you are doing. What does your extension do? If you need to hide content on the page, currently that is only possible with Safari Content Blockers.

What is the different behavior you are seeing on simulators? What happens after you clear the cache?

We see that on simulator after we clear the cache the content is blocked and working as expected.

Is there a limit to the number of rules on content blocker using Safari web extension?

Would you recommend Safari content blocker extension or Safari web extension for the same functionality?

Accepted Answer

The rule limit for a Safari content blocker is 150,000 rules, Safari Web Extension declarativeNetRequest rules are translated into content blocker rules, and that limit is also 150,000 rules. Additionally for Web Extensions, we have a limit of: 100 static rulesets 50 enabled rulesets 30,000 dynamic and session rules

I would say using a content blocker vs Safari Web Extension depends on what you are doing. What does your extension do? If you need to hide content on the page, currently that is only possible with Safari Content Blockers.

We are creating an extension to block the ads on Safari.

Could you please elaborate this-- "Additionally for Web Extensions, we have a limit of: 100 static rulesets 50 enabled rulesets 30,000 dynamic and session rules"

Content blocker using Safari web extensions.
 
 
Q