What uBlock allows removing a given `class`, while only knowing the prefix of this `class`?
Feb 13, 1:06pm

To remove a CSS class in uBlock Origin when you only know the prefix of the class, you can use the :remove-class() operator in combination with a wildcard selector. Here’s how you can do it:

Method 1: Using :remove-class() with a Wildcard

If the class name starts with a known prefix (e.g., prefix-), you can use the following syntax in your uBlock Origin custom filter:

text
example.com##[class^="prefix-"]:remove-class(/^prefix-/)
  • [class^="prefix-"] selects all elements whose class attribute starts with prefix-.
  • :remove-class(/^prefix-/) removes all classes that start with prefix- from those elements.

Method 2: Using :watch-attr() for Dynamic Classes

If the class is added dynamically, you can use :watch-attr() to monitor changes and remove the class as soon as it appears:

text
example.com##[class^="prefix-"]:watch-attr(class):remove-class(/^prefix-/)

Notes:

  • This approach requires uBlock Origin 1.15.0 or later.
  • The /^prefix-/ is a regular expression that matches any class starting with prefix-.

References:

  • uBlock Origin Wiki: Static Filter Syntax
  • Stack Overflow: Remove class dynamically using uBlock Origin

Would you like help crafting a specific filter for your use case?

Feb 13, 1:06pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Le Chat can make mistakes. Check answers. Learn more