I would like to remove custom HTML elements from websites - mainly ad banners or it could be anything. It looks like this functionality is not allowed with the latest ad blockers in the extension gallery (please correct me if I am wrong). So far I have tried Ghostery Lite, Adblock, Ka-Block, UBlock, 1Block, etc.

I am curious if this could be done with a custom extension that I only use locally:

  • keep a list of unwanted HTML elements per site
  • remove elements on site visit

Before I spend hours on this, is this doable?

Mac OS X: 10.15.5 Safari: 13.1.1


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.


Before I spend hours on this, is this doable?

Yes. However, it would be a spectacular time suck trying continually maintain it.

A better (and my preferred) option is to do something at the network level and use pfBlockerNG or piHole. I personally use pfBlockerNG because I’m a big proponent of pfSense firewall routers (as well as FreeBSD). pf is also the default firewall found on macOS. Though, I’ve never tried running pfBlocker on macOS.

PiHole is a really interesting product in that it’s small enough to run on a Raspberry Pi or various other Linux distros. While I’ve done some preliminary experiments with it, I opted for pfBlockerNG because I’m a BSD guy and not much of a Linux fan. However, YMMV.

What do these things do?

Block elements at the network level based on a community supported blacklist. A more up-to-date and thorough list is available via subscription. So depending on your needs and risk tolerance, it could be a free solution. For instance, I use the community version for home and the subscription model for work and for my clients.

Better than Browser Plugins

(IMO) these are much better than browser plugins. Since they operate at the network layer and will protect your whole network rather than just a single browser. Additionally, there's no overhead you CPU needs yo deal with, even if it is negligible.

However, most important for me is the privacy aspect where plugins ask for access to things like your location, your browsing history and even your contacts. “Free” usually has a cost associated with it and it’s usually your privacy.

PiHole and pfBlockerNG use a different model, called “freemium.” The product is available for free, but premium services (like support or real-time black list updates) are available for a fee.

One of the benefits of using this approach was finding and blocking advertising domains things like my SmartTV (Samsung and LG)or internet connected radio (Sonus) were communicating with. You can’t address that with a browser plugin!

Finally, blocking these elements at the network level will free up quite a chunk of bandwidth you didn’t even realize was being consumed by advertising domains and trackers.

  • Do you still get 'turn off your ad-blocker to access our site' on some websites? And what can you do about these if you're blocking ads at the network level but want to view the site? – Richard Brockbank Jun 18 '20 at 23:39
  • 1
    No, because the script runs still Its just that when the ad is served up, nothing happens because it can’t make the connection – Allan Jun 19 '20 at 4:55

Yes, this is doable using SafariServices in a custom app. You could create a app which loads specific things you want to disable (for example, a list of domains or CSS selectors) and lets Safari know when that list is updated. You would then have to transform your list into something the Content Blocker Extension can parse and tell Safari to refresh its content blocking list. You could use this locally without having to sign it/submit it to the App Store.


Switch to Firefox and use uBlock Origin.

That is the short - in your face - answer. Hereafter, my reasoning and a more detailed answer to your question.

uBlock origin is a wide-spectrum blocker and provides exactly the functionality you need. It is not commercialized, maintained by the community and free to use. Beware that uBlock is something different than uBlock Origin (use the provided link above). In my opinion it is the best content- (and ad-) blocker available.

uBlock Origin for Safari used to be a thing as well, but since Safari 12 content blockers don't work as reliable in Safari anymore. Reasons for the change in Safari were discussed here, and this is also why other ad-blockers don't work as reliable in Safari anymore. This is likely not going to change in the near future. Therefore uBlock Origin for Safari was discontinued, and is no longer a viable option for current versions of Safari. Personally I cannot stand browsing the web without a sufficient customizable content-blocker. That's why the only option for me was to change to a different browser.

If you dislike Firefox after you tried it, uBlock Origin also works with any Chromium based browser (e.g. Brave, Chrome, Opera). Though one main reason to use Safari is the good power management on Laptops: Your notebook will last much longer compared to using any Chromium based browser. Hence I recommend Firefox. Needless to say that Chromium is the most popular, but maybe not be the most trustworthy engine when it comes to privacy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .