Skip to content

[Adblock] :matches-path() doesn't work correctly when websites use JavaScript like pushState() for navigation. #46429

Open
@Emi-TheVampireInLoveWithTheCorpsesBlood

Description

Brave's :matches-path() currently has two issues that affect the way it works in Brave.

  1. When a website doesn't use the normal navigation and uses JS History API like pushState() the :matches-path() will not work on navigation and only when you refresh the path or go directly to it.

  2. when elements get properly hidden for matching a :matches-path() rule, when you navigate away from the matching path where the rule doesn't/shouldn't apply anymore, the display: none !important property stays in the elements causing the elements to be hidden until page is refreshed.
    Note: This issue also affect the other Procedurals, but :matches-path() is the one where it matters and it is needed the most.

Example:

  1. Add smite2.com##:matches-path(founders) .flex.items-center.gap-2 as a custom filter.
  2. Go to smite2.com
  3. Navigate to the FOUNDER'S EDITION through the menu, but the PLAY FREE NOW doesn't hide dynamically going to the founders-edition path.
  4. Refresh the page founders-edition path and now the item gets properly hidden.
  5. Hit back button or click on another item in the menu, and the item will stay hidden.
20250528-2150-46.2583587.mp4

Extra information

Like I said, elements keeping the display: none !important from a procedural, even if a rule doesn't match anymore, is not limited to :matches-path() but I hope it gets fixed for every other procedural.
But even if the element is forced to update by removing it from the DOM with Devtools and then undo the action with Ctrl+Z, the element keeps the display: none !important in Brave.

Example:

  1. add smite2.com##.hidden.xl\:block > a:has-text(/game mode/i)
  2. open Devtools and find the element .hidden.xl\:block > a:nth-child(2)
  3. change the Game Mode text for whatever.
  4. Select the element and delete it and then undo it with ctrl+z
  5. the item will keep the display: none !important
  6. try the same in uBlock, and you will notice that the item re-appears with the new text and the element in the DOM will only have one of the two attributes that procedurals use to hide the element.

Brave:

20250528-2215-28.2777432.mp4

uBlock

20250528-2220-32.5818968.mp4

As can be seen by the example, uBlock doesn't keep the display: none !important in the element on delete/undo action since the rule is not matching anymore.

So this is the something that happens in :matches-path because the element keeps the display: none !important even on a delete/undo the element and even if the path is different where is not matching the :matches-path() rule at all.

20250528-2231-52.6549725.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions