How do I exclude elements with a specific id from a filter in uBlock Origin?

6 days ago 7
ARTICLE AD BOX

I want to create a uBlock Origin filter that blocks all matching HTML elements except if it has a specific id value.

For example, let's say I had a page on example.com with the following elements:

<section id="advertisement"> Ads </section> <section id="promotion"> Promo </section> <section id="content"> Content I don't want to block </section> <section id="spam"> Spam </section> <section> Junk </section>

My goal is to block every section unless it has id="content". I tried using a not equals operator (!=), but it was invalid.

example.com##section[id!="content"]

I could write separate filters for each other possible ID. However, this would require making multiple rules, and it wouldn't cover section elements that don't have an ID.

How do I create a filter in uBlock Origin that excludes elements with a specific ID?

Read Entire Article