-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
34 lines (26 loc) · 879 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
// background.js
var estTraduit;
// Called when the user clicks on the browser action.
browser.browserAction.onClicked.addListener(function(tab) {
browser.browserAction.setIcon({
path: "iconeOk.png"
})
// Send a message to the active tab
browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
var activeTab = tabs[0];
browser.tabs.sendMessage(activeTab.id, {"message": "clicked_browser_action"});
});
estTraduit = true;
});
function updateActiveTab(tabs) {
browser.browserAction.setIcon({
path: "icone2.png"
})
estTraduit = false;
}
// listen to tab URL changes
browser.tabs.onUpdated.addListener(updateActiveTab);
// listen to tab switching
browser.tabs.onActivated.addListener(updateActiveTab);
// listen for window switching
browser.windows.onFocusChanged.addListener(updateActiveTab);