How to add whitelisted domains when using Safari Content blocker

Hello,


What's the proper way to create whitelists when using Safari content blocker API?https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ContentBlocker.html

Imagine I have an adult content blocker like this one, but instead of 3 domains, 50000. (I already did it and it works)


[

{

"action": {

"type": "block"

},

"trigger": {

"url-filter": ".*",

"if-domain": ["*xvideos.com", "********.com", "****.com"]

}

}

]

How should I add a whitelist? Do I have to create a second blocker with other rules or do I have to modify my adult content blocker to remove the whitelisted domains programatically in real time, generate another JSON and reloading it?

Thanks for suggestions.

Replies

There are a few possible ways to add a whitelist.


You could edit the content blocker like you mentioned, or you could do something with the "ignore-previous-rules" action available to content blockers.


https://developer.apple.com/documentation/safariservices/creating_a_content_blocker?language=objc