-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbackground.js
56 lines (50 loc) · 1.5 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
51
52
53
54
55
56
chrome.runtime.onInstalled.addListener(function(details) {
var thisVersion = chrome.runtime.getManifest().version;
if (details.reason == 'install') {
chrome.tabs.create({
url: 'http://echo.amazon.com'
}, function(tab) {
//
});
} else if (details.reason == 'update') {
//
}
});
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
switch (request.action){
case "is_first_launch":
var hasLaunched = localStorage.getItem('artisan_welcome_displayed');
if (hasLaunched){
sendResponse({isFirstLaunch: false});
} else {
sendResponse({isFirstLaunch: true});
localStorage.setItem('artisan_welcome_displayed', true);
}
break;
case "show_page_action":
chrome.pageAction.show(sender.tab.id);
break;
case "set_jj_settings":
localStorage.setItem('jj_email', request.email);
localStorage.setItem('jj_pass', request.pass);
sendResponse({ success: true });
break;
case "get_jj_settings":
sendResponse({
email: localStorage.getItem('jj_email'),
pass: localStorage.getItem('jj_pass')
});
break;
case "is_ordering_enabled":
if (localStorage.getItem('jj_ordering_enabled')) {
sendResponse({enabled: true});
} else {
sendResponse({enabled: false});
}
break;
case "enable_ordering":
localStorage.setItem('jj_ordering_enabled', true);
sendResponse({success: true});
break;
}
});