mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Inject scriptlets in their intended target world
This commit is contained in:
parent
e56ca0f612
commit
8a6b12a319
2 changed files with 12 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue