Skip to content

Commit 44c038b

Browse files
committed
Fix for old scriptlet syntax
Related feedback: https://old.reddit.com/r/uBlockOrigin/comments/1jmcqhn/
1 parent 862557f commit 44c038b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/js/scriptlet-filtering-core.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ const lookupScriptlet = (rawToken, mainMap, isolatedMap, debug = false) => {
6767
const details = reng.contentFromName(token, 'text/javascript');
6868
if ( details === undefined ) { return; }
6969
const targetWorldMap = details.world !== 'ISOLATED' ? mainMap : isolatedMap;
70-
targetWorldMap.set(token, details.js);
7170
const content = patchScriptlet(details.js, args.slice(1));
71+
if ( content.startsWith('(function(') === false ) {
72+
targetWorldMap.set(token, details.js);
73+
}
7274
const dependencies = details.dependencies || [];
7375
while ( dependencies.length !== 0 ) {
7476
const token = dependencies.shift();
@@ -291,7 +293,7 @@ export class ScriptletFilteringEngine {
291293
options.debugScriptlets ? 'debugger;' : ';',
292294
'',
293295
// For use by scriptlets to share local data among themselves
294-
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`,
296+
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)};`,
295297
'',
296298
scriptletDetails.mainWorld,
297299
'',
@@ -305,7 +307,7 @@ export class ScriptletFilteringEngine {
305307
options.debugScriptlets ? 'debugger;' : ';',
306308
'',
307309
// For use by scriptlets to share local data among themselves
308-
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`,
310+
`const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)};`,
309311
'',
310312
scriptletDetails.isolatedWorld,
311313
'',

0 commit comments

Comments
 (0)