@@ -396,13 +396,26 @@ function loadAllSourceScriptlets() {
396
396
397
397
/******************************************************************************/
398
398
399
- async function processGenericCosmeticFilters ( assetDetails , bucketsMap ) {
399
+ async function processGenericCosmeticFilters ( assetDetails , bucketsMap , exceptionSet ) {
400
400
if ( bucketsMap === undefined ) { return 0 ; }
401
+ if ( exceptionSet ) {
402
+ for ( const [ hash , selectors ] of bucketsMap ) {
403
+ let i = selectors . length ;
404
+ while ( i -- ) {
405
+ const selector = selectors [ i ] ;
406
+ if ( exceptionSet . has ( selector ) === false ) { continue ; }
407
+ selectors . splice ( i , 1 ) ;
408
+ //log(`\tRemoving excepted generic filter ##${selector}`);
409
+ }
410
+ if ( selectors . length === 0 ) {
411
+ bucketsMap . delete ( hash ) ;
412
+ }
413
+ }
414
+ }
401
415
if ( bucketsMap . size === 0 ) { return 0 ; }
402
416
const bucketsList = Array . from ( bucketsMap ) ;
403
417
const count = bucketsList . reduce ( ( a , v ) => a += v [ 1 ] . length , 0 ) ;
404
418
if ( count === 0 ) { return 0 ; }
405
-
406
419
const selectorLists = bucketsList . map ( v => [ v [ 0 ] , v [ 1 ] . join ( ',' ) ] ) ;
407
420
const originalScriptletMap = await loadAllSourceScriptlets ( ) ;
408
421
@@ -427,8 +440,15 @@ async function processGenericCosmeticFilters(assetDetails, bucketsMap) {
427
440
428
441
/******************************************************************************/
429
442
430
- async function processGenericHighCosmeticFilters ( assetDetails , selectorSet ) {
443
+ async function processGenericHighCosmeticFilters ( assetDetails , selectorSet , exceptionSet ) {
431
444
if ( selectorSet === undefined ) { return 0 ; }
445
+ if ( exceptionSet ) {
446
+ for ( const selector of selectorSet ) {
447
+ if ( exceptionSet . has ( selector ) === false ) { continue ; }
448
+ selectorSet . delete ( selector ) ;
449
+ //log(`\tRemoving excepted generic filter ##${selector}`);
450
+ }
451
+ }
432
452
if ( selectorSet . size === 0 ) { return 0 ; }
433
453
const selectorLists = Array . from ( selectorSet ) . sort ( ) . join ( ',\n' ) ;
434
454
const originalScriptletMap = await loadAllSourceScriptlets ( ) ;
@@ -925,11 +945,13 @@ async function rulesetFromURLs(assetDetails) {
925
945
926
946
const genericCosmeticStats = await processGenericCosmeticFilters (
927
947
assetDetails ,
928
- results . genericCosmetic
948
+ results . genericCosmetic ,
949
+ results . genericCosmeticExceptions
929
950
) ;
930
951
const genericHighCosmeticStats = await processGenericHighCosmeticFilters (
931
952
assetDetails ,
932
- results . genericHighCosmetic
953
+ results . genericHighCosmetic ,
954
+ results . genericCosmeticExceptions
933
955
) ;
934
956
const specificCosmeticStats = await processCosmeticFilters (
935
957
assetDetails ,
0 commit comments