From 44c038b9a1be5aa59b151a580394d110b6bea256 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 29 Mar 2025 09:06:07 -0400 Subject: [PATCH] Fix for old scriptlet syntax Related feedback: https://old.reddit.com/r/uBlockOrigin/comments/1jmcqhn/ --- src/js/scriptlet-filtering-core.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/scriptlet-filtering-core.js b/src/js/scriptlet-filtering-core.js index b6d7c0be2..eca58e310 100644 --- a/src/js/scriptlet-filtering-core.js +++ b/src/js/scriptlet-filtering-core.js @@ -67,8 +67,10 @@ const lookupScriptlet = (rawToken, mainMap, isolatedMap, debug = false) => { const details = reng.contentFromName(token, 'text/javascript'); if ( details === undefined ) { return; } const targetWorldMap = details.world !== 'ISOLATED' ? mainMap : isolatedMap; - targetWorldMap.set(token, details.js); const content = patchScriptlet(details.js, args.slice(1)); + if ( content.startsWith('(function(') === false ) { + targetWorldMap.set(token, details.js); + } const dependencies = details.dependencies || []; while ( dependencies.length !== 0 ) { const token = dependencies.shift(); @@ -291,7 +293,7 @@ export class ScriptletFilteringEngine { options.debugScriptlets ? 'debugger;' : ';', '', // For use by scriptlets to share local data among themselves - `const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`, + `const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)};`, '', scriptletDetails.mainWorld, '', @@ -305,7 +307,7 @@ export class ScriptletFilteringEngine { options.debugScriptlets ? 'debugger;' : ';', '', // For use by scriptlets to share local data among themselves - `const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)}`, + `const scriptletGlobals = ${JSON.stringify(scriptletGlobals, null, 4)};`, '', scriptletDetails.isolatedWorld, '',