Migrating CSS Content Blocker to Web Extension

Hi,

In the WWDC23 session “What’s new in Safari extensions,” the presenter says:

There are four ways to build Safari extensions: content blockers, share extensions, app extensions, and web extensions.

Safari 17 continues to support all of these types, but the future of browser customization lies in web extensions.

I take that to mean that content blocker extensions won’t be supported indefinitely, so I would like to get ahead of this by migrating my CSS content blocker to a web extension. However, I don’t see an API which allows for declarative CSS blocking in the same privacy-preserving way.

I like the current way of building CSS content blockers because I can block page content without requesting any additional permissions. This provides a very smooth user experience, but I don’t see any way to do this using Safari web extensions.

This method of blocking content is even referenced in the video, but only as a way to draw parallels to Declarative Net Request. Did I miss a change that allows me to build a privacy-preserving CSS content blocker in a web extension?

Accepted Answer

You haven't missed anything, there is no way to declaratively hide content using CSS with Web Extensions. Content Blockers are still the best way to do that and ensure your user's privacy. Declarative CSS blocking has been a topic of discussion in the WebExtension Community Group. We'd appreciate your feedback on uses cases and ideas for declarative CSS blocking, please tell us more at https://feedbackassistant.apple.com or join the discussion in the WECG at https://github.com/w3c/webextensions.

Migrating CSS Content Blocker to Web Extension
 
 
Q