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

Return a range of elements rather than 1 single element #139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

antonok-edm
Copy link
Collaborator

Some cookie notices are structured like the following:

<div>                                      <!-- A -->
  <div id="cookie_notice">                 <!-- B -->
    <div class="backdrop">                 <!-- C -->
      <div class="modal">                  <!-- D -->
        <h1>Your privacy choices</h1>
        ...
      </div>
    </div>
  </div>
</div>

In this particular case:

  • Element A has no special styling or semantics; it doesn't matter whether or not it is hidden
  • Element B has a very convenient ID that could be targeted by a cosmetic filter rule
  • It's important to hide element C since it has a backdrop element covering the rest of the page
  • Element D is the actual floating notice

The heuristics prior to this PR would identify element C as the cookie notice, when in reality, elements A and B could be hidden with equal success. .modal:has-text(Your privacy choices) could be a usable selector, but in this case #cookie_notice would be an even better selector to choose since it's more precise (IDs are unique per-page), and procedural filters are more expensive in terms of runtime performance.

In preparation for proposing filter rules, it will be important to calculate this kind of additional context. This PR introduces a "range" of elements that can be hidden. The innermost element must be hidden to remove the notice and any associated backdrop elements. Anything up to the outermost element can be considered for the purposes of hiding, in order to select the optimal rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant