diff --git a/app/manifest/v2/_base.json b/app/manifest/v2/_base.json index 9843a20529de..31b1c82224fd 100644 --- a/app/manifest/v2/_base.json +++ b/app/manifest/v2/_base.json @@ -15,7 +15,7 @@ "512": "images/icon-512.png" }, "default_title": "MetaMask", - "default_popup": "popup.html" + "default_popup": "popup-init.html" }, "commands": { "_execute_browser_action": { diff --git a/app/manifest/v2/firefox.json b/app/manifest/v2/firefox.json index 6b0a122cfd9e..b2858bb8612f 100644 --- a/app/manifest/v2/firefox.json +++ b/app/manifest/v2/firefox.json @@ -4,5 +4,19 @@ "id": "webextension@metamask.io", "strict_min_version": "89.0" } - } + }, + "browser_action": { + "default_icon": { + "16": "images/icon-16.png", + "19": "images/icon-19.png", + "32": "images/icon-32.png", + "38": "images/icon-38.png", + "64": "images/icon-64.png", + "128": "images/icon-128.png", + "512": "images/icon-512.png" + }, + "default_title": "MetaMask", + "default_popup": "popup.html" + }, + "manifest_version": 2 } diff --git a/app/manifest/v3/_base.json b/app/manifest/v3/_base.json index f3ffbf07c173..71d083208b55 100644 --- a/app/manifest/v3/_base.json +++ b/app/manifest/v3/_base.json @@ -10,7 +10,7 @@ "512": "images/icon-512.png" }, "default_title": "MetaMask", - "default_popup": "popup.html" + "default_popup": "popup-init.html" }, "author": "https://metamask.io", "background": { diff --git a/app/notification.html b/app/notification.html index a581bec5e003..3a19128baa1f 100644 --- a/app/notification.html +++ b/app/notification.html @@ -50,6 +50,6 @@ />
- + diff --git a/app/popup-init.html b/app/popup-init.html new file mode 100644 index 000000000000..2fb79fefcfde --- /dev/null +++ b/app/popup-init.html @@ -0,0 +1,39 @@ + + + + + + + MetaMask + + + diff --git a/app/scripts/load-app.js b/app/scripts/load-app.js deleted file mode 100644 index 4b92255a5bc2..000000000000 --- a/app/scripts/load-app.js +++ /dev/null @@ -1,26 +0,0 @@ -// eslint-disable-next-line import/unambiguous -'use strict'; - -setTimeout(() => { - // eslint-disable-next-line spaced-comment - const scriptsToLoad = [ - /* SCRIPTS */ - ]; - - const loadScript = (src) => { - const script = document.createElement('script'); - script.type = 'text/javascript'; - script.async = true; - script.onload = loadNext; - script.src = src; - document.body.appendChild(script); - }; - - loadNext(); - - function loadNext() { - if (scriptsToLoad.length) { - loadScript(scriptsToLoad.shift()); - } - } -}, 10); diff --git a/development/build/scripts.js b/development/build/scripts.js index 35a931841aef..926acea8252d 100644 --- a/development/build/scripts.js +++ b/development/build/scripts.js @@ -659,6 +659,12 @@ function createFactoredBuild({ const isTest = buildTarget === BUILD_TARGETS.TEST || buildTarget === BUILD_TARGETS.TEST_DEV; + const scripts = getScriptTags({ + groupSet, + commonSet, + shouldIncludeSnow, + applyLavaMoat, + }); switch (groupLabel) { case 'ui': { renderHtmlFile({ @@ -667,36 +673,39 @@ function createFactoredBuild({ shouldIncludeSnow, applyLavaMoat, isMMI: buildType === 'mmi', + scripts, }); renderHtmlFile({ htmlName: 'popup', browserPlatforms, shouldIncludeSnow, applyLavaMoat, + scripts, }); renderHtmlFile({ - htmlName: 'notification', + htmlName: 'popup-init', browserPlatforms, shouldIncludeSnow, applyLavaMoat, - isMMI: buildType === 'mmi', - isTest, + scripts, }); renderHtmlFile({ - htmlName: 'home', + htmlName: 'notification', browserPlatforms, shouldIncludeSnow, applyLavaMoat, isMMI: buildType === 'mmi', isTest, + scripts, }); - renderJavaScriptLoader({ - groupSet, - commonSet, + renderHtmlFile({ + htmlName: 'home', browserPlatforms, shouldIncludeSnow, applyLavaMoat, - destinationFileName: 'load-app.js', + isMMI: buildType === 'mmi', + isTest, + scripts, }); break; } @@ -708,14 +717,7 @@ function createFactoredBuild({ browserPlatforms, shouldIncludeSnow, applyLavaMoat, - }); - renderJavaScriptLoader({ - groupSet, - commonSet, - browserPlatforms, - shouldIncludeSnow, - applyLavaMoat, - destinationFileName: 'load-background.js', + scripts, }); if (isManifestV3) { const jsBundles = [ @@ -745,17 +747,19 @@ function createFactoredBuild({ browserPlatforms, shouldIncludeSnow, applyLavaMoat: false, + scripts, }); break; } case 'offscreen': { - renderJavaScriptLoader({ + renderHtmlFile({ + htmlName: 'offscreen', groupSet, commonSet, browserPlatforms, shouldIncludeSnow, applyLavaMoat, - destinationFileName: 'load-offscreen.js', + scripts, }); break; } @@ -1139,13 +1143,11 @@ async function createBundle(buildConfiguration, { reloadOnChange }) { } } -function renderJavaScriptLoader({ +function getScriptTags({ groupSet, commonSet, - browserPlatforms, shouldIncludeSnow, applyLavaMoat, - destinationFileName, }) { if (applyLavaMoat === undefined) { throw new Error( @@ -1179,17 +1181,8 @@ function renderJavaScriptLoader({ ...jsBundles, ]; - browserPlatforms.forEach((platform) => { - const appLoadFilePath = './app/scripts/load-app.js'; - const appLoadContents = readFileSync(appLoadFilePath, 'utf8'); - - const scriptDest = `./dist/${platform}/${destinationFileName}`; - const scriptOutput = appLoadContents.replace( - '/* SCRIPTS */', - `...${JSON.stringify(requiredScripts)}`, - ); - - writeFileSync(scriptDest, scriptOutput); + return requiredScripts.map((src) => { + return ``; }); } @@ -1200,6 +1193,7 @@ function renderHtmlFile({ applyLavaMoat, isMMI, isTest, + scripts = [], }) { if (applyLavaMoat === undefined) { throw new Error( @@ -1212,7 +1206,12 @@ function renderHtmlFile({ ); } - const htmlFilePath = `./app/${htmlName}.html`; + const scriptTags = scripts.join('\n '); + + const htmlFilePath = + htmlName === 'offscreen' + ? `./offscreen/${htmlName}.html` + : `./app/${htmlName}.html`; const htmlTemplate = readFileSync(htmlFilePath, 'utf8'); const eta = new Eta(); @@ -1223,9 +1222,10 @@ function renderHtmlFile({ .replace('./scripts/load/background.ts', './load-background.js') .replace( '', - '\n ', + `${scriptTags}\n `, ) - .replace('./scripts/load/ui.ts', './load-app.js') + .replace('', scriptTags) + .replace('', scriptTags) .replace('../ui/css/index.scss', './index.css') .replace('@lavamoat/snow/snow.prod.js', './scripts/snow.js'); browserPlatforms.forEach((platform) => { diff --git a/development/build/static.js b/development/build/static.js index edf6d8f618d4..2c0854d4b3c8 100644 --- a/development/build/static.js +++ b/development/build/static.js @@ -165,10 +165,6 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) { src: './app/scripts/init-globals.js', dest: 'scripts/init-globals.js', }, - { - src: './app/scripts/load-app.js', - dest: 'scripts/load-app.js', - }, { src: shouldIncludeLockdown ? `./app/scripts/lockdown-run.js` @@ -191,11 +187,6 @@ function getCopyTargets(shouldIncludeLockdown, shouldIncludeSnow) { dest: `scripts/runtime-lavamoat.js`, pattern: '', }, - { - src: `./offscreen/`, - pattern: `*.html`, - dest: '', - }, { src: getPathInsideNodeModules('@blockaid/ppom_release', '/'), pattern: '*.wasm', diff --git a/offscreen/offscreen.html b/offscreen/offscreen.html index ea5ad76dd7a7..7137f2406213 100644 --- a/offscreen/offscreen.html +++ b/offscreen/offscreen.html @@ -5,6 +5,6 @@ MetaMask Offscreen Page - +