@@ -911,11 +911,17 @@ async function processPopupRules(assetDetails, popupRules) {
911911 }
912912 if ( re === undefined ) { return data ; }
913913 const token = literalStrFromRegex ( re ) . slice ( 0 , 7 ) ;
914- const key = `${ isUrlFilterCaseSensitive ? ' ' : 'i' } ${ token } ` ;
915- if ( realm . regexes . has ( key ) ) {
916- realm . regexes . set ( key , `${ realm . regexes . get ( key ) } |${ re } ` ) ;
917- } else {
918- realm . regexes . set ( key , re ) ;
914+ const details = realm . regexes . get ( token ) ?? { token, rules : [ ] } ;
915+ if ( details . rules . length === 0 ) {
916+ realm . regexes . set ( token , details )
917+ }
918+ const entry = { re, f : isUrlFilterCaseSensitive ? '' : 'i' } ;
919+ details . rules . push ( entry ) ;
920+ if ( condition . requestDomains ) {
921+ entry . to = condition . requestDomains . sort ( hostnameCompare ) ;
922+ }
923+ if ( condition . excludedRequestDomains ) {
924+ entry . xto = condition . excludedRequestDomains . sort ( hostnameCompare ) ;
919925 }
920926 return data ;
921927 }
@@ -949,9 +955,13 @@ async function processPopupRules(assetDetails, popupRules) {
949955 const count = data . block . hostnames . length + data . block . regexes . size ;
950956 if ( count === 0 ) { return ; }
951957 data . block . hostnames = data . block . hostnames . toSorted ( hostnameCompare ) ;
952- data . block . regexes = Array . from ( data . block . regexes ) . flat ( ) ;
958+ data . block . regexes = Array . from ( data . block . regexes . values ( ) ) . map ( a =>
959+ [ a . token , JSON . stringify ( a . rules ) ]
960+ ) . flat ( ) ;
953961 data . allow . hostnames = data . allow . hostnames . toSorted ( hostnameCompare ) ;
954- data . allow . regexes = Array . from ( data . allow . regexes ) . flat ( ) ;
962+ data . allow . regexes = Array . from ( data . allow . regexes . values ( ) ) . map ( a =>
963+ [ a . token , JSON . stringify ( a . rules ) ]
964+ ) . flat ( ) ;
955965 const originalScriptletMap = await loadAllSourceScriptlets ( ) ;
956966 let patchedScriptlet = originalScriptletMap . get ( `prevent-popup` ) ;
957967 patchedScriptlet = safeReplace ( patchedScriptlet ,
0 commit comments