mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Merge pull request #391 from keepassxreboot/code_cleaning
Code cleaning
This commit is contained in:
commit
e9e039484c
16 changed files with 2341 additions and 2415 deletions
|
|
@ -15,8 +15,7 @@ browserAction.show = function(callback, tab) {
|
|||
if (!page.tabs[tab.id] || page.tabs[tab.id].stack.length === 0) {
|
||||
browserAction.showDefault(callback, tab);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
data = page.tabs[tab.id].stack[page.tabs[tab.id].stack.length - 1];
|
||||
}
|
||||
|
||||
|
|
@ -38,13 +37,13 @@ browserAction.update = function(interval) {
|
|||
return;
|
||||
}
|
||||
|
||||
let data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
|
||||
const data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
|
||||
|
||||
if (data.visibleForMilliSeconds !== undefined && data.visibleForMilliSeconds !== -1) {
|
||||
if (data.visibleForMilliSeconds <= 0) {
|
||||
browserAction.stackPop(page.currentTabId);
|
||||
browserAction.disableLoop();
|
||||
browserAction.show(null, {'id': page.currentTabId});
|
||||
browserAction.show(null, { 'id': page.currentTabId });
|
||||
page.clearCredentials(page.currentTabId);
|
||||
return;
|
||||
}
|
||||
|
|
@ -72,7 +71,7 @@ browserAction.update = function(interval) {
|
|||
};
|
||||
|
||||
browserAction.showDefault = function(callback, tab) {
|
||||
let stackData = {
|
||||
const stackData = {
|
||||
level: 1,
|
||||
iconType: 'normal',
|
||||
popup: 'popup.html'
|
||||
|
|
@ -100,7 +99,7 @@ browserAction.stackAdd = function(callback, tab, icon, popup, level, push, visib
|
|||
level = 1;
|
||||
}
|
||||
|
||||
let stackData = {
|
||||
const stackData = {
|
||||
level: level,
|
||||
icon: icon
|
||||
};
|
||||
|
|
@ -123,13 +122,12 @@ browserAction.stackAdd = function(callback, tab, icon, popup, level, push, visib
|
|||
|
||||
if (push) {
|
||||
browserAction.stackPush(stackData, id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
browserAction.stackUnshift(stackData, id);
|
||||
}
|
||||
|
||||
if (!dontShow) {
|
||||
browserAction.show(null, {'id': id});
|
||||
browserAction.show(null, { 'id': id });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -142,17 +140,15 @@ browserAction.removeLevelFromStack = function(callback, tab, level, type, dontSh
|
|||
type = '<=';
|
||||
}
|
||||
|
||||
let newStack = [];
|
||||
const newStack = [];
|
||||
for (const i of page.tabs[tab.id].stack) {
|
||||
if (
|
||||
(type == '<' && i.level >= level) ||
|
||||
(type == '<=' && i.level > level) ||
|
||||
(type == '=' && i.level != level) ||
|
||||
(type == '==' && i.level != level) ||
|
||||
(type == '!=' && i.level == level) ||
|
||||
(type == '>' && i.level <= level) ||
|
||||
(type == '>=' && i.level < level)
|
||||
) {
|
||||
if ((type === '<' && i.level >= level) ||
|
||||
(type === '<=' && i.level > level) ||
|
||||
(type === '=' && i.level !== level) ||
|
||||
(type === '==' && i.level !== level) ||
|
||||
(type === '!=' && i.level === level) ||
|
||||
(type === '>' && i.level <= level) ||
|
||||
(type === '>=' && i.level < level)) {
|
||||
newStack.push(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -199,10 +195,8 @@ browserAction.removeRememberPopup = function(callback, tab, removeImmediately) {
|
|||
browserAction.stackPop(tab.id);
|
||||
browserAction.show(null, {"id": tab.id});
|
||||
page.clearCredentials(tab.id);
|
||||
return;
|
||||
}
|
||||
else if (!isNaN(data.visibleForPageUpdates) && data.redirectOffset > 0 && currentMS >= data.redirectOffset) {
|
||||
data.visibleForPageUpdates = data.visibleForPageUpdates - 1;
|
||||
} else if (!isNaN(data.visibleForPageUpdates) && data.redirectOffset > 0 && currentMS >= data.redirectOffset) {
|
||||
data.visibleForPageUpdates -= 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -256,17 +250,18 @@ browserAction.setRememberPopup = function(tabId, username, password, url, userna
|
|||
list: credentialsList
|
||||
};
|
||||
|
||||
browserAction.show(null, {'id': id});
|
||||
browserAction.show(null, { 'id': id });
|
||||
|
||||
if (page.settings.showLoginNotifications) {
|
||||
const message = tr('rememberCredentialsPopup');
|
||||
const buttons = [
|
||||
{
|
||||
'title': tr('popupButtonClose')
|
||||
},
|
||||
{
|
||||
'title': tr('popupButtonIgnore')
|
||||
}];
|
||||
{
|
||||
'title': tr('popupButtonClose')
|
||||
},
|
||||
{
|
||||
'title': tr('popupButtonIgnore')
|
||||
}
|
||||
];
|
||||
|
||||
browser.notifications.create({
|
||||
'type': 'basic',
|
||||
|
|
@ -293,7 +288,7 @@ function getValueOrDefault(settings, key, defaultVal, min) {
|
|||
val = defaultVal;
|
||||
}
|
||||
return val;
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
|
@ -312,16 +307,16 @@ browserAction.generateIconName = function(iconType, icon) {
|
|||
};
|
||||
|
||||
browserAction.ignoreSite = function(url) {
|
||||
browser.windows.getCurrent().then((win) => {
|
||||
browser.windows.getCurrent().then(() => {
|
||||
// Get current active window
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
|
||||
const tab = tabs[0];
|
||||
|
||||
// Send the message to the current tab's content script
|
||||
browser.runtime.getBackgroundPage().then((global) => {
|
||||
browser.runtime.getBackgroundPage().then(() => {
|
||||
browser.tabs.sendMessage(tab.id, {
|
||||
action: 'ignore-site',
|
||||
args: [url]
|
||||
action: 'ignore_site',
|
||||
args: [ url ]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ kpxcEvent.invoke = function(handler, callback, senderTabId, args, secondTime) {
|
|||
page.createTabEntry(senderTabId);
|
||||
}
|
||||
|
||||
// remove information from no longer existing tabs
|
||||
// Remove information from no longer existing tabs
|
||||
page.removePageInformationFromNotExistingTabs();
|
||||
|
||||
browser.tabs.get(senderTabId).then((tab) => {
|
||||
|
|
@ -70,8 +70,7 @@ kpxcEvent.invoke = function(handler, callback, senderTabId, args, secondTime) {
|
|||
|
||||
if (handler) {
|
||||
handler.apply(this, args);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('undefined handler for tab ' + tab.id);
|
||||
}
|
||||
}).catch((e) => {
|
||||
|
|
@ -113,12 +112,12 @@ kpxcEvent.onLoadSettings = function(callback, tab) {
|
|||
};
|
||||
|
||||
kpxcEvent.onLoadKeyRing = function(callback, tab) {
|
||||
browser.storage.local.get({'keyRing': {}}).then(function(item) {
|
||||
browser.storage.local.get({ 'keyRing': {} }).then(function(item) {
|
||||
keepass.keyRing = item.keyRing;
|
||||
if (keepass.isAssociated() && !keepass.keyRing[keepass.associated.hash]) {
|
||||
keepass.associated = {
|
||||
"value": false,
|
||||
"hash": null
|
||||
'value': false,
|
||||
'hash': null
|
||||
};
|
||||
}
|
||||
callback(item.keyRing);
|
||||
|
|
@ -128,7 +127,7 @@ kpxcEvent.onLoadKeyRing = function(callback, tab) {
|
|||
};
|
||||
|
||||
kpxcEvent.onSaveSettings = function(callback, tab, settings) {
|
||||
browser.storage.local.set({'settings': settings}).then(function() {
|
||||
browser.storage.local.set({ 'settings': settings }).then(function() {
|
||||
kpxcEvent.onLoadSettings(callback, tab);
|
||||
});
|
||||
};
|
||||
|
|
@ -168,9 +167,9 @@ kpxcEvent.onReconnect = function(callback, tab) {
|
|||
};
|
||||
|
||||
kpxcEvent.lockDatabase = function(callback, tab) {
|
||||
keepass.lockDatabase(tab).then((response => {
|
||||
keepass.lockDatabase(tab).then(() => {
|
||||
kpxcEvent.showStatus(true, tab, callback);
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
kpxcEvent.onPopStack = function(callback, tab) {
|
||||
|
|
@ -191,7 +190,7 @@ kpxcEvent.onGetConnectedDatabase = function(callback, tab) {
|
|||
};
|
||||
|
||||
kpxcEvent.onGetKeePassXCVersions = function(callback, tab) {
|
||||
if (keepass.currentKeePassXC == '') {
|
||||
if (keepass.currentKeePassXC === '') {
|
||||
keepass.getDatabaseHash((res) => {
|
||||
callback({'current': keepass.currentKeePassXC, 'latest': keepass.latestKeePassXC.version});
|
||||
}, tab);
|
||||
|
|
@ -229,7 +228,7 @@ kpxcEvent.onSetRememberPopup = function(callback, tab, username, password, url,
|
|||
};
|
||||
|
||||
kpxcEvent.onLoginPopup = function(callback, tab, logins) {
|
||||
let stackData = {
|
||||
const stackData = {
|
||||
level: 1,
|
||||
iconType: 'questionmark',
|
||||
popup: 'popup_login.html'
|
||||
|
|
@ -245,7 +244,7 @@ kpxcEvent.initHttpAuth = function(callback) {
|
|||
}
|
||||
|
||||
kpxcEvent.onHTTPAuthPopup = function(callback, tab, data) {
|
||||
let stackData = {
|
||||
const stackData = {
|
||||
level: 1,
|
||||
iconType: 'questionmark',
|
||||
popup: 'popup_httpauth.html'
|
||||
|
|
@ -256,7 +255,7 @@ kpxcEvent.onHTTPAuthPopup = function(callback, tab, data) {
|
|||
};
|
||||
|
||||
kpxcEvent.onMultipleFieldsPopup = function(callback, tab) {
|
||||
let stackData = {
|
||||
const stackData = {
|
||||
level: 1,
|
||||
iconType: 'normal',
|
||||
popup: 'popup_multiple-fields.html'
|
||||
|
|
@ -280,7 +279,7 @@ kpxcEvent.pageSetLoginId = function(callback, tab, loginId) {
|
|||
page.loginId = loginId;
|
||||
};
|
||||
|
||||
// all methods named in this object have to be declared BEFORE this!
|
||||
// All methods named in this object have to be declared BEFORE this!
|
||||
kpxcEvent.messageHandlers = {
|
||||
'add_credentials': keepass.addCredentials,
|
||||
'associate': keepass.associate,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ httpAuth.init = function() {
|
|||
};
|
||||
|
||||
httpAuth.requestCompleted = function(details) {
|
||||
let index = httpAuth.requests.indexOf(details.requestId);
|
||||
const index = httpAuth.requests.indexOf(details.requestId);
|
||||
if (index >= 0) {
|
||||
httpAuth.requests.splice(index, 1);
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ httpAuth.retrieveCredentials = function(tabId, url, submitUrl, forceCallback) {
|
|||
|
||||
httpAuth.processPendingCallbacks = async function(details, resolve, reject) {
|
||||
if (httpAuth.requests.indexOf(details.requestId) >= 0 || !page.tabs[details.tabId]) {
|
||||
reject({cancel: false});
|
||||
reject({ cancel: false });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ httpAuth.processPendingCallbacks = async function(details, resolve, reject) {
|
|||
};
|
||||
|
||||
httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) {
|
||||
// at least one login found --> use first to login
|
||||
// At least one login found --> use first to login
|
||||
if (logins.length > 0 && page.settings.autoFillAndSend) {
|
||||
if (logins.length === 1) {
|
||||
resolve({
|
||||
|
|
@ -89,9 +89,7 @@ httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) {
|
|||
}
|
||||
kpxcEvent.onHTTPAuthPopup(null, { 'id': details.tabId }, { 'logins': logins, 'url': details.searchUrl, 'resolve': resolve });
|
||||
}
|
||||
}
|
||||
// no logins found
|
||||
else {
|
||||
reject({cancel: false});
|
||||
} else {
|
||||
reject({ cancel: false }); // No logins found
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ browser.tabs.onRemoved.addListener((tabId, removeInfo) => {
|
|||
* @param {object} activeInfo
|
||||
*/
|
||||
browser.tabs.onActivated.addListener((activeInfo) => {
|
||||
// remove possible credentials from old tab information
|
||||
// Remove possible credentials from old tab information
|
||||
page.clearCredentials(page.currentTabId, true);
|
||||
browserAction.removeRememberPopup(null, {'id': page.currentTabId}, true);
|
||||
browserAction.removeRememberPopup(null, { 'id': page.currentTabId }, true);
|
||||
|
||||
browser.tabs.get(activeInfo.tabId).then((info) => {
|
||||
if (info && info.id) {
|
||||
|
|
@ -81,14 +81,14 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
|
|||
browser.runtime.onMessage.addListener(kpxcEvent.onMessage);
|
||||
|
||||
const contextMenuItems = [
|
||||
{title: tr('contextMenuFillUsernameAndPassword'), action: 'fill_user_pass'},
|
||||
{title: tr('contextMenuFillPassword'), action: 'fill_pass_only'},
|
||||
{title: tr('contextMenuFillUsernameAndPassword'), action: 'fill_username_password'},
|
||||
{title: tr('contextMenuFillPassword'), action: 'fill_password'},
|
||||
{title: tr('contextMenuFillTOTP'), action: 'fill_totp'},
|
||||
{title: tr('contextMenuShowPasswordGeneratorIcons'), action: 'activate_password_generator'},
|
||||
{title: tr('contextMenuSaveCredentials'), action: 'remember_credentials'}
|
||||
];
|
||||
|
||||
let menuContexts = ['editable'];
|
||||
const menuContexts = ['editable'];
|
||||
|
||||
if (isFirefox()) {
|
||||
menuContexts.push('password');
|
||||
|
|
@ -102,33 +102,19 @@ for (const item of contextMenuItems) {
|
|||
onclick: (info, tab) => {
|
||||
browser.tabs.sendMessage(tab.id, {
|
||||
action: item.action
|
||||
}).catch((e) => {console.log(e);});
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Listen for keyboard shortcuts specified by user
|
||||
browser.commands.onCommand.addListener((command) => {
|
||||
if (command === 'fill-username-password') {
|
||||
if (contextMenuItems.some(e => e.action === command)) {
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: 'fill_user_pass' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (command === 'fill-password') {
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: 'fill_pass_only' });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (command === 'fill-totp') {
|
||||
browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
|
||||
if (tabs.length) {
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: 'fill_totp' });
|
||||
browser.tabs.sendMessage(tabs[0].id, { action: command });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ keepass.nativeHostName = 'org.keepassxc.keepassxc_browser';
|
|||
keepass.nativePort = null;
|
||||
keepass.keySize = 24;
|
||||
keepass.latestVersionUrl = 'https://api.github.com/repos/keepassxreboot/keepassxc/releases/latest';
|
||||
keepass.cacheTimeout = 30 * 1000; // milliseconds
|
||||
keepass.cacheTimeout = 30 * 1000; // Milliseconds
|
||||
keepass.databaseHash = '';
|
||||
keepass.previousDatabaseHash = '';
|
||||
keepass.keyId = 'keepassxc-browser-cryptokey-name';
|
||||
keepass.keyBody = 'keepassxc-browser-key';
|
||||
keepass.messageTimeout = 500; // milliseconds
|
||||
keepass.messageTimeout = 500; // Milliseconds
|
||||
keepass.nonce = nacl.util.encodeBase64(nacl.randomBytes(keepass.keySize));
|
||||
|
||||
const kpActions = {
|
||||
|
|
@ -79,7 +79,7 @@ const kpErrors = {
|
|||
};
|
||||
|
||||
browser.storage.local.get({
|
||||
'latestKeePassXC': {'version': '', 'lastChecked': null},
|
||||
'latestKeePassXC': { 'version': '', 'lastChecked': null },
|
||||
'keyRing': {}}).then((item) => {
|
||||
keepass.latestKeePassXC = item.latestKeePassXC;
|
||||
keepass.keyRing = item.keyRing;
|
||||
|
|
@ -88,11 +88,11 @@ browser.storage.local.get({
|
|||
keepass.sendNativeMessage = function(request, enableTimeout = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let timeout;
|
||||
let action = request.action;
|
||||
let ev = keepass.nativePort.onMessage;
|
||||
const requestAction = request.action;
|
||||
const ev = keepass.nativePort.onMessage;
|
||||
|
||||
let listener = ((port, action) => {
|
||||
let handler = (msg) => {
|
||||
const listener = ((port, action) => {
|
||||
const handler = (msg) => {
|
||||
if (msg && msg.action === action) {
|
||||
port.removeListener(handler);
|
||||
if (enableTimeout) {
|
||||
|
|
@ -102,7 +102,7 @@ keepass.sendNativeMessage = function(request, enableTimeout = false) {
|
|||
}
|
||||
};
|
||||
return handler;
|
||||
})(ev, action);
|
||||
})(ev, requestAction);
|
||||
ev.addListener(listener);
|
||||
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ keepass.sendNativeMessage = function(request, enableTimeout = false) {
|
|||
if (enableTimeout) {
|
||||
timeout = setTimeout(() => {
|
||||
const errorMessage = {
|
||||
action: action,
|
||||
action: requestAction,
|
||||
error: kpErrors.getError(kpErrors.TIMEOUT_OR_NOT_CONNECTED),
|
||||
errorCode: kpErrors.TIMEOUT_OR_NOT_CONNECTED
|
||||
};
|
||||
|
|
@ -137,19 +137,19 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password,
|
|||
page.tabs[tab.id].errorMessage = null;
|
||||
}
|
||||
|
||||
keepass.testAssociation((response) => {
|
||||
if (!response) {
|
||||
keepass.testAssociation((taResponse) => {
|
||||
if (!taResponse) {
|
||||
browserAction.showDefault(null, tab);
|
||||
callback([]);
|
||||
return;
|
||||
}
|
||||
|
||||
const kpAction = kpActions.SET_LOGIN;
|
||||
const {dbid} = keepass.getCryptoKey();
|
||||
const { dbid } = keepass.getCryptoKey();
|
||||
const nonce = keepass.getNonce();
|
||||
const incrementedNonce = keepass.incrementedNonce(nonce);
|
||||
|
||||
let messageData = {
|
||||
const messageData = {
|
||||
action: kpAction,
|
||||
id: dbid,
|
||||
login: username,
|
||||
|
|
@ -181,12 +181,10 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password,
|
|||
const message = nacl.util.encodeUTF8(res);
|
||||
const parsed = JSON.parse(message);
|
||||
callback(keepass.verifyResponse(parsed, incrementedNonce) ? 'success' : 'error');
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
callback('error');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
browserAction.showDefault(null, tab);
|
||||
}
|
||||
});
|
||||
|
|
@ -219,16 +217,16 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb
|
|||
const kpAction = kpActions.GET_LOGINS;
|
||||
const nonce = keepass.getNonce();
|
||||
const incrementedNonce = keepass.incrementedNonce(nonce);
|
||||
const {dbid} = keepass.getCryptoKey();
|
||||
const { dbid } = keepass.getCryptoKey();
|
||||
|
||||
for (let keyHash in keepass.keyRing) {
|
||||
for (const keyHash in keepass.keyRing) {
|
||||
keys.push({
|
||||
id: keepass.keyRing[keyHash].id,
|
||||
key: keepass.keyRing[keyHash].key
|
||||
});
|
||||
}
|
||||
|
||||
let messageData = {
|
||||
const messageData = {
|
||||
action: kpAction,
|
||||
id: dbid,
|
||||
url: url,
|
||||
|
|
@ -267,21 +265,18 @@ keepass.retrieveCredentials = function(callback, tab, url, submiturl, forceCallb
|
|||
entries = parsed.entries;
|
||||
keepass.updateLastUsed(keepass.databaseHash);
|
||||
if (entries.length === 0) {
|
||||
// questionmark-icon is not triggered, so we have to trigger for the normal symbol
|
||||
// Questionmark-icon is not triggered, so we have to trigger for the normal symbol
|
||||
browserAction.showDefault(null, tab);
|
||||
}
|
||||
callback(entries);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('RetrieveCredentials for ' + url + ' rejected');
|
||||
}
|
||||
page.debug('keepass.retrieveCredentials() => entries.length = {1}', entries.length);
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
callback([]);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
browserAction.showDefault(null, tab);
|
||||
callback([]);
|
||||
}
|
||||
|
|
@ -337,17 +332,14 @@ keepass.generatePassword = function(callback, tab, forceCallback) {
|
|||
if (parsed.entries) {
|
||||
passwords = parsed.entries;
|
||||
keepass.updateLastUsed(keepass.databaseHash);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('No entries returned. Is KeePassXC up-to-date?');
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log('GeneratePassword rejected');
|
||||
}
|
||||
callback(passwords);
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
});
|
||||
|
|
@ -406,8 +398,7 @@ keepass.associate = function(callback, tab) {
|
|||
|
||||
if (!keepass.verifyResponse(parsed, incrementedNonce)) {
|
||||
keepass.handleError(tab, kpErrors.ASSOCIATION_FAILED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Use public key as identification key with older KeePassXC releases
|
||||
const savedKey = keepass.compareVersion('2.3.4', keepass.currentKeePassXC) ? idKey : key;
|
||||
keepass.setCryptoKey(id, savedKey); // Save the new identification public key as id key for the database
|
||||
|
|
@ -416,8 +407,7 @@ keepass.associate = function(callback, tab) {
|
|||
}
|
||||
|
||||
browserAction.show(callback, tab);
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
});
|
||||
|
|
@ -456,7 +446,7 @@ keepass.testAssociation = function(callback, tab, enableTimeout = false, trigger
|
|||
const kpAction = kpActions.TEST_ASSOCIATE;
|
||||
const nonce = keepass.getNonce();
|
||||
const incrementedNonce = keepass.incrementedNonce(nonce);
|
||||
const {dbid, dbkey} = keepass.getCryptoKey();
|
||||
const { dbid, dbkey } = keepass.getCryptoKey();
|
||||
|
||||
if (dbkey === null || dbid === null) {
|
||||
if (tab && page.tabs[tab.id]) {
|
||||
|
|
@ -500,17 +490,14 @@ keepass.testAssociation = function(callback, tab, enableTimeout = false, trigger
|
|||
keepass.handleError(tab, kpErrors.ENCRYPTION_KEY_UNRECOGNIZED);
|
||||
keepass.associated.value = false;
|
||||
keepass.associated.hash = null;
|
||||
}
|
||||
else if (!keepass.isAssociated()) {
|
||||
} else if (!keepass.isAssociated()) {
|
||||
keepass.handleError(tab, kpErrors.ASSOCIATION_FAILED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (tab && page.tabs[tab.id]) {
|
||||
delete page.tabs[tab.id].errorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
callback(keepass.isAssociated());
|
||||
|
|
@ -539,9 +526,9 @@ keepass.getDatabaseHash = function(callback, tab, enableTimeout = false, trigger
|
|||
|
||||
const encrypted = keepass.encrypt(messageData, nonce);
|
||||
if (encrypted.length <= 0) {
|
||||
keepass.handleError(tab, kpErrors.PUBLIC_KEY_NOT_FOUND);
|
||||
callback(keepass.databaseHash);
|
||||
return;
|
||||
keepass.handleError(tab, kpErrors.PUBLIC_KEY_NOT_FOUND);
|
||||
callback(keepass.databaseHash);
|
||||
return;
|
||||
}
|
||||
|
||||
const request = {
|
||||
|
|
@ -580,23 +567,20 @@ keepass.getDatabaseHash = function(callback, tab, enableTimeout = false, trigger
|
|||
keepass.isKeePassXCAvailable = true;
|
||||
callback(parsed.hash);
|
||||
return;
|
||||
}
|
||||
else if (parsed.errorCode) {
|
||||
} else if (parsed.errorCode) {
|
||||
keepass.databaseHash = '';
|
||||
keepass.isDatabaseClosed = true;
|
||||
keepass.handleError(tab, kpErrors.DATABASE_NOT_OPENED);
|
||||
callback(keepass.databaseHash);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keepass.databaseHash = '';
|
||||
keepass.isDatabaseClosed = true;
|
||||
if (response.message && response.message === '') {
|
||||
keepass.isKeePassXCAvailable = false;
|
||||
keepass.handleError(tab, kpErrors.TIMEOUT_OR_NOT_CONNECTED);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
callback(keepass.databaseHash);
|
||||
|
|
@ -633,8 +617,7 @@ keepass.changePublicKeys = function(tab, enableTimeout = false) {
|
|||
keepass.handleError(tab, kpErrors.KEY_CHANGE_FAILED);
|
||||
reject(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keepass.isKeePassXCAvailable = true;
|
||||
console.log('Server public key: ' + nacl.util.encodeBase64(keepass.serverPublicKey));
|
||||
}
|
||||
|
|
@ -686,8 +669,7 @@ keepass.lockDatabase = function(tab) {
|
|||
keepass.handleError(tab, kpErrors.DATABASE_NOT_OPENED);
|
||||
resolve(true);
|
||||
}
|
||||
}
|
||||
else if (response.error && response.errorCode) {
|
||||
} else if (response.error && response.errorCode) {
|
||||
keepass.isDatabaseClosed = true;
|
||||
keepass.handleError(tab, response.errorCode, response.error);
|
||||
}
|
||||
|
|
@ -759,25 +741,24 @@ keepass.saveKey = function(hash, id, key) {
|
|||
created: new Date().valueOf(),
|
||||
lastUsed: new Date().valueOf()
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keepass.keyRing[hash].id = id;
|
||||
keepass.keyRing[hash].key = key;
|
||||
keepass.keyRing[hash].hash = hash;
|
||||
}
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({ 'keyRing': keepass.keyRing });
|
||||
};
|
||||
|
||||
keepass.updateLastUsed = function(hash) {
|
||||
if ((hash in keepass.keyRing)) {
|
||||
keepass.keyRing[hash].lastUsed = new Date().valueOf();
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({ 'keyRing': keepass.keyRing });
|
||||
}
|
||||
};
|
||||
|
||||
keepass.deleteKey = function(hash) {
|
||||
delete keepass.keyRing[hash];
|
||||
browser.storage.local.set({'keyRing': keepass.keyRing});
|
||||
browser.storage.local.set({ 'keyRing': keepass.keyRing });
|
||||
};
|
||||
|
||||
keepass.setcurrentKeePassXCVersion = function(version) {
|
||||
|
|
@ -789,7 +770,7 @@ keepass.setcurrentKeePassXCVersion = function(version) {
|
|||
keepass.keePassXCUpdateAvailable = function() {
|
||||
if (page.settings.checkUpdateKeePassXC && page.settings.checkUpdateKeePassXC > 0) {
|
||||
const lastChecked = (keepass.latestKeePassXC.lastChecked) ? new Date(keepass.latestKeePassXC.lastChecked) : new Date(1986, 11, 21);
|
||||
const daysSinceLastCheck = Math.floor(((new Date()).getTime()-lastChecked.getTime())/86400000);
|
||||
const daysSinceLastCheck = Math.floor(((new Date()).getTime() - lastChecked.getTime()) / 86400000);
|
||||
if (daysSinceLastCheck >= page.settings.checkUpdateKeePassXC) {
|
||||
keepass.checkForNewKeePassXCVersion();
|
||||
}
|
||||
|
|
@ -799,7 +780,7 @@ keepass.keePassXCUpdateAvailable = function() {
|
|||
};
|
||||
|
||||
keepass.checkForNewKeePassXCVersion = function() {
|
||||
let xhr = new XMLHttpRequest();
|
||||
const xhr = new XMLHttpRequest();
|
||||
let version = -1;
|
||||
|
||||
xhr.onload = function(e) {
|
||||
|
|
@ -973,7 +954,7 @@ keepass.getCryptoKey = function() {
|
|||
let dbkey = null;
|
||||
let dbid = null;
|
||||
if (!(keepass.databaseHash in keepass.keyRing)) {
|
||||
return {dbid, dbkey};
|
||||
return { dbid, dbkey };
|
||||
}
|
||||
|
||||
dbid = keepass.keyRing[keepass.databaseHash].id;
|
||||
|
|
@ -982,7 +963,7 @@ keepass.getCryptoKey = function() {
|
|||
dbkey = keepass.keyRing[keepass.databaseHash].key;
|
||||
}
|
||||
|
||||
return {dbid, dbkey};
|
||||
return { dbid, dbkey };
|
||||
};
|
||||
|
||||
keepass.setCryptoKey = function(id, key) {
|
||||
|
|
@ -1046,7 +1027,7 @@ keepass.updatePopup = function(iconType) {
|
|||
if (page && page.tabs.length > 0) {
|
||||
const data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
|
||||
data.iconType = iconType;
|
||||
browserAction.show(null, {'id': page.currentTabId});
|
||||
browserAction.show(null, { 'id': page.currentTabId });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ page.loginId = -1;
|
|||
|
||||
page.initSettings = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
browser.storage.local.get({'settings': {}}).then((item) => {
|
||||
browser.storage.local.get({ 'settings': {} }).then((item) => {
|
||||
page.settings = item.settings;
|
||||
if (!('checkUpdateKeePassXC' in page.settings)) {
|
||||
page.settings.checkUpdateKeePassXC = defaultSettings.checkUpdateKeePassXC;
|
||||
|
|
@ -62,14 +62,14 @@ page.initOpenedTabs = function() {
|
|||
page.createTabEntry(i.id);
|
||||
}
|
||||
|
||||
// set initial tab-ID
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
|
||||
if (tabs.length === 0) {
|
||||
// Set initial tab-ID
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((t) => {
|
||||
if (t.length === 0) {
|
||||
resolve();
|
||||
return; // For example: only the background devtools or a popup are opened
|
||||
}
|
||||
page.currentTabId = tabs[0].id;
|
||||
browserAction.show(null, tabs[0]);
|
||||
page.currentTabId = t[0].id;
|
||||
browserAction.show(null, t[0]);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
|
@ -84,7 +84,7 @@ page.isValidProtocol = function(url) {
|
|||
|
||||
page.switchTab = function(callback, tab) {
|
||||
browserAction.showDefault(null, tab);
|
||||
browser.tabs.sendMessage(tab.id, {action: 'activated_tab'}).catch((e) => {});
|
||||
browser.tabs.sendMessage(tab.id, { action: 'activated_tab' }).catch((e) => {});
|
||||
};
|
||||
|
||||
page.clearCredentials = function(tabId, complete) {
|
||||
|
|
@ -121,18 +121,18 @@ page.createTabEntry = function(tabId) {
|
|||
};
|
||||
|
||||
page.removePageInformationFromNotExistingTabs = function() {
|
||||
let rand = Math.floor(Math.random()*1001);
|
||||
const rand = Math.floor(Math.random() * 1001);
|
||||
if (rand === 28) {
|
||||
browser.tabs.query({}).then(function(tabs) {
|
||||
let $tabIds = [];
|
||||
const $infoIds = Object.keys(page.tabs);
|
||||
const tabIds = [];
|
||||
const infoIds = Object.keys(page.tabs);
|
||||
|
||||
for (const t of tabs) {
|
||||
$tabIds[t.id] = true;
|
||||
tabIds[t.id] = true;
|
||||
}
|
||||
|
||||
for (const i of $infoIds) {
|
||||
if (!(i in $tabIds)) {
|
||||
for (const i of infoIds) {
|
||||
if (!(i in tabIds)) {
|
||||
delete page.tabs[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -143,8 +143,7 @@ page.removePageInformationFromNotExistingTabs = function() {
|
|||
page.debugConsole = function() {
|
||||
if (arguments.length > 1) {
|
||||
console.log(page.sprintf(arguments[0], arguments));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
console.log(arguments[0]);
|
||||
}
|
||||
};
|
||||
|
|
@ -163,8 +162,7 @@ page.setDebug = function(bool) {
|
|||
if (bool) {
|
||||
page.debug = page.debugConsole;
|
||||
return 'Debug mode enabled';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
page.debug = page.debugDummy;
|
||||
return 'Debug mode disabled';
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -61,21 +61,21 @@
|
|||
}
|
||||
],
|
||||
"commands": {
|
||||
"fill-username-password": {
|
||||
"fill_username_password": {
|
||||
"description": "__MSG_contextMenuFillUsernameAndPassword__",
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+U",
|
||||
"mac": "MacCtrl+Shift+U"
|
||||
}
|
||||
},
|
||||
"fill-password": {
|
||||
"fill_password": {
|
||||
"description": "__MSG_contextMenuFillPassword__",
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+I",
|
||||
"mac": "MacCtrl+Shift+I"
|
||||
}
|
||||
},
|
||||
"fill-totp": {
|
||||
"fill_totp": {
|
||||
"description": "__MSG_contextMenuFillTOTP__",
|
||||
"suggested_key": {
|
||||
"default": "Alt+Shift+T",
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@
|
|||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel" data-i18n="optionsIgnoredSitesRemove"></h3>
|
||||
<h3 id="myModalLabel" data-i18n="optionsSitePreferencesRemove"></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><span data-i18n="optionsSitePreferencesConfirmation" i18n-placeholder="<strong></strong>"></span></p>
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ options.initMenu = function() {
|
|||
|
||||
options.saveSettingsPromise = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
browser.storage.local.set({'settings': options.settings}).then((item) => {
|
||||
browser.storage.local.set({ 'settings': options.settings }).then((item) => {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'load_settings'
|
||||
}).then((settings) => {
|
||||
|
|
@ -56,21 +56,21 @@ options.saveSetting = function(name) {
|
|||
$(id).closest('.control-group').removeClass('error').addClass('success');
|
||||
setTimeout(() => { $(id).closest('.control-group').removeClass('success'); }, 2500);
|
||||
|
||||
browser.storage.local.set({'settings': options.settings});
|
||||
browser.storage.local.set({ 'settings': options.settings });
|
||||
browser.runtime.sendMessage({
|
||||
action: 'load_settings'
|
||||
});
|
||||
};
|
||||
|
||||
options.saveSettings = function() {
|
||||
browser.storage.local.set({'settings': options.settings});
|
||||
browser.storage.local.set({ 'settings': options.settings });
|
||||
browser.runtime.sendMessage({
|
||||
action: 'load_settings'
|
||||
});
|
||||
};
|
||||
|
||||
options.saveKeyRing = function() {
|
||||
browser.storage.local.set({'keyRing': options.keyRing});
|
||||
browser.storage.local.set({ 'keyRing': options.keyRing });
|
||||
browser.runtime.sendMessage({
|
||||
action: 'load_keyring'
|
||||
});
|
||||
|
|
@ -86,7 +86,7 @@ options.initGeneralSettings = function() {
|
|||
options.settings[name] = $(this).is(':checked');
|
||||
options.saveSettingsPromise().then((x) => {
|
||||
if (name === 'autoFillAndSend') {
|
||||
browser.runtime.sendMessage({action: 'init_http_auth'});
|
||||
browser.runtime.sendMessage({ action: 'init_http_auth' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -128,11 +128,11 @@ options.initGeneralSettings = function() {
|
|||
|
||||
$('#configureCommands').click(function() {
|
||||
browser.tabs.create({
|
||||
url: isFirefox() ? browser.runtime.getURL("options/shortcuts.html") : 'chrome://extensions/configureCommands'
|
||||
url: isFirefox() ? browser.runtime.getURL('options/shortcuts.html') : 'chrome://extensions/configureCommands'
|
||||
});
|
||||
});
|
||||
|
||||
$('#blinkTimeoutButton').click(function(){
|
||||
$('#blinkTimeoutButton').click(function() {
|
||||
const blinkTimeout = $.trim($('#blinkTimeout').val());
|
||||
const blinkTimeoutval = blinkTimeout !== '' ? Number(blinkTimeout) : defaultSettings.blinkTimeout;
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ options.initGeneralSettings = function() {
|
|||
options.saveSetting('blinkTimeout');
|
||||
});
|
||||
|
||||
$('#blinkMinTimeoutButton').click(function(){
|
||||
$('#blinkMinTimeoutButton').click(function() {
|
||||
const blinkMinTimeout = $.trim($('#blinkMinTimeout').val());
|
||||
const blinkMinTimeoutval = blinkMinTimeout !== '' ? Number(blinkMinTimeout) : defaultSettings.redirectOffset;
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ options.initGeneralSettings = function() {
|
|||
options.saveSetting('blinkMinTimeout');
|
||||
});
|
||||
|
||||
$('#allowedRedirectButton').click(function(){
|
||||
$('#allowedRedirectButton').click(function() {
|
||||
const allowedRedirect = $.trim($('#allowedRedirect').val());
|
||||
const allowedRedirectval = allowedRedirect !== '' ? Number(allowedRedirect) : defaultSettings.redirectAllowance;
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ options.getPartiallyHiddenKey = function(key) {
|
|||
};
|
||||
|
||||
options.initConnectedDatabases = function() {
|
||||
$('#dialogDeleteConnectedDatabase').modal({keyboard: true, show: false, backdrop: true});
|
||||
$('#dialogDeleteConnectedDatabase').modal({ keyboard: true, show: false, backdrop: true });
|
||||
$('#tab-connected-databases tr.clone:first button.delete:first').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#dialogDeleteConnectedDatabase').data('hash', $(this).closest('tr').data('hash'));
|
||||
|
|
@ -233,7 +233,7 @@ options.initConnectedDatabases = function() {
|
|||
};
|
||||
|
||||
options.initCustomCredentialFields = function() {
|
||||
$('#dialogDeleteCustomCredentialFields').modal({keyboard: true, show: false, backdrop: true});
|
||||
$('#dialogDeleteCustomCredentialFields').modal({ keyboard: true, show: false, backdrop: true });
|
||||
$('#tab-custom-fields tr.clone:first button.delete:first').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#dialogDeleteCustomCredentialFields').data('url', $(this).closest('tr').data('url'));
|
||||
|
|
@ -262,7 +262,7 @@ options.initCustomCredentialFields = function() {
|
|||
const trClone = $('#tab-custom-fields table tr.clone:first').clone(true);
|
||||
trClone.removeClass('clone');
|
||||
let counter = 1;
|
||||
for (let url in options.settings['defined-custom-fields']) {
|
||||
for (const url in options.settings['defined-custom-fields']) {
|
||||
const tr = trClone.clone(true);
|
||||
tr.data('url', url);
|
||||
tr.attr('id', 'tr-scf' + counter);
|
||||
|
|
@ -280,7 +280,7 @@ options.initCustomCredentialFields = function() {
|
|||
};
|
||||
|
||||
options.initSitePreferences = function() {
|
||||
$('#dialogDeleteSite').modal({keyboard: true, show: false, backdrop: true});
|
||||
$('#dialogDeleteSite').modal({ keyboard: true, show: false, backdrop: true });
|
||||
$('#tab-site-preferences tr.clone:first button.delete:first').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#dialogDeleteSite').data('url', $(this).closest('tr').data('url'));
|
||||
|
|
@ -291,7 +291,7 @@ options.initSitePreferences = function() {
|
|||
|
||||
$('#tab-site-preferences tr.clone:first input[type=checkbox]:first').change(function() {
|
||||
const url = $(this).closest('tr').data('url');
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
for (const site of options.settings['sitePreferences']) {
|
||||
if (site.url === url) {
|
||||
site.usernameOnly = $(this).is(':checked');
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ options.initSitePreferences = function() {
|
|||
|
||||
$('#tab-site-preferences tr.clone:first select:first').change(function() {
|
||||
const url = $(this).closest('tr').data('url');
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
for (const site of options.settings['sitePreferences']) {
|
||||
if (site.url === url) {
|
||||
site.ignore = $(this).val();
|
||||
}
|
||||
|
|
@ -309,9 +309,9 @@ options.initSitePreferences = function() {
|
|||
options.saveSettings();
|
||||
});
|
||||
|
||||
$("#manualUrl").keyup(function(event) {
|
||||
$('#manualUrl').keyup(function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
$("#sitePreferencesManualAdd").click();
|
||||
$('#sitePreferencesManualAdd').click();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ options.initSitePreferences = function() {
|
|||
$('#tab-site-preferences table tbody:first').append(tr);
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').hide();
|
||||
|
||||
options.settings['sitePreferences'].push({url: value, ignore: IGNORE_NOTHING, usernameOnly: false});
|
||||
options.settings['sitePreferences'].push({ url: value, ignore: IGNORE_NOTHING, usernameOnly: false });
|
||||
options.saveSettings();
|
||||
|
||||
$('#manualUrl').val('');
|
||||
|
|
@ -371,7 +371,7 @@ options.initSitePreferences = function() {
|
|||
const trClone = $('#tab-site-preferences table tr.clone:first').clone(true);
|
||||
trClone.removeClass('clone');
|
||||
let counter = 1;
|
||||
if (options.settings['sitePreferences']){
|
||||
if (options.settings['sitePreferences']) {
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
const tr = trClone.clone(true);
|
||||
tr.data('url', site.url);
|
||||
|
|
@ -396,7 +396,7 @@ options.initAbout = function() {
|
|||
$('#tab-about em.versionCIP').text(browser.runtime.getManifest().version);
|
||||
|
||||
// Hides keyboard shortcut configure button if Firefox version is < 60 (API is not compatible)
|
||||
if (isFirefox() && Number(navigator.userAgent.substr(navigator.userAgent.lastIndexOf('/')+1, 2)) < 60) {
|
||||
if (isFirefox() && Number(navigator.userAgent.substr(navigator.userAgent.lastIndexOf('/') + 1, 2)) < 60) {
|
||||
$('#chrome-only').remove();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ document.querySelectorAll('input').forEach((b) => {
|
|||
|
||||
const saveButtons = document.querySelectorAll('.btn-primary');
|
||||
for (const b of saveButtons) {
|
||||
b.addEventListener('click', e => {
|
||||
b.addEventListener('click', (e) => {
|
||||
updateShortcut(b.parentElement.children[1].getAttribute('id'))
|
||||
});
|
||||
}
|
||||
|
||||
const resetButtons = document.querySelectorAll('.btn-danger');
|
||||
for (const b of resetButtons) {
|
||||
b.addEventListener('click', e => {
|
||||
b.addEventListener('click', (e) => {
|
||||
resetShortcut(b.parentElement.children[1].getAttribute('id'))
|
||||
});
|
||||
}
|
||||
|
|
@ -69,12 +69,12 @@ async function updateKeys() {
|
|||
|
||||
async function updateShortcut(shortcut) {
|
||||
try {
|
||||
await browser.commands.update({
|
||||
await browser.commands.update({
|
||||
name: shortcut,
|
||||
shortcut: document.querySelector('#' + shortcut).value
|
||||
});
|
||||
createBanner('success', shortcut);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.log('Cannot change shortcut: ' + e);
|
||||
createBanner('danger', shortcut);
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ function createBanner(type, shortcut) {
|
|||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
document.body.appendChild(banner);
|
||||
|
||||
// Destroy the banner after five seconds
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
function status_response(r) {
|
||||
function statusResponse(r) {
|
||||
$('#initial-state').hide();
|
||||
$('#error-encountered').hide();
|
||||
$('#need-reconfigure').hide();
|
||||
|
|
@ -12,27 +12,21 @@ function status_response(r) {
|
|||
if (!r.keePassXCAvailable) {
|
||||
$('#error-message').html(r.error);
|
||||
$('#error-encountered').show();
|
||||
}
|
||||
else if (r.keePassXCAvailable && r.databaseClosed) {
|
||||
} else if (r.keePassXCAvailable && r.databaseClosed) {
|
||||
$('#database-error-message').html(r.error);
|
||||
$('#database-not-opened').show();
|
||||
}
|
||||
else if (!r.configured) {
|
||||
} else if (!r.configured) {
|
||||
$('#not-configured').show();
|
||||
}
|
||||
else if (r.encryptionKeyUnrecognized) {
|
||||
} else if (r.encryptionKeyUnrecognized) {
|
||||
$('#need-reconfigure').show();
|
||||
$('#need-reconfigure-message').html(r.error);
|
||||
}
|
||||
else if (!r.associated) {
|
||||
} else if (!r.associated) {
|
||||
$('#need-reconfigure').show();
|
||||
$('#need-reconfigure-message').html(r.error);
|
||||
}
|
||||
else if (r.error !== null) {
|
||||
} else if (r.error !== null) {
|
||||
$('#error-encountered').show();
|
||||
$('#error-message').html(r.error);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('#configured-and-associated').show();
|
||||
$('#associated-identifier').html(r.identifier);
|
||||
$('#lock-database-button').show();
|
||||
|
|
@ -57,22 +51,22 @@ $(function() {
|
|||
$('#reload-status-button').click(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'reconnect'
|
||||
}).then(status_response);
|
||||
}).then(statusResponse);
|
||||
});
|
||||
|
||||
$('#reopen-database-button').click(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'get_status',
|
||||
args: [ false, true ] // Set forcePopup to true
|
||||
}).then(status_response);
|
||||
}).then(statusResponse);
|
||||
});
|
||||
|
||||
$('#redetect-fields-button').click(function() {
|
||||
browser.tabs.query({"active": true, "currentWindow": true}).then(function(tabs) {
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then(function(tabs) {
|
||||
if (tabs.length === 0) {
|
||||
return; // For example: only the background devtools or a popup are opened
|
||||
}
|
||||
let tab = tabs[0];
|
||||
const tab = tabs[0];
|
||||
|
||||
browser.tabs.sendMessage(tab.id, {
|
||||
action: 'redetect_fields'
|
||||
|
|
@ -83,10 +77,10 @@ $(function() {
|
|||
$('#lock-database-button').click(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'lock-database'
|
||||
}).then(status_response);
|
||||
}).then(statusResponse);
|
||||
});
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
action: "get_status"
|
||||
}).then(status_response);
|
||||
action: 'get_status'
|
||||
}).then(statusResponse);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
const getLoginData = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
browser.runtime.getBackgroundPage().then((global) => {
|
||||
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
|
||||
resolve(global.page.tabs[tabs[0].id].loginList);
|
||||
});
|
||||
});
|
||||
|
|
@ -12,13 +12,13 @@ const getLoginData = function() {
|
|||
|
||||
$(function() {
|
||||
getLoginData().then((data) => {
|
||||
let ll = document.getElementById('login-list');
|
||||
const ll = document.getElementById('login-list');
|
||||
for (let i = 0; i < data.logins.length; ++i) {
|
||||
const a = document.createElement('a');
|
||||
a.setAttribute('class', 'list-group-item');
|
||||
a.textContent = data.logins[i].login + " (" + data.logins[i].name + ")";
|
||||
a.textContent = data.logins[i].login + ' (' + data.logins[i].name + ')';
|
||||
$(a).data('creds', data.logins[i]);
|
||||
$(a).click(function () {
|
||||
$(a).click(function() {
|
||||
if (data.resolve) {
|
||||
const creds = $(this).data('creds');
|
||||
data.resolve({
|
||||
|
|
@ -37,8 +37,8 @@ $(function() {
|
|||
$('#lock-database-button').click(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'lock-database'
|
||||
}).then(status_response);
|
||||
});
|
||||
}).then(statusResponse);
|
||||
});
|
||||
|
||||
$('#btn-dismiss').click(function() {
|
||||
getLoginData().then((data) => {
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
$(function() {
|
||||
browser.runtime.getBackgroundPage().then((global) => {
|
||||
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
|
||||
browser.tabs.query({ 'active': true, 'currentWindow': true }).then((tabs) => {
|
||||
if (tabs.length === 0) {
|
||||
return; // For example: only the background devtools or a popup are opened
|
||||
}
|
||||
const tab = tabs[0];
|
||||
|
||||
const logins = global.page.tabs[tab.id].loginList;
|
||||
let ll = document.getElementById('login-list');
|
||||
const ll = document.getElementById('login-list');
|
||||
for (let i = 0; i < logins.length; i++) {
|
||||
const a = document.createElement('a');
|
||||
a.textContent = logins[i];
|
||||
|
|
@ -25,17 +25,17 @@ $(function() {
|
|||
});
|
||||
ll.appendChild(a);
|
||||
}
|
||||
|
||||
|
||||
if (logins.length > 1) {
|
||||
document.getElementById('filter-block').style = '';
|
||||
let filter = document.getElementById('login-filter');
|
||||
const filter = document.getElementById('login-filter');
|
||||
filter.addEventListener('keyup', (e) => {
|
||||
let val = filter.value;
|
||||
let re = new RegExp(val, 'i');
|
||||
let links = ll.getElementsByTagName('a');
|
||||
for (let i in links) {
|
||||
const val = filter.value;
|
||||
const re = new RegExp(val, 'i');
|
||||
const links = ll.getElementsByTagName('a');
|
||||
for (const i in links) {
|
||||
if (links.hasOwnProperty(i)) {
|
||||
let found = String(links[i].textContent).match(re) !== null;
|
||||
const found = String(links[i].textContent).match(re) !== null;
|
||||
links[i].style = found ? '' : 'display: none;';
|
||||
}
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ $(function() {
|
|||
$('#reopen-database-button').click(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'get_status',
|
||||
args: [ false, true ] // Set forcePopup to true
|
||||
args: [ false, true ] // Set forcePopup to true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function _initialize(tab) {
|
|||
e.preventDefault();
|
||||
|
||||
// Only one entry which could be updated
|
||||
if(_tab.credentials.list.length === 1) {
|
||||
if (_tab.credentials.list.length === 1) {
|
||||
// Use the current username if it's empty
|
||||
if (!_tab.credentials.username) {
|
||||
_tab.credentials.username = _tab.credentials.list[0].login;
|
||||
|
|
@ -47,22 +47,20 @@ function _initialize(tab) {
|
|||
action: 'update_credentials',
|
||||
args: [_tab.credentials.list[0].uuid, _tab.credentials.username, _tab.credentials.password, _tab.credentials.url]
|
||||
}).then(_verifyResult);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('.credentials:first .username-new:first strong:first').text(_tab.credentials.username);
|
||||
$('.credentials:first .username-exists:first strong:first').text(_tab.credentials.username);
|
||||
|
||||
if (_tab.credentials.usernameExists) {
|
||||
$('.credentials:first .username-new:first').hide();
|
||||
$('.credentials:first .username-exists:first').show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('.credentials:first .username-new:first').show();
|
||||
$('.credentials:first .username-exists:first').hide();
|
||||
}
|
||||
|
||||
for (let i = 0; i < _tab.credentials.list.length; i++) {
|
||||
let $a = $('<a>')
|
||||
const $a = $('<a>')
|
||||
.attr('href', '#')
|
||||
.text(_tab.credentials.list[i].login + ' (' + _tab.credentials.list[i].name + ')')
|
||||
.data('entryId', i)
|
||||
|
|
@ -84,7 +82,7 @@ function _initialize(tab) {
|
|||
_verifyResult('error');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Show a notification if the user tries to update credentials using the old password
|
||||
if (credentials[entryId].password === _tab.credentials.password) {
|
||||
showNotification('Error: Credentials not updated. The password has not been changed.');
|
||||
|
|
@ -122,8 +120,8 @@ function _initialize(tab) {
|
|||
const tab = tabs[0];
|
||||
browser.runtime.getBackgroundPage().then((global) => {
|
||||
browser.tabs.sendMessage(tab.id, {
|
||||
action: 'ignore-site',
|
||||
args: [_tab.credentials.url]
|
||||
action: 'ignore_site',
|
||||
args: [ _tab.credentials.url ]
|
||||
});
|
||||
_close();
|
||||
});
|
||||
|
|
@ -132,12 +130,11 @@ function _initialize(tab) {
|
|||
});
|
||||
}
|
||||
|
||||
function _connected_database(db) {
|
||||
function _connectedDatabase(db) {
|
||||
if (db.count > 1 && db.identifier) {
|
||||
$('.connected-database:first em:first').text(db.identifier);
|
||||
$('.connected-database:first').show();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$('.connected-database:first').hide();
|
||||
}
|
||||
}
|
||||
|
|
@ -164,7 +161,7 @@ function _close() {
|
|||
$(function() {
|
||||
browser.runtime.sendMessage({
|
||||
action: 'stack_add',
|
||||
args: ['icon_remember_red_background_19x19.png', 'popup_remember.html', 10, true, 0]
|
||||
args: [ 'icon_remember_red_background_19x19.png', 'popup_remember.html', 10, true, 0 ]
|
||||
});
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
|
|
@ -173,5 +170,5 @@ $(function() {
|
|||
|
||||
browser.runtime.sendMessage({
|
||||
action: 'get_connected_database'
|
||||
}).then(_connected_database);
|
||||
}).then(_connectedDatabase);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
'use strict';
|
||||
|
||||
const items = document.querySelectorAll('[data-i18n]');
|
||||
for (let item of items) {
|
||||
for (const item of items) {
|
||||
const key = item.getAttribute('data-i18n');
|
||||
if (key) {
|
||||
const placeholder = item.getAttribute('i18n-placeholder');
|
||||
|
|
|
|||
Loading…
Reference in a new issue