-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.js
More file actions
65 lines (56 loc) · 2.02 KB
/
main.js
File metadata and controls
65 lines (56 loc) · 2.02 KB
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
/* globals keepass, keepassClient, onDisconnected */
"use strict";
const page = {
tabs: [],
clearCredentials: () => {},
clearAllLogins: () => {},
settings: {
autoReconnect: true,
checkUpdateKeePassXC: 0
}
};
const browserAction = {
show: () => {},
showDefault: () => {}
};
// enable access to keepass object in option page
window.keepass = keepass;
const isKeepassReady = function(){
const keepassModule = import("./modules/keepass.js");
return async function(){
const { isReady } = await keepassModule;
return isReady();
};
}();
window.isKeepassReady = isKeepassReady;
import("./modules/externalRequests.js");
window.selectedModule = import("./modules/selected.js");
const getCredentialsModule = import("./modules/getCredentials.js");
browser.credentials.onCredentialRequested.addListener(async function(credentialInfo){
const { getCredentials } = await getCredentialsModule;
return await getCredentials(credentialInfo);
});
const storeCredentialsModule = import("./modules/storeCredentials.js");
browser.credentials.onNewCredential.addListener(async function(credentialInfo){
const { storeCredentials } = await storeCredentialsModule;
return await storeCredentials(credentialInfo);
});
browser.credentials.getThunderbirdSavedLoginsStatus().then(async function(status){
if (status.count === 0){
return false;
}
const currentSeenPasswordChange = Math.max(status.latestTimeCreated, status.latestTimePasswordChanged);
const { lastSeenPasswordChange } = await browser.storage.local.get({lastSeenPasswordChange: -1});
browser.storage.local.set({lastSeenPasswordChange: currentSeenPasswordChange});
if (lastSeenPasswordChange >= currentSeenPasswordChange){
return false;
}
(await import("./modules/modal.js")).messageModal(
browser.i18n.getMessage("passwordsStoredInThunderbird.title"),
lastSeenPasswordChange === -1?
browser.i18n.getMessage("passwordsStoredInThunderbird.message"):
browser.i18n.getMessage("passwordsStoredInThunderbird.newStored"),
"passwordsStoredInThunderbird"
);
return true;
}).catch(error => {});