Normalize Adguard's plain cosmetic filters disguised as style-based filters

Reported by https://github.com/uBlock-user in
https://github.com/orgs/uBlockOrigin/teams/ublock-issues-volunteers/discussions/56

For some reasons, many cosmetic filters in Adguard's Annoyance List
are plain cosmetic filters disguised as style-based cosmetic filters,
and this was breaking uBO's ability to reverse lookup such filters
from the logger.
This commit is contained in:
Raymond Hill 2018-12-23 08:58:03 -05:00
parent 96fe5f7232
commit e2d1f50dd8
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 9 additions and 2 deletions

View File

@ -119,9 +119,16 @@
};
const translateAdguardCSSInjectionFilter = function(suffix) {
var matches = /^([^{]+)\{([^}]+)\}$/.exec(suffix);
const matches = /^([^{]+)\{([^}]+)\}$/.exec(suffix);
if ( matches === null ) { return ''; }
return matches[1].trim() + ':style(' + matches[2].trim() + ')';
const selector = matches[1].trim();
const style = matches[2].trim();
// For some reasons, many of Adguard's plain cosmetic filters are
// "disguised" as style-based cosmetic filters: convert such filters
// to plain cosmetic filters.
return /display\s*:\s*none\s*!important;?$/.test(style)
? selector
: selector + ':style(' + style + ')';
};
const hostnamesFromPrefix = function(s) {