-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
executable file
·50 lines (48 loc) · 1.76 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*LIEN VERS LE STACKOVERFLOW http://stackoverflow.com/questions/20181239/chrome-extension-making-extension-active-only-if-matches-match*/
/* When the content scripts makes contact,
* set the page-action's icon and popup */
chrome.runtime.onMessage.addListener(function(msg, sender) {
if (msg.WebPageFacebook === true) {
chrome.browserAction.setIcon({
tabId: sender.tab.id,
path: "icons/oracle32.png"
});
chrome.browserAction.setPopup({
tabId: sender.tab.id,
popup: "src/popupfacebook.html"
});
}else if (msg.WebPageGoogle === true) {
chrome.browserAction.setIcon({
tabId: sender.tab.id,
path: "icons/oracle32.png"
});
chrome.browserAction.setPopup({
tabId: sender.tab.id,
popup: "src/popupgoogle.html"
});
} else if (msg.WebPageTwitter === true) {
chrome.browserAction.setIcon({
tabId: sender.tab.id,
path: "icons/oracle32.png"
});
chrome.browserAction.setPopup({
tabId: sender.tab.id,
popup: "src/popuptwitter.html"
});
}
});
/* When the tab's address changes/reloads,
* clear the popup and reset the icon.
* (If applicable, the newly injected content script will send a new message.) */
chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
if (info.status === "loadstart") {
chrome.browserAction.setIcon({
tabId: tabId,
path: "icons/oraclesleep.png"
});
chrome.browserAction.setPopup({
tabId: tabId,
popup: "src/popup2.html"
});
}
});