mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01:00
[mv3] Honor scriptlets' target world in Firefox
When the target world of a scriptlet is the ISOLATED one, skip Blob-based injection in Firefox, as the current world is always the ISOLATED one. This should make ISOLATED world-based scriptlets more reliable (i.e. execute sooner) in Firefox.
This commit is contained in:
parent
607bba6eaf
commit
6af4494946
2 changed files with 6 additions and 1 deletions
|
@ -59,6 +59,7 @@ export function init() {
|
|||
const entry = {
|
||||
name: fn.name,
|
||||
code: fn.toString(),
|
||||
world: scriptlet.world || 'MAIN',
|
||||
dependencies: scriptlet.dependencies,
|
||||
requiresTrust: scriptlet.requiresTrust === true,
|
||||
};
|
||||
|
@ -96,6 +97,7 @@ export function compile(details) {
|
|||
scriptletFiles.set(scriptletToken, {
|
||||
name: resourceEntry.name,
|
||||
code: createScriptletCoreCode(scriptletToken),
|
||||
world: resourceEntry.world,
|
||||
args: new Map(),
|
||||
hostnames: new Map(),
|
||||
entities: new Map(),
|
||||
|
@ -165,6 +167,7 @@ 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)))
|
||||
|
|
|
@ -132,8 +132,10 @@ argsList.length = 0;
|
|||
// 'MAIN' world not yet supported in Firefox, so we inject the code into
|
||||
// 'MAIN' ourself when environment in Firefox.
|
||||
|
||||
const targetWorld = '$world$';
|
||||
|
||||
// Not Firefox
|
||||
if ( typeof wrappedJSObject !== 'object' ) {
|
||||
if ( typeof wrappedJSObject !== 'object' || targetWorld === 'ISOLATED' ) {
|
||||
return uBOL_$scriptletName$();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue