-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
40 lines (31 loc) · 844 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
35
36
37
38
39
40
function onRequest(request, sender, sendResponse) {
var tagMap;
//update the stored tag list
chrome.storage.sync.get('rainbow.interestingtags', function(o) {
tagMap = o['rainbow.interestingtags'];
if(!tagMap) {
tagMap = new Object();
}
var tmpTagMap = new Object();
$.each(request.tagMap, function(i, e) {
if(tagMap[i]) {
tmpTagMap[i] = tagMap[i];
} else {
tmpTagMap[i] = e;
}
});
tagMap = tmpTagMap;
chrome.storage.sync.set({
'rainbow.interestingtags': tmpTagMap
}, function() {
// Show the page action for the tab that the sender (content script)
// was on.
chrome.pageAction.show(sender.tab.id);
sendResponse({
tagMap: tagMap
});
});
});
};
// Listen for the content script to send a message to the background page.
chrome.extension.onRequest.addListener(onRequest);