Skip to content

Commit

Permalink
don't be a dum dum (include all browser targets)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Feb 5, 2024
1 parent f2940fc commit 0072a28
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions development/build/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,19 +475,21 @@ function createScriptTasks({
// MV3 injects inpage into the tab's main world, but in MV2 we need
// to do it manually:
if (process.env.ENABLE_MV3) {
return;
throw new Error("uh, why is mv3 enabled?");
}
// stringify inpage.js into itself, and then make it inject itself into the page
const inpagePath = path.join(
__dirname,
'../../',
`dist/chrome/${inpage}.js`,
);
const textContent = JSON.stringify(readFileSync(inpagePath, 'utf8'))
.replace(/\u2028/gu, '\\u2028')
.replace(/\u2029/gu, '\\u2029');
const html = `{let d=document,s=d.createElement('script');s.textContent=${textContent};d.documentElement.appendChild(s).remove();}`;
writeFileSync(inpagePath, html, 'utf8');
browserPlatforms.forEach((browser) => {
const inpagePath = path.join(
__dirname,
'../../',
`dist/${browser}/${inpage}.js`,
);
const textContent = JSON.stringify(readFileSync(inpagePath, 'utf8'))
.replace(/\u2028/gu, '\\u2028')
.replace(/\u2029/gu, '\\u2029');
const html = `{let d=document,s=d.createElement('script');s.textContent=${textContent};d.documentElement.appendChild(s).remove();}`;
writeFileSync(inpagePath, html, 'utf8');
});
},
createNormalBundle({
buildTarget,
Expand Down

0 comments on commit 0072a28

Please sign in to comment.