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

Cosmetic filters not working on many websites with "Experimental Web Platform features" in chrome://flags #1751

Closed
5 of 6 tasks
sauravyad500 opened this issue Oct 5, 2021 · 35 comments
Labels
bug Something isn't working Chromium specific to Chromium/Chrome

Comments

@sauravyad500
Copy link

sauravyad500 commented Oct 5, 2021

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

URL(s) where the issue occurs

https://timesofindia.indiatimes.com/home/education/news/upsc-indian-forest-service-mains-interview-schedule-announced/articleshow/86091072.cms
https://www.ndtv.com/india-news/farmers-call-off-agitation-in-up-after-promises-of-compensation-2563188#pfrom=home-ndtv_topscroll

Describe the issue

The cosmetic filters that I apply manually via "Element picker mode" are saved in my filter lists. When I click on preview, the selected element disappears from the page. After clicking on pick and reloading the page, those same elements appear again. There is no change in their class or id. I had checked in the filter list also, they are there.

These are some of the websites on which it is not working.

Screenshot(s)

No response

uBlock Origin version

1.38.2

Browser name and version

Microsoft Edge 96.0.1033.0 (Official build) canary (64-bit)

Settings

! 2021-10-05 https://timesofindia.indiatimes.com
timesofindia.indiatimes.com##.article-content-wrapper.clearfix.wrapper > .sidebar

in the filter list and javascript is also blocked in the ublock origin for this website

Notes

This seems to be some issue with filter lists as after every alternate update my filters break. Facing this problem since 1.37 has been launched.

@uBlock-user uBlock-user transferred this issue from uBlockOrigin/uAssets Oct 5, 2021
@uBlock-user
Copy link
Contributor

uBlock-user commented Oct 5, 2021

After clicking on pick and reloading the page, those same elements appear again.

https:/gorhill/uBlock/wiki/Element-picker#element-picker-does-not-work-removed-element-reappears-when-you-reload-the-page

@gorhill
Copy link
Member

gorhill commented Oct 5, 2021

Since I can't reproduce, whoever can reproduce such issue will have to investigate the cause of it.

@uBlock-user uBlock-user added the unable to reproduce cannot reproduce the issue label Oct 5, 2021
@intrnl
Copy link

intrnl commented Oct 6, 2021

I'm having the same issues with cosmetic filtering not applying on both Chrome and Edge for at least one or two months now. I've been trying to repro with no avail, what I do know is that wiping my entire user data clean does the charm 🤷

@gorhill
Copy link
Member

gorhill commented Oct 6, 2021

wiping my entire user data clean does the charm

If you experience such issue, please report useful details along the report, just pointing out you suffer the same issue does not help. For all I know, it could be a misconfiguration issue such as broad exception filters or subscribing to bad filter lists (example). Resetting to default settings/lists will typical resolve such issue when the cause is bad filters/rules/lists.

@PF4Public
Copy link

PF4Public commented Oct 9, 2021

FWIW I noticed this after updating Chromium to 94 (or maybe 93) on Linux. Didn't change settings/filters for a long time. This also happened to my Vivaldi installation on Windows.

EDIT: reinstalling extension fixed this issue for me.

@sauravyad500
Copy link
Author

Found a temporary solution. After I uncheck "Parse and enforce cosmetic filters" , all my filters started working on the all those website I was facing problem with.

It seems like there is some glitch with this option or manual custom filters don't work when I check this option. But strangely this happens only on some site.

Facing this on two more sites https://www.coolztricks.com/ and https://timesofindia.indiatimes.com/world/china/taiwan-rejects-chinas-path-amid-show-of-military-force/articleshow/86913666.cms

@gorhill
Copy link
Member

gorhill commented Oct 10, 2021

manual custom filters don't work when I check this option

So possibly I might be able to reproduce if I have the same custom filters? Can you share?

It's quite possible that some very specific problematic cosmetic filters are wholly breaking cosmetic filtering -- though uBO is supposed to detect such problematic cosmetic filters and discard them.

