forked from richgilbank/Scratch-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
29 lines (29 loc) · 893 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
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
switch (request.name) {
case 'platformInfo':
chrome.runtime.getPlatformInfo(function(info) {
sendResponse(info);
});
return true; // indicates sendResponse will be called asynchronously
break;
case 'getSettings':
sendResponse(JSON.parse(localStorage.getItem('settings')));
break;
case 'setSettings':
localStorage.setItem('settings', JSON.stringify(request.value));
sendResponse(localStorage.getItem('settings'));
break;
case 'getCode':
chrome.storage.sync.get('code', function (data) {
sendResponse(data);
});
return true;
break;
case 'setCode':
chrome.storage.sync.set({'code': request.value}, function () {
sendResponse('success');
});
return true;
break;
}
});