AdguardTeam / CoreLibs

Core Adguard libraries
https://adguard.com/
Apache License 2.0
39 stars 7 forks source link

Websites that rely on the stylesheets order / type #492

Closed AdamWr closed 11 months ago

AdamWr commented 5 years ago

https://github.com/AdguardTeam/AdguardFilters/issues/22589#issue-360636978

Steps to reproduce

  1. Open this website - http://www.gerasanews.com/

Expected behavior

Website should works correctly.

Actual behavior

Part of the website is broken.

Screenshot with AdGuard: ![image](https://user-images.githubusercontent.com/29142494/45705210-4782ee00-bb79-11e8-8ec6-dd0e54f38819.png) ![image](https://user-images.githubusercontent.com/29142494/45705214-4baf0b80-bb79-11e8-8832-0c4a7d24f9b3.png)
Screenshot without AdGuard: ![image](https://user-images.githubusercontent.com/29142494/45705252-608b9f00-bb79-11e8-8de4-0e39ddf49d3d.png)


It seems that it's broken by cosmetic rules, because it happens even if I disable all filters and add this rule: gerasanews.com###Test

Your environment

AdGuard 2.12.224 nightly, happens with AG for Windows 6.4.1619.4513 too.

sxgunchenko commented 5 years ago

Seems like it is caused by applying rules in the content script, not by injections in corelibs.

sfionov commented 5 years ago

@Alex-302 Isn't it a filters problem? Seems that we've nothing to do with it.

Alex-302 commented 5 years ago

@sfionov only some element hiding rules causes it. For example these generic element hiding rules fro Eng filter:

##div[data-spotim-slot]
##div[data-native_ad]

Russian filter does not break the site.

Alex-302 commented 5 years ago

@AdamWr just add generichide exclusion for affected products.

AdamWr commented 5 years ago

Unfortunately generichide doesn't work, because this website is broken by any cosmetic rule on my end. I checked it with AG for Windows 6.4.1840.4955 and AG for Android 3.0.72, disabled all filters and added that rule: gerasanews.com###test and website is broken.

It doesn't happen with extension.

I can add elemhide exclusion, but I don't think that it's good solution.

ameshkov commented 5 years ago

Adding any style tag to the document breaks the website JS due to this: https://uploads.adguard.com/up04_wb46n___.png

This is a complicated issue actually, and it'd be hard to come up with a generic solution.

  1. We could use shadow DOM v0 to encapsulate the stylesheets but this version of shadow DOM is deprecated now:(
  2. If we could apply cosmetic rules in some "stealthy" undetectable way, it could help, but we are yet to come up with this approach.

The temporary solution for this particular website would be to use $generichide and extended-CSS rules to hide elements without adding any additional stylesheets.

AdamWr commented 5 years ago

Ok, added $generichide exception.

Sergey-Lyapin commented 3 years ago

It seems that the issue below also has to do with this bug. https://github.com/AdguardTeam/AdguardFilters/issues/65301