From 2e745f9bfb2cf7e5e241160b2a20edf5edfcad92 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 13 Nov 2024 09:10:51 -0500 Subject: [PATCH] [mv3] Remove obsolete Firefox-only workaround in scriptlet template Related bugzilla issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 The issue was fixed months ago. The removed code block is causing uBOL to be flagged as "including remotely hosted code". To be clear, the removed obsolete code block was not related to executing remote code. The referenced code was in the file itself, not remote, and this was a workaround for when Firefox was not supporting injecting script in the `MAIN` world. The issue was fixed months ago in Firefox, so there is no point for the workaround. --- platform/mv3/scriptlets/scriptlet.template.js | 40 +------------------ 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/platform/mv3/scriptlets/scriptlet.template.js b/platform/mv3/scriptlets/scriptlet.template.js index 9ce165d09..19560c8ae 100644 --- a/platform/mv3/scriptlets/scriptlet.template.js +++ b/platform/mv3/scriptlets/scriptlet.template.js @@ -21,7 +21,6 @@ */ /* eslint-disable indent */ -/* global cloneInto */ // ruleset: $rulesetId$ @@ -136,44 +135,7 @@ argsList.length = 0; /******************************************************************************/ -// Inject code - -// https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 -// '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' || targetWorld === 'ISOLATED' ) { - return uBOL_$scriptletName$(); -} - -// Firefox -{ - const page = self.wrappedJSObject; - let script, url; - try { - page.uBOL_$scriptletName$ = cloneInto([ - [ '(', uBOL_$scriptletName$.toString(), ')();' ], - { type: 'text/javascript; charset=utf-8' }, - ], self); - const blob = new page.Blob(...page.uBOL_$scriptletName$); - url = page.URL.createObjectURL(blob); - const doc = page.document; - script = doc.createElement('script'); - script.async = false; - script.src = url; - (doc.head || doc.documentElement || doc).append(script); - } catch (ex) { - console.error(ex); - } - if ( url ) { - if ( script ) { script.remove(); } - page.URL.revokeObjectURL(url); - } - delete page.uBOL_$scriptletName$; -} +uBOL_$scriptletName$(); /******************************************************************************/