-
Notifications
You must be signed in to change notification settings - Fork 0
/
evf_background.html
70 lines (59 loc) · 2.98 KB
/
evf_background.html
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<html>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script type="text/javascript" src="evf_config.js" charset="utf-8"></script>
<script type="text/javascript">
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
switch(request.method){
// Method to return all eVF preferences as object
case 'getAllPrefs':
eVFprefs = new Object();
nbr_prefs = evf_prefs_name.length;
for(i = 0; i < nbr_prefs; i++){
if(typeof(localStorage[evf_prefs_name[i]]) != 'undefined'){
value = localStorage[evf_prefs_name[i]];
}else{
value = evf_prefs_default[i];
}
eVFprefs[evf_prefs_name[i]] = value;
}
sendResponse({data: eVFprefs});
break;
// Method to return one eVF preference as object
case 'getOnePref':
if(typeof(localStorage[request.pref]) != 'undefined'){
sendResponse({data: localStorage[request.pref]});
}else{
sendResponse({});
}
break;
// Method to save the stock eVF preference
case 'saveStockPrefs':
localStorage['evf_stocks'] = request.evf_stock
sendResponse({data: 'Pref evf_stocks sauvée'});
break;
// Method to save the notes eVF preference
case 'saveNotesPrefs':
localStorage['evf_notes'] = request.val
sendResponse({data: 'Pref evf_notes sauvée'});
break;
case 'includeJsFile':
chrome.tabs.executeScript(null, {file: request.jsfile});
txt = request.jsfile + ' used from background.html...';
sendResponse({data: txt});
break;
// Method to return one eVF preference as object
case 'getCookie':
//txt = 'evf_background getCookie: ' + request.cookieName;
txt = chrome.cookies.get({'url': 'http://www.virtuafoot.com', "name": request.cookieName},
function(cookie) {
sendResponse({data: cookie.value});
}
);
break;
default:
sendResponse({});
break;
}
});
</script>
</html>