diff --git a/scripts/build.ts b/scripts/build.ts index 782afb8b7..a57609217 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -72,6 +72,7 @@ async function createCopyFiles(context: Context): Promise<() => Promise> { "pages/popup.html", ...(watch && browser === "chrome" ? ["pages/watch.html"] : []), "scripts/active.js", + ...(browser === "safari" ? ["scripts/import-content-script.js"] : []), "third-party-notices.txt", ]; if (watch) { diff --git a/src/manifest.json.ts b/src/manifest.json.ts index bd50b1477..a0ce532a4 100644 --- a/src/manifest.json.ts +++ b/src/manifest.json.ts @@ -38,7 +38,7 @@ export default { process.env.BROWSER === "safari" ? Object.values(SEARCH_ENGINES).flatMap(({ contentScripts }) => contentScripts.map(({ matches, runAt }) => ({ - js: ["scripts/content-script.js"], + js: ["scripts/import-content-script.js"], matches: [ ...new Set( matches.map((match) => { @@ -118,5 +118,9 @@ export default { }, ], } - : {}), + : process.env.BROWSER === "safari" + ? { + web_accessible_resources: ["scripts/content-script.js"], + } + : {}), }; diff --git a/src/scripts/import-content-script.js b/src/scripts/import-content-script.js new file mode 100644 index 000000000..a15edf2d9 --- /dev/null +++ b/src/scripts/import-content-script.js @@ -0,0 +1 @@ +import("./content-script.js");