You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Filters containing classes with double dashes are ignored #1885
Custom filters that specify an element with a class name that contains a double dash (or double underscore) are ignored. This issue is reproducible for any page with an element whose class name contains a double dash or double underscore.
For example, say I want to block the top navigation bar that peeks in on Medium sites when you scroll the site up. My filter is:
It's not the double-dash, it's because the class .metabar--affixed is added/removed as one scroll up/down. uBO does not listen to class/id changes in its mutation observer.
In any case, this is not ideal as a cosmetic filter (because it is removed/added dynamically), .metabar--postArticle (or even better because specific filters are always better: medium.com##.metabar--postArticle) works better here, as it is a permanent class on the div.
Edit: Ok, I can see the benefit of using .metabar--affixed, it just prevents the top bar from floating while scrolling, while not getting rid of it completely. I have a fix locally, but I want to better evaluate its impact.
What's interesting is that on some other sites (e.g., this) uBlock accommodates the dynamic addition of classes:
Navigate to this article. The header bar peeks in when scrolling up. With dev tools, we see that scrolled-up is one of the classes dynamically added to the element.
Because specific filters are used in your arstechnica.com example. Specific filters (ex. arstechnica.com##header.scrolled-up) are always injected, but generic ones (ex. ##header.scrolled-up) are injected only after uBO's DOM surveyor finds a match. Not watching for class/id changes prevent uBO from finding out whether new generic filters must be injected when a new class or id is merely added to an existing DOM element.
These filters don't work because there is no div with class with socialLink substring in it, there are a elements with class footer__socialLink___1Iby-, and there is a div element with a data-testid attribute set to socialLinksContainer.
By the way, how did you come to create the filter with a div with the element picker? The element picker would have found no match on the page, and in such case it won't let you create the filter.
Listening to class/id changes would affect negatively performance, so such cases have will have to be worked around using either specific cosmetic filters, and specific-generic cosmetic filters will have to be used in case the filter is meant to apply everywhere.
Activity
gorhill commentedon Aug 9, 2016
I can't find any element with the class
.metabar--affixedon the test page. This is what dev console says:gorhill commentedon Aug 9, 2016
Never mind, got it while scrolling up, as you said.
gorhill commentedon Aug 9, 2016
It's not the double-dash, it's because the class
.metabar--affixedis added/removed as one scroll up/down. uBO does not listen to class/id changes in its mutation observer.In any case, this is not ideal as a cosmetic filter (because it is removed/added dynamically),
.metabar--postArticle(or even better because specific filters are always better:medium.com##.metabar--postArticle) works better here, as it is a permanent class on thediv.Edit: Ok, I can see the benefit of using
.metabar--affixed, it just prevents the top bar from floating while scrolling, while not getting rid of it completely. I have a fix locally, but I want to better evaluate its impact.danielyli commentedon Aug 9, 2016
What's interesting is that on some other sites (e.g., this) uBlock accommodates the dynamic addition of classes:
scrolled-upis one of the classes dynamically added to the element.arstechnica.com##header.site-header.is_stuck.scrolled-uparstechnica.com##header.scrolled-upgorhill commentedon Aug 9, 2016
Because specific filters are used in your
arstechnica.comexample. Specific filters (ex.arstechnica.com##header.scrolled-up) are always injected, but generic ones (ex.##header.scrolled-up) are injected only after uBO's DOM surveyor finds a match. Not watching forclass/idchanges prevent uBO from finding out whether new generic filters must be injected when a newclassoridis merely added to an existing DOM element.danielyli commentedon Aug 9, 2016
Ah, I see. Great, thanks for the explanation.
ryanbr commentedon Dec 24, 2017
I've started to notice a trend of a certain CMS's using the "__" div elements. Given the age of this bug, is going to be fixed?
Was trying to filter on tunein.com "##.footer__socialLink___1Iby-" Even the following didn't work;
gorhill commentedon Dec 24, 2017
The bug title is incorrect, it has nothing to do with double-dash, or any double-anything.
gorhill commentedon Dec 24, 2017
or
work fine for me.
gorhill commentedon Dec 24, 2017
These filters don't work because there is no
divwith class withsocialLinksubstring in it, there areaelements with classfooter__socialLink___1Iby-, and there is adivelement with adata-testidattribute set tosocialLinksContainer.ryanbr commentedon Dec 24, 2017
hmm annoying, right, doesn't show what type of element it is. Is there feature request to show the type of element being used when using the Picker?
gorhill commentedon Dec 24, 2017
There is #1736, which I interpret as wanting more controls over cosmetic filter crafting.
gorhill commentedon Dec 25, 2017
By the way, how did you come to create the filter with a
divwith the element picker? The element picker would have found no match on the page, and in such case it won't let you create the filter.gorhill commentedon Jul 10, 2021
Listening to
class/idchanges would affect negatively performance, so such cases have will have to be worked around using either specific cosmetic filters, and specific-generic cosmetic filters will have to be used in case the filter is meant to apply everywhere.