[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.
This commit is contained in:
Raymond Hill 2024-11-13 09:10:51 -05:00
parent d325dcd192
commit 2e745f9bfb
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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$();
/******************************************************************************/