To block all elements that do NOT have a specific class (e.g., X) using uBlock Origin, you can use a cosmetic filter with the :not() CSS selector.
Use the following filter in uBlock Origin's dashboard under the Custom filters tab (or in the Cosmetic filters section for a specific site):
plaintextexample.com##:not(.X)
example.com → Replace with the domain(s) you want to apply the filter to. Use * for all sites.## → Indicates a cosmetic (element-hiding) filter.:not(.X) → Selects all elements except those with the class X.X on all sites:
plaintext*##:not(.X)
X on example.com:
plaintextexample.com##:not(.X)
<div> elements except those with class X:
plaintext*##div:not(.X)
example.com##:not(.X)).X, you need a different approach (e.g., using :matches-css() or script injection, which is more advanced).Le Chat can make mistakes. Check answers. Learn more