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

Add a new rule to check for Extended CSS usage without the correct separator #193

Open
Alex-302 opened this issue Jan 12, 2024 · 5 comments
Assignees

Comments

@Alex-302
Copy link
Member

Alex-302 commented Jan 12, 2024

  • beverfood.com#$#a[href^="/bnlink/?bnid="] { remove: true; }

{ remove: true; } can be used only with #$?#

  • Warn, if used an extended CSS selector with ## marker.
    ##div:contains(a)
    ##div:has(> table:contains(a))
    Not including :has() without not native selectors, like ##div:has(> table) / #?#div:has(> table).
@Alex-302 Alex-302 changed the title Invalid Extended CSS rule is not detected Detect if Extended CSS is used without the proper separator Jan 26, 2024
@scripthunter7
Copy link
Member

scripthunter7 commented Jan 27, 2024

This rule should work both ways:

  • if Extended CSS was used without the appropriate separator, like ##div:contains(foo)
  • and on the other hand, if plain CSS was used with Extended CSS separator: #?#div

In addition, the rule must also create a fix, which means replacing the separator:

  • ##div:contains(foo)
    ↓↓↓ should be fixed as ↓↓↓
    #?#div:contains(foo)
  • #$#div:contains(foo) { padding-top: 0 !important; }
    ↓↓↓ should be fixed as ↓↓↓
    #$?#div:contains(foo) { padding-top: 0 !important; }
  • #?#div
    ↓↓↓ should be fixed as ↓↓↓
    ##div
  • #$?#div { padding-top: 0 !important; }
    ↓↓↓ should be fixed as ↓↓↓
    #$#div { padding-top: 0 !important; }

@AdamWr
Copy link
Member

AdamWr commented Jan 27, 2024

  • #?#div
    ↓↓↓ should be fixed as ↓↓↓
    ##div
  • #$?#div { padding-top: 0 !important; }
    ↓↓↓ should be fixed as ↓↓↓
    #$#div { padding-top: 0 !important; }

Regarding these two last examples.
I think that for apps in some cases it might still be valid.
The problem is that if there is element with inline style, for example like this:

<h1 style="display: block !important; position: relative !important;">Example Domain</h1>

then in apps, the rule like this:

##h1

will not hide this element, because inline style has higher specificity/priority.
So using:

#?#h1

for this case might be a valid solution, the same for CSS (#$?#) rule.

I don't have anything against about warning that such rules can be used without ?, but I think that it would be a good idea to take into consideration that these rules still might be valid in some cases.

@Alex-302
Copy link
Member Author

@AdamWr Maybe better to change all extended css rules with native :has() once? The main purpose of this - using native :has().

@AdamWr
Copy link
Member

AdamWr commented Jan 31, 2024

I think that changing rules to use native :has() is a good idea.

I'm not sure if it was related to my comment above, but if so, then I meant rule like this:

#?#h1

there is no :has(), and it might be used intentionally in the case of apps, to hide element with inline style like in example above, or in the case where for some other reason applying CSS rules do not work or stylesheet has been removed.

@Alex-302
Copy link
Member Author

Alex-302 commented Feb 1, 2024

there is no :has(), and it might be used intentionally in the case of apps, to hide element with inline style like in example above

#?#h1

Rules like this we will not change.

@scripthunter7 scripthunter7 changed the title Detect if Extended CSS is used without the proper separator Add a new rule to check for Extended CSS usage without the correct separator Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants