Skip to content

Commit

Permalink
Normalize Adguard's plain cosmetic filters disguised as style-based f…
Browse files Browse the repository at this point in the history
…ilters

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.
  • Loading branch information
gorhill authored and hawkeye116477 committed Jun 29, 2020
1 parent 546057e commit 5bac0b9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/js/static-ext-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5bac0b9

Please sign in to comment.