-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
30 lines (22 loc) · 1.02 KB
/
Copy pathbackground.js
File metadata and controls
30 lines (22 loc) · 1.02 KB
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
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
if (request.type == "tabId") sendResponse({
tabId : sender.tab.id
});
});
chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
chrome.storage.local.get(["clients", "" + tabId], function(items) {
if (items.clients != undefined && items.clients.indexOf("" + tabId) > -1)
delete items.clients[items.clients.indexOf("" + tabId)];
if (items[tabId] != undefined) delete items[tabId];
chrome.storage.local.set(items);
});
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo) {
if (changeInfo.url != undefined && (changeInfo.status == undefined || changeInfo.status == "loading"))
chrome.storage.local.get(["clients", "" + tabId], function(items) {
if (items.clients != undefined && items.clients.indexOf("" + tabId) > -1)
delete items.clients[items.clients.indexOf("" + tabId)];
if (items[tabId] != undefined) delete items[tabId];
chrome.storage.local.set(items);
});
});