forked from tangrufus/LazyCUHKOnePass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
50 lines (46 loc) · 1.29 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
//check first run?
function onInstall() {
//console.log("Extension Installed");
chrome.tabs.create({url: "options.html"});
chrome.tabs.create({url: "update.html"});
}
function onUpdate() {
//console.log("Extension Updated");
chrome.tabs.create({url: "options.html"});
chrome.tabs.create({url: "update.html"});
}
function getVersion() {
var details = chrome.app.getDetails();
return details.version;
}
// Check if the version has changed.
var currVersion = getVersion();
var prevVersion = localStorage['version']
if (currVersion != prevVersion) {
// Check if we just installed this extension.
if (typeof prevVersion == 'undefined') {
onInstall();
} else {
onUpdate();
}
localStorage['version'] = currVersion;
}
//end check first run?
//send localhost
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse)
{
if (request.request == "accounts")
{
sendResponse({
"u_id": localStorage["u_id"],
"wifi_pw": localStorage["wifi_pw"],
"lib_pw": localStorage["lib_pw"],
"cwem_pw": localStorage["cwem_pw"],
"ergwave_id": localStorage["ergwave_id"],
"ergwave_pw": localStorage["ergwave_pw"],
"fqdn": localStorage["fqdn"]
});
} else sendResponse({}); // snub them.
}
);