@gorhill
Copy link
Member

gorhill commented Oct 10, 2021

Facing this on two more sites https://www.coolztricks.com/

I went to https://www.coolztricks.com/ in Microsoft Edge (dev) 95.0 for linux, created the filter www.coolztricks.com##.inside-right-sidebar to remove the right-hand side bar, forced a reload of the page, and the side bar was properly hidden as expected. Using default up to date filter lists and settings.

@PatchMixolydic
Copy link

PatchMixolydic commented Oct 11, 2021

Something similar is happening to me: I've been using twitter.com##[aria-label="Timeline: Trending now"] to block the Twitter trends sidebar on https://twitter.com for a while now, but it broke after a Chrome update. Adding that filter while I have Twitter open successfully removes the sidebar every time, but it reappears after refreshing the page. The trends sidebar always has that attribute when using English Twitter (I think it's translated in other languages). I'm using uBlock Origin 1.38.2 and Chrome for Linux Version 94.0.4606.81 (Official Build) (64-bit).

Unchecking "Parse and enforce cosmetic filters" doesn't seem to fix the issue for me (inuitively, it makes it worse by showing even more of the topics bar). Reinstalling the extension doesn't seem to have helped either. Unfortunately, I'm not well-equipped to diagnose the issue, as I'm incredibly ill-versed in JavaScript.

@PatchMixolydic
Copy link

PatchMixolydic commented Oct 11, 2021

After following those instructions, the Twitter trends sidebar was blocked successfully. After some trial and error, it seems like using any of these filters (alone or together) breaks custom filters (but not the default filters):

twitter.com##div[aria-label^="Timeline:"]:not([aria-label$="Topics"]):not([aria-label$="Explore"]) .r-qklmqi:has([aria-labelledby*="topic-not-interested-button"])
twitter.com##div[aria-label^="Timeline:"]:not([aria-label$="Topics"]):not([aria-label$="Your Lists"]) .r-1adg3ll:has(div[aria-label="Timeline: Carousel"])
twitter.com##div[aria-label^="Timeline:"]:not([aria-label$="Lists"]):not([aria-label$="List"]) div[style^="position: absolute;"]:not(:has(article)):has(a[href^="/i/lists/"])
twitter.com##div[aria-label="Timeline: Your Lists"] div[style^="position: absolute;"]:has(a[href="/i/lists/suggested"])

None of these seem to be related to the trends bar from a quick glance (they are intended to block various other nuisances). Should I file this as a separate issue, or is this expected behaviour given the structure of the Twitter website?

Edit: I seem to be having a similar issue on https://old.reddit.com: promoted posts (ads) aren't filtered. The filter reddit.com##.promotedlink should do it, and I believe it should be in one of the filter lists, but the ads still appear. Sidebar ads, however, are blocked. This seems to be caused by the "uBlock Filters" list; disabling it and enabling the other default filters seems to remove promoted posts even without a custom filter.

@sauravyad500
Copy link
Author

sauravyad500 commented Oct 11, 2021

Found the culprit. For me whenever I use filter list named "AdGuard Base" with "Parse and enforce cosmetic filters" as checked, I face the issue. And when I uncheck the "AdGuard Base". The issue disappears.

Something is clashing with AdGuard Base

@uBlock-user uBlock-user added the filterlist a filter list issue label Oct 11, 2021
@uBlock-user uBlock-user added invalid not a uBlock issue and removed unable to reproduce cannot reproduce the issue labels Oct 11, 2021
@uBlock-user
Copy link
Contributor

Report AdGuard filters list issues at https:/AdguardTeam/AdguardFilters/issues

@uBlock-user
Copy link
Contributor

PatchMixolydic try reporting the issue on uAssets tracker,

Why ? He's using custom filters that are not part of the default filter lists, will be closed and marked as invalid too. Whereever he found those filters, he should report there.

@uBlock-user
Copy link
Contributor

He clarified that #1751 (comment), those 4 filters are not present in any default filter lists.

