From a394a8f0a6ab29fcb189a033da1f58bae62244cc Mon Sep 17 00:00:00 2001 From: wtetsu Date: Sat, 14 May 2022 13:17:24 +0900 Subject: [PATCH] Add cross-browser executeScript --- package-lock.json | 8 ++++---- package.json | 2 +- src/background/background.js | 18 +++++++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index da2cd279..4be4782c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "mouse-dictionary-manifest-v3", - "version": "1.6.0", + "name": "mouse-dictionary", + "version": "1.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "mouse-dictionary-manifest-v3", - "version": "1.6.0", + "name": "mouse-dictionary", + "version": "1.6.1", "license": "MIT", "dependencies": { "deinja": "0.0.3", diff --git a/package.json b/package.json index 8bb523db..1efc8048 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mouse-dictionary", - "version": "1.6.0", + "version": "1.6.1", "repository": "https://github.com/wtetsu/mouse-dictionary.git", "author": "wtetsu", "license": "MIT", diff --git a/src/background/background.js b/src/background/background.js index 505d92d0..d5a96559 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -7,12 +7,20 @@ import ExpiringQueue from "./queue"; import uniqueId from "./unique"; -chrome.action.onClicked.addListener((tab) => { - chrome.scripting.executeScript({ - target: { tabId: tab.id }, - files: ["main.js"], +if (BROWSER === "CHROME") { + chrome.action.onClicked.addListener((tab) => { + chrome.scripting.executeScript({ + target: { tabId: tab.id }, + files: ["main.js"], + }); }); -}); +} else { + chrome.browserAction.onClicked.addListener(() => { + chrome.tabs.executeScript({ + file: "./main.js", + }); + }); +} // cross-extension messaging chrome.runtime.onMessageExternal.addListener((message) => {