-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackground.ts
34 lines (26 loc) · 878 Bytes
/
background.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
console.log(
"Live now; make now always the most precious time. Now will never come again."
)
chrome.action.onClicked.addListener(() => {
console.log(`action clicked`)
})
/* Note if you're building for firefox or mv2 in general, chrome.action will be undefined so you have to do something like this:
@see https://stackoverflow.com/questions/70216500/chrome-action-is-undefined-migrating-to-v3-manifest
const handleClick = (tab) => {
console.log("clicked", tab.id);
if (!tab.id) throw new Error("tab id not found");
chrome.tabs.sendMessage(tab.id, {
name: "show-dialog"
});
};
if (chrome.action != undefined) {
chrome.action.onClicked.addListener(handleClick);
} else {
chrome.browserAction.onClicked.addListener(handleClick);
}
*/
chrome.commands.onCommand.addListener((command) => {
if (command === "test") {
console.log(`test command`)
}
})