@gorhill gorhill reopened this Oct 11, 2021
@gorhill
Copy link
Member

gorhill commented Oct 11, 2021

Re-opening, one cosmetic filter should not prevent another cosmetic filter from being applied, unless they are exception filters.

I would like to know which exact filter does not work on which exact site (with a description of what the filter is supposed to hide) when AdGuard Base is enabled -- actually when an exact disclosed set of filter lists/custom filters are enabled. Also, in which exact browser -- I typically test in current stable Chromium on my side.

Promoted posts are properly hidden on my side on old.reddit.com with AdGuard Base enabled.

@uBlock-user uBlock-user removed the invalid not a uBlock issue label Oct 11, 2021
@gorhill
Copy link
Member

gorhill commented Oct 11, 2021

@sauravyad500

Found the culprit. For me whenever I use filter list named "AdGuard Base" with "Parse and enforce cosmetic filters" as checked, I face the issue. And when I uncheck the "AdGuard Base". The issue disappears.

In your original report, you stated you were using only default filter lists, AdGuard Base is not a default list.

@uBlock-user uBlock-user added the unable to reproduce cannot reproduce the issue label Oct 11, 2021
@MiaowMinx
Copy link

MiaowMinx commented Oct 16, 2021

Edit: I seem to be having a similar issue on https://old.reddit.com: promoted posts (ads) aren't filtered. The filter reddit.com##.promotedlink should do it, and I believe it should be in one of the filter lists, but the ads still appear. Sidebar ads, however, are blocked. This seems to be caused by the "uBlock Filters" list; disabling it and enabling the other default filters seems to remove promoted posts even without a custom filter.

I'm running into the exact same problem with the "uBlock Filters" list on old.reddit.com using uBlockOrigin on Vivaldi in Linux. uBO will hide .promotedlink and .premiumbanner as asked only if "uBlock Filters" is turned off; none of the other 'built-in' filter lists have that effect. (edited for clarity)

@jeremywho
Copy link

I'm running into the exact same problem with the "uBlock Filters" list on old.reddit.com ... uBO will hide .promotedlink and .premiumbanner as asked only if "uBlock Filters" is turned off; none of the other 'built-in' filter lists have that effect. (edited for clarity)

+1

Same thing happening here.

@jeremywho
Copy link

I've found 4 cosmetic filters in uBlock Filters, try to disable them to see whether there is any difference, just add the following exceptions to My Filters pane, reload the site, and report whether the promoted ads are still here:

Adding the exceptions works. The promoted ads are no longer showing.

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

Can you try to narrow down which specific exception works?

@uBlock-user
Copy link
Contributor

reddit.com#@#.adLinkBar:upward(article[style="z-index: 1;"]) will bring back ads in Android, uBlockOrigin/uAssets#10102, so down to three.

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

I am not proposing adding any of the exceptions in a filter list, I am just trying to understand how those exception filters are have any effect. For this I need to first know which one to investigate.

@jeremywho
Copy link

reddit.com#@#.size-compact.Post:has([class*="promoted"])

This is the one that works.

The other 3, on their own, have no effect.

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

@jeremywho

Thanks. Can you provide me with an exact URL where you can reproduce the issue? If I have an exact URL, I won't worry that I am trying to reproduce an issue which could depend on something very specific on a very specific page.

@jeremywho
Copy link

jeremywho commented Oct 21, 2021

I was using:

https://old.reddit.com/r/nba/

Quick screenshot of the ads in question:
image

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

What's the browser and browser version?

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

I can't understand why ##.size-compact.Post:has([class*="promoted"]) would have any effect on that page. I get 8 matches for [class*="promoted"] but no match for .size-compact or .Post.

Are you using other extensions which could have an effect on Reddit beside uBO?

@jeremywho
Copy link

Chrome on Windows: Version 94.0.4606.81 (Official Build) (64-bit)

These are all of the extensions:
image

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

