Scriptlets
Scriptlets copied to clipboard
Access to the compatibility table via the Scriptlet API
TSUrlFilter issue reference: https://github.com/AdguardTeam/tsurlfilter/issues/60
Compatibility table contains ALL ABP/uBO scriptlets, even if AdGuard doesn't yet support one of them. However, the API currently only allows to determine whether a scriptlet is supported by Adguard or not. This function is called isValidScriptletRule
. This function is also used by the TSUrlFilter converter.
Take the example below:
RuleConverter.convertRule('ebay.com#$#hide-if-contains-visible-text /Sponsored/ div[aria-label] div[class]');
This will produce the following array (i.e. the rule remains unchanged, since hide-if-contains-visible-text
isn't supported by ADG):
['ebay.com#$#hide-if-contains-visible-text /Sponsored/ div[aria-label] div[class]']
If we pass this rule to RuleFactory.createRule
, it will detect it as a bad CSS injection rule. After all, the unsupported rule is not created, only an incorrect error message is displayed.
I think it would be a good idea to somehow make the compatibility table available through the API. This would increase compatibility and make the above case also solvable, since it could be checked if a script exists (the compatibility table contains ALL scriptlets) but not supported by ADG. For example, hide-if-contains-visible-text
is a valid ABP scriptlet, only ADG does not support it yet.
@scripthunter7 so the main reason is to improve error logging?
because, if I understand your suggestion correctly, partly valid abp-snippet rules still will not be converted
e.g. #$#abort-on-property-read localStorage; hide-if-contains-visible-text2 /Sponsored/ div[aria-label] div[class]
still skipped fully despite the first part is ok
@slavaleleka
so the main reason is to improve error logging?
Nope, the main reason is to improve compatibility. The improvement of TSUrlFilter's error logging could be a consequence of this.
All ABP/uBO scriptlets are listed in the compatibility table (even those not yet supported by AdGuard). However, when I convert an existing ABP scriptlet that is not supported by AdGuard, TSUrlFilter will detect it as a CSS rule, since the conversion does not changes the rule. For example:
RuleConverter.convertRule('ebay.com#$#hide-if-contains-visible-text /Sponsored/ div[aria-label] div[class]');
=>
['ebay.com#$#hide-if-contains-visible-text /Sponsored/ div[aria-label] div[class]']
TSUrlFilter uses isValidScriptletRule
function from the scriptlet library, which only specifies compatibility with AdGuard, but the compatibility table contains ALL scriptlets.
Btw, my motivation is that I'm working on a rule categorizer, and I also use TSUrlFilter and the scriptlets library for this. That's why I opened several issues, as I found the conversion errors during testing. I solved this issue in the categorizer (but for this I needed to list the names of the scriptlets), and I just thought that it would be a good idea if the compatibility table could somehow be accessed via the Scriptlets API.
If you are interested in the categorizer, here is a sample output for AdGuard Base List: https://gist.github.com/scripthunter7/f6a45411302ed7a1dd0a77a7f31c5cb8
I got you, thanks, we will think how to do it better as for now scriptlets compatibility table is used for wiki purposes only
@slavaleleka I updated the main comment as I wasn't clear. Now it only contains the gist.