From 0a18f758973f293bdc52c9ef8117d772fc9b0d23 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 9 Oct 2023 11:12:10 -0400 Subject: [PATCH] Fix dumping of CFE internals when no cosmetic filters present --- src/js/cosmetic-filtering.js | 5 ++--- src/js/messaging.js | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/js/cosmetic-filtering.js b/src/js/cosmetic-filtering.js index 62d7fd4b5..b7d1e6d86 100644 --- a/src/js/cosmetic-filtering.js +++ b/src/js/cosmetic-filtering.js @@ -961,9 +961,8 @@ FilterContainer.prototype.dump = function() { lowlyGenerics.push(...selectors.split(',\n')); } lowlyGenerics.sort(); - const highlyGenerics = Array.from(this.highlyGeneric.simple.dict); - highlyGenerics.push(Array.from(this.highlyGeneric.complex.dict)); - highlyGenerics.sort(); + const highlyGenerics = Array.from(this.highlyGeneric.simple.dict).sort(); + highlyGenerics.push(...Array.from(this.highlyGeneric.complex.dict).sort()); return [ 'Cosmetic Filtering Engine internals:', `specific: ${this.specificFilters.size}`, diff --git a/src/js/messaging.js b/src/js/messaging.js index 1b394d088..3ad22bbcf 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -240,11 +240,14 @@ const onMessage = function(request, sender, callback) { ); out.push(`+ Unsupported filters (${bad.length}): ${JSON.stringify(bad, replacer, 2)}`); out.push(`+ generichide exclusions (${network.generichideExclusions.length}): ${JSON.stringify(network.generichideExclusions, replacer, 2)}`); - out.push(`+ Cosmetic filters: ${result.specificCosmetic.size}`); - for ( const details of result.specificCosmetic ) { - out.push(` ${JSON.stringify(details)}`); + if ( result.specificCosmetic ) { + out.push(`+ Cosmetic filters: ${result.specificCosmetic.size}`); + for ( const details of result.specificCosmetic ) { + out.push(` ${JSON.stringify(details)}`); + } + } else { + out.push(' Cosmetic filters: 0'); } - callback(out.join('\n')); }); return;