Ublock: (Site Based) Wildcard CSS ID Filter: #id*

Created on 21 Aug 2015  路  2Comments  路  Source: gorhill/uBlock

Hi,

if 碌Block origin could create a rule with the help of the element picker that filters all IDs starting with bsa via a rule #bsa* site-wide that would be awesome!

There are a few annoying anti-adblockers that effectively stop visitors from viewing the site unless ad-blockers are disabled. They have a div sitting ontop of the site, that is only removed, if no adblocker is detected. It's predictably creating these divs with IDs starting with #bsa<random-chars>.

Most helpful comment

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
http://www.w3.org/TR/css3-selectors/#selectors

[attr^=value]
    Represents an element with an attribute name of attr and whose value is prefixed by "value".
[attr$=value]
    Represents an element with an attribute name of attr and whose value is suffixed by "value".
[attr*=value]
    Represents an element with an attribute name of attr and whose value contains at least one occurrence of string "value" as substring.

Instead of
###bsa* (which doesn't work), try
##div[id*="bsa"] for contains bsa, or better yet,
##div[id^="bsa"] for prefixed by bsa.

All 2 comments

https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
http://www.w3.org/TR/css3-selectors/#selectors

[attr^=value]
    Represents an element with an attribute name of attr and whose value is prefixed by "value".
[attr$=value]
    Represents an element with an attribute name of attr and whose value is suffixed by "value".
[attr*=value]
    Represents an element with an attribute name of attr and whose value contains at least one occurrence of string "value" as substring.

Instead of
###bsa* (which doesn't work), try
##div[id*="bsa"] for contains bsa, or better yet,
##div[id^="bsa"] for prefixed by bsa.

could create a rule with the help of the element picker that filters all IDs starting with bsa via a rule #bsa*

It can, but the element picker won't do it for you. Hiding rules (cosmetic filters) are just plain CSS selectors:

In general, any CSS selector supported by Firefox can be used for element hiding. For example the following rule will hide anything following a div element with class "adheader": ##div.adheader + *. For a full list of CSS list see W3C CSS specification.

So in your case, a valid CSS selector:

##[id^="bsa"]

In uBlock it's not too complicated to do this:

  1. Pick the element to hide using the element picker.
  2. Click on one of the suggest cosmetic filter (they are ordered from narrower to broader).
  3. Edit the result in the text area to furtehr fine tune your cosmetic filter.

    • The element picker "assist" you because it will highlight elements on the page which match your filter.

    • If your filter is invalid, you won't be able to create it.

  4. The element picker _always_ create site-specific cosmetic filters.
Was this page helpful?
0 / 5 - 0 ratings