mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Fix assembling of scriptlets for isolated world
This commit is contained in:
parent
9b682dff03
commit
40141e2dfc
1 changed files with 9 additions and 1 deletions
|
@ -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 a new issue