1.0.7
[Fixed] Some matches-css rules are not applied #23
There was a bug that ExtendedCss could not parse a selector with many :matches-css
pseudo classes or with complicated arguments inside :matches-css
.
It was necessary to impose some rules in order to make extended selectors declarative.
The allowed arguments will be outlined below.
[Improved] Support regular expressions as arguments of :contains
and :matches-css
#29
ExtendedCss now support regular expressions as arguments of :contains
and :matches-css
. Same for :has-text
, :matches-css-after
, :matches-css-before
.
Previously, arguments of such are treated as a substring of a text to be matched against, and additionally for :matches-css
, we supported ABP-style special characters used in url matching filter rules, such as |,^,*
. Now, if arguments are enclosed in /
symbols, it will be treated as a regular expression which matches the same text as the JS regular expression.
:contains, :has-text
- Unquoted texts, with characters
()[]
escaped.- Sizzle automatically removes escapes.
- The resulting argument will be tested against
textContent
that it contains the argument. - Example:
.placeholder:contains(googletag.cmd.push\(function\(\){))
- Regular expressions, enclosed by
/
on both sides.- It should represent a valid JavaScript regular expression object.
- As such, characters
/
should be escaped in the regular expression text. - Example:
.block:has(> .header:contains(/[Ss]ponsored/))
- Below is kept here for reference, but is discouraged to use it.
- Quoted texts, either by
"
or'
.- Sizzle automatically correct escaped
"
and'
, and the resulting string will be searched againsttextContent
. - Note that this may not work with other adblockers which support similar syntaxes.
- Sizzle automatically correct escaped
- Unquoted texts containing unescaped
()[]
- Sizzle supports this, but its behavior is unpredictable, so it is not recommended to use it.
:matches-css, :matches-css-after, :matches-css-before
Allowed arguments are similar to those of :contains
.
- Unquoted texts, with characters
()[]
not occurring at all or are all escaped.- Example:
div[class^="_"]:matches-css(background-color: rgb\(255, 0, 0\))
- Example:
- Regular expressions of a form
:matches-css( propertyName: /.*/ )
- Example:
div[class^="_"]:matches-css(background-image: /url\(data\:image\/png;base64,[\w\d\/+=]{100,}\)/ )
- Example:
- Below is kept here for reference, but is discouraged to use it.
- Quoted texts, either by
"
or'
.- The string occurring after the style property name will be used as an ABP url matching rule for matching elements' style property value.
- Unquoted texts containing
()[]
- It may happen to be working for some cases, but it can cause erratic behavior as in #23 (comment).
[Improved] Remove unsupported pseudo class declarations #26
[Improved] Observe document.documentElement instead of document.body to subscribe to parser-generated mutation events #28
[Fixed] Compatibility with old versions Internet Explorer#35
[Fixed] Extended css test fails if opened in new tab #41
[Improved] Use Travis-CI to automate unit-testing #38