diff --git a/platform/mv3/extension/js/scripting-manager.js b/platform/mv3/extension/js/scripting-manager.js index 6b28dc5b9..2e5c9c6fd 100644 --- a/platform/mv3/extension/js/scripting-manager.js +++ b/platform/mv3/extension/js/scripting-manager.js @@ -430,7 +430,7 @@ function registerScriptlet(context, scriptletDetails) { const scriptletList = scriptletDetails.get(rulesetId); if ( scriptletList === undefined ) { continue; } - for ( const [ token, scriptletHostnames ] of scriptletList ) { + for ( const [ token, details ] of scriptletList ) { const id = `${rulesetId}.${token}`; const registered = before.get(id); @@ -439,17 +439,17 @@ function registerScriptlet(context, scriptletDetails) { let targetHostnames = []; if ( hasBroadHostPermission ) { excludeMatches.push(...permissionRevokedMatches); - if ( scriptletHostnames.length > 100 ) { + if ( details.hostnames.length > 100 ) { targetHostnames = [ '*' ]; } else { - targetHostnames = scriptletHostnames; + targetHostnames = details.hostnames; } } else if ( permissionGrantedHostnames.length !== 0 ) { - if ( scriptletHostnames.includes('*') ) { + if ( details.hostnames.includes('*') ) { targetHostnames = permissionGrantedHostnames; } else { targetHostnames = ut.intersectHostnameIters( - scriptletHostnames, + details.hostnames, permissionGrantedHostnames ); } @@ -467,7 +467,7 @@ function registerScriptlet(context, scriptletDetails) { excludeMatches, matchOriginAsFallback: true, runAt: 'document_start', - world: 'MAIN', + world: details.world, }; // register diff --git a/platform/mv3/make-scriptlets.js b/platform/mv3/make-scriptlets.js index 8cc651ff2..c2fc6d69f 100644 --- a/platform/mv3/make-scriptlets.js +++ b/platform/mv3/make-scriptlets.js @@ -163,7 +163,6 @@ export async function commit(rulesetId, path, writeFn) { ); content = safeReplace(content, /\$rulesetId\$/, rulesetId, 0); content = safeReplace(content, /\$scriptletName\$/, details.name, 0); - content = safeReplace(content, '$world$', details.world); content = safeReplace(content, 'self.$argsList$', JSON.stringify(Array.from(details.args.keys()).map(a => JSON.parse(a))) @@ -181,7 +180,12 @@ export async function commit(rulesetId, path, writeFn) { JSON.stringify(Array.from(details.exceptions)) ); writeFn(`${path}/${rulesetId}.${name}`, content); - scriptletStats.push([ name.slice(0, -3), Array.from(details.matches).sort() ]); + scriptletStats.push([ + name.slice(0, -3), { + hostnames: Array.from(details.matches).sort(), + world: details.world, + } + ]); } return scriptletStats; }