-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
34 lines (32 loc) · 871 Bytes
/
background.js
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
/*
Called when the item has been created, or when creation failed due to an error.
We'll just log success/failure here.
*/
function onCreated() {
if (browser.runtime.lastError) {
console.log(`Error: ${browser.runtime.lastError}`);
} else {
console.log("Item created successfully");
}
}
/*
The click event listener, where we perform the appropriate action given the
ID of the menu item that was clicked.
*/
/*
Create all the context menu items.
*/
browser.menus.create({
id: "doggify-me",
title: "Doggify me!",
contexts: ["image","video"]
}, onCreated);
browser.menus.onClicked.addListener(function (info, tab) {
// Sent single message to current tab with the source url for
// image to change
browser.tabs.sendMessage(
tab.id,
{imageToChangeURL: `${info.srcUrl}`}
)
console.log(`Sent message to tab ${tab.id} to Doggify image`)
})