Skip to content

Commit

Permalink
Add cross-browser executeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed May 14, 2022
1 parent 54fd7b2 commit a394a8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 13 additions & 5 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit a394a8f

Please sign in to comment.