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