-
Notifications
You must be signed in to change notification settings - Fork 12
/
background.js
23 lines (22 loc) · 930 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
importScripts("js/constants.js");
importScripts("js/utils/LocalStorageProvider.js");
importScripts("js/models/GeoLocation.js");
importScripts("js/main.js");
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.method == "get") {
chrome.storage.local.get(request.key, function (result) {
sendResponse({ data: result[request.key] });
});
} else if (request.method == "set") {
let item = {};
item[request.key] = request.value;
chrome.storage.local.set(item, sendResponse);
} else if (request.method == "isSet") {
chrome.storage.local.get(request.key, function (result) {
sendResponse({ data: key in result });
});
} else if (request.method == "remove") {
chrome.storage.local.remove(request.key, sendResponse);
}
return true; // indicates we will send a response asynchronously
});