mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 17:19:38 +02:00
Fix assembling of scriptlets for isolated world
This commit is contained in:
parent
9b682dff03
commit
40141e2dfc
@ -143,7 +143,15 @@ const isolatedWorldInjector = (( ) => {
|
||||
scriptletSlot: parts.indexOf('scriptlet-slot'),
|
||||
assemble: function(hostname, scriptlets) {
|
||||
this.parts[this.jsonSlot] = JSON.stringify({ hostname });
|
||||
return this.parts.join('').replace('function(){}', scriptlets);
|
||||
const code = this.parts.join('');
|
||||
// Manually substitute noop function with scriptlet wrapper
|
||||
// function, so as to not suffer instances of special
|
||||
// replacement characters `$`,`\` when using String.replace()
|
||||
// with in scriptlet code.
|
||||
const match = /function\(\)\{\}/.exec(code);
|
||||
return code.slice(0, match.index) +
|
||||
scriptlets +
|
||||
code.slice(match.index + match[0].length);
|
||||
},
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user