Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
X4 opened this issue Aug 21, 2015 · 2 comments
Closed

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

X4 opened this issue Aug 21, 2015 · 2 comments

Comments

@X4
Copy link

X4 commented Aug 21, 2015

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>.

@X4 X4 changed the title Site Based Wildcard CSS ID Filter (Site Based) Wildcard CSS ID Filter Aug 21, 2015
@X4 X4 changed the title (Site Based) Wildcard CSS ID Filter (Site Based) Wildcard CSS ID Filter: #id* Aug 21, 2015
@ghost
Copy link

ghost commented Aug 21, 2015

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.

@gorhill
Copy link
Owner

gorhill commented Aug 21, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants