diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a2b8f88..80f49b5 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -4,6 +4,9 @@ module.exports = { es2021: true, webextensions: true, }, + globals: { + process: 'readonly', + }, extends: ['eslint:recommended', 'prettier'], overrides: [ { diff --git a/gulpfile.js b/gulpfile.js index 4b648ed..c627f2c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -41,7 +41,10 @@ async function buildCustomElements(outputDirPath) { }, }, define: { - 'process.env': {}, + 'process.env': { + // TODO: Need to run this for each extension (chrome/firefox) + EXTENSION_ID: process.env.EXTENSION_ID, + }, }, plugins: [vue({ customElement: true }), svgLoader()], }); diff --git a/src/background/bridge.js b/src/background/bridge.js index f776477..ebaa532 100644 --- a/src/background/bridge.js +++ b/src/background/bridge.js @@ -20,8 +20,11 @@ const listeners = { }; export const listen = () => { - chrome.runtime.onMessage.addListener(({ action, data }, _sender, sendResponse) => { + const listener = ({ action, data }, _sender, sendResponse) => { Promise.resolve(listeners[action](data)).then(sendResponse); return true; - }); + }; + + chrome.runtime.onMessage.addListener(listener); + chrome.runtime.onMessageExternal.addListener(listener); }; diff --git a/src/content/bridge.js b/src/content/bridge.js index 44c7797..055d9e9 100644 --- a/src/content/bridge.js +++ b/src/content/bridge.js @@ -3,6 +3,7 @@ import { PACKAGE_INFO_ACTION } from '../bridge-sync'; export const getPackageInfo = async (packageID) => { return new Promise((resolve) => chrome.runtime.sendMessage( + process.env.EXTENSION_ID, { action: PACKAGE_INFO_ACTION, data: packageID, diff --git a/src/custom-elements/indicator.vue b/src/custom-elements/indicator.vue index da65e30..950e7af 100644 --- a/src/custom-elements/indicator.vue +++ b/src/custom-elements/indicator.vue @@ -1,7 +1,7 @@