Fix edge case of background image filter and no cosmetic filters

Related commit:
- ebaa8a8bb2

Related feedback:
- ebaa8a8bb2 (commitcomment-63818019)
This commit is contained in:
Raymond Hill 2022-01-13 11:03:21 -05:00
parent ebaa8a8bb2
commit 9759bfef4e
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -566,6 +566,18 @@ const filtersFrom = function(x, y) {
}
}
// https://github.com/gorhill/uBlock/commit/ebaa8a8bb28aef043a68c99965fe6c128a3fe5e4#commitcomment-63818019
// If still no best candidate, just use whatever is available in network
// filter candidates -- which may have been previously skipped in favor
// of cosmetic filters.
if ( bestCandidateFilter === null && netFilterCandidates.length !== 0 ) {
bestCandidateFilter = {
type: 'net',
filters: netFilterCandidates,
slot: 0
};
}
return netFilterCandidates.length + cosmeticFilterCandidates.length;
};