From 9759bfef4e07e30ff2e2ea6f8944a2cf23c19436 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 13 Jan 2022 11:03:21 -0500 Subject: [PATCH] Fix edge case of background image filter and no cosmetic filters Related commit: - https://github.com/gorhill/uBlock/commit/ebaa8a8bb28aef043a68c99965fe6c128a3fe5e4 Related feedback: - https://github.com/gorhill/uBlock/commit/ebaa8a8bb28aef043a68c99965fe6c128a3fe5e4#commitcomment-63818019 --- src/js/scriptlets/epicker.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/js/scriptlets/epicker.js b/src/js/scriptlets/epicker.js index 138c93217..25afe465a 100644 --- a/src/js/scriptlets/epicker.js +++ b/src/js/scriptlets/epicker.js @@ -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; };