AdguardTeam / AdguardBrowserExtension

AdGuard browser extension
https://adguard.com/
GNU General Public License v3.0
3.12k stars 333 forks source link

'Check for filter updates' option breaks user rules on the current page until you refresh it #2684

Closed alexx7311 closed 8 months ago

alexx7311 commented 10 months ago

AdGuard Extension version

4.2.241

Browser version

Chrome 121

OS version

Windows 11

What filters do you have enabled?

No response

What Stealth Mode options do you have enabled?

No response

Issue Details

STR:

  1. Go to example.org
  2. Click 'Block ads on this website' in the popup menu
  3. Block any element on the page and make sure the rule is in 'User rules' section
  4. Right click on the page and choose 'AdGuard AdBlocker' > 'Check for filter updates'

Expected Behavior

User rules should work correctly after checking for filter updates and the blocked element shouldn't be displayed.

Screenshots

Screenshot 1:

Additional Information

No response

105th commented 8 months ago

@alexx7311

why does this happen? When we rely on the nth-child selector in the rules, and they count ancestors at the very top level (right after the body, like the header in the picture, which is hidden by the rule gismeteo.com##header.header.js-header:nth-child(5)), such rules will break when we inject our iframe with information about filter updates (or version updates) because it is injected at the very first place, in the afterbegin position.

In theory, we could change it to beforeend, so it doesn't disrupt the operation of such nth-child rules. On the other hand, it seems that there are extremely few such rules counting descendants from the root element in our filters (except for auto-generated rules through the browser assistant). And changing the position to put it at the very end might, in my opinion, provoke more problematic issues, so we won't be making changes right now.

image