[mv3] Use Set instead of array to avoid spurious script updates

Spurious updates to registered content scripts would occur when
using some regional lists, for example DEU would cause spurious
updates to registered script `css-procedural`.
This commit is contained in:
Raymond Hill 2022-11-10 12:46:25 -05:00
parent abe2ecba6b
commit 5b6fc43a2c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 2 deletions

View File

@ -200,12 +200,14 @@ function registerProcedural(context, proceduralDetails) {
const { before, filteringModeDetails, rulesetsDetails } = context; const { before, filteringModeDetails, rulesetsDetails } = context;
const js = []; const js = [];
const hostnameMatches = []; const hostnameMatches = new Set();
for ( const details of rulesetsDetails ) { for ( const details of rulesetsDetails ) {
if ( details.css.procedural === 0 ) { continue; } if ( details.css.procedural === 0 ) { continue; }
js.push(`/rulesets/scripting/procedural/${details.id}.js`); js.push(`/rulesets/scripting/procedural/${details.id}.js`);
if ( proceduralDetails.has(details.id) ) { if ( proceduralDetails.has(details.id) ) {
hostnameMatches.push(...proceduralDetails.get(details.id)); for ( const hn of proceduralDetails.get(details.id) ) {
hostnameMatches.add(hn);
}
} }
} }