When the issue occurs, any errors in the Reddit page's dev console or uBO's dev console?

@jeremywho
Copy link

Reddit console:
image

uBO Background.html console is emtpy.

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

Beside default ones, did you enable more lists in "Filter lists"?

@gorhill
Copy link
Member

gorhill commented Oct 21, 2021

When I select a promoted post (which is properly hidden on my side) in the DOM, I can confirm that there is a stylesheet injected by uBO:

Screenshot from 2021-10-21 15-52-30

Do you see such stylesheet on your side? What is the difference on your side regarding this with and without the exception filter which appears to trigger an issue?

@gorhill
Copy link
Member

gorhill commented Oct 26, 2021

I am starting to suspect something is not working as expected in Chromium: https://www.reddit.com/r/uBlockOrigin/comments/qgd6fe/reddit_promoted_posts_getting_through/.


So from all the information I got I this point, it appears the cosmetic filter .size-compact.Post:has([class*="promoted"]) is breaking cosmetic filtering for some people on Reddit.

That filter is a procedural cosmetic filter, and it is manually enforced through JS by uBO, not declaratively through a stylesheet. If that filter was injected through a stylesheet, this would break cosmetic filtering because the browser would reject the whole CSS declaration since it would detect an invalid CSS selector in it.

uBO knows that .size-compact.Post:has([class*="promoted"]) is not a valid CSS selector because it asks the browser to validate it at this line. An invalid CSS selector will cause an exception to be thrown, and as a result uBO will parse the cosmetic filter as a procedural one.

I am trying to figure out how the detection could fail. It theoretically could fail at this line if uBO was unable to create a div here. However I fail to see how uBO could fail to create a div, uBO is in an environment similar to a web page, and thus should have no issue to create a div. (The only time the failure can occur is when uBO is executed in a Node.js environment.)

@gorhill
Copy link
Member

gorhill commented Oct 27, 2021

Finally, with the help of Reddit user, the root of the issue has been found:

Yep, looks like something is wrong, the exception wasn't thrown and 1 is getting returned when parsing this expression. https://i.imgur.com/kOzo4XL.png

Edit: not related to this change, is it?

So the issue occurs when one enables "Experimental Web Platform features" in chrome://flags, this explains why most people could not reproduce.

The reddit user was able to track down changes in Chromium code which is quite probably related to this.

For now I need to think through how to best fix this in an emergency release.

@uBlock-user uBlock-user added bug Something isn't working Chromium specific to Chromium/Chrome and removed unable to reproduce cannot reproduce the issue filterlist a filter list issue labels Oct 27, 2021
@gorhill gorhill changed the title Cosmetic Filters aren't working on many websites Cosmetic filters not working on many websites with "Experimental Web Platform features" in chrome://flags Oct 27, 2021
gorhill added a commit to gorhill/uBlock that referenced this issue Oct 27, 2021
Related issue:
- uBlockOrigin/uBlock-issues#1751

Related feedback:
- https://www.reddit.com/r/uBlockOrigin/comments/qgd6fe/

It turns out Chromium has started to implement the `:has()`
operator, which becomes recognized when the browser flag
"Experimental Web Platform features" is enabled. However the
hic is that `:has()` is not supported as a declarative CSS
style rule and is only supported through `querySelector()`
et al.

The fix is to no longer detect plain CSS selectors through
`querySelector` et al. but rather use an actual stylesheet
to validate that a cosmetic filter can be injected into a
stylesheet in a declarative way.

Additionally, I added support to enforce ABP's semantic
regarding cosmetic filter with the `#?#` anchor: when using
such anchor, uBO will _first_ try to compile the filter as
a procedural one rather than a declarative one.

Related discussion:
- uBlockOrigin/uBlock-issues#1011 (comment)
@gorhill
Copy link
Member

gorhill commented Oct 28, 2021

I need to keep track of all related commits for when I prepare a revision for stable release:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Chromium specific to Chromium/Chrome
Projects
None yet
Development

No branches or pull requests

9 participants