mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[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:
parent
d325dcd192
commit
2e745f9bfb
1 changed files with 1 additions and 39 deletions
|
|
@ -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$();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue