Safari Remove Custom Elements
Adguard for Mac avoids the restrictions placed on browser extensions. It intercepts http(s) connections from all apps (not just Safari) and applies its blocking rules.

As well as using blocklists linked to Adguard, you can create your own. So invent your own rules - limited only by your imagination!

And if you need a little help there is an active forum which includes a section for Custom Filters.