AdguardTeam / AdguardBrowserExtension

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

How can I use the native :has() selector #2967

Closed BloodlineL closed 1 month ago

BloodlineL commented 1 month ago

Please answer the following questions for yourself before submitting a question.

Ask a question

In the user filter of chrome 5.0.97, selectors like :has(+#id) will repeatedly select elements as the page changes, while the native :has() will not.

krystian3w commented 1 month ago

You would need to improve the ExtendedCSS module so that the rule is considered CSS compatible.

If raw JavaScript rules in MV3 are still in effect, you can try injecting the e.g. <style> tag into the page while hiding the element:

https://adguard.com/kb/general/ad-filtering/create-own-filters/#javascript-rules

https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement

foo:has(+#id) { display: none ! important }

Then the limitation can be:

slavaleleka commented 1 month ago

native :has() is not supported in the extension yet, but it is planned: https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2587