Date: Tue, 3 Apr 2018 08:46:51 +0300
Subject: [PATCH 11/22] Some more fixes
---
keepassxc-browser/keepassxc-browser.css | 3 ++-
keepassxc-browser/keepassxc-browser.js | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/keepassxc-browser/keepassxc-browser.css b/keepassxc-browser/keepassxc-browser.css
index f61efc0..d4b50cd 100644
--- a/keepassxc-browser/keepassxc-browser.css
+++ b/keepassxc-browser/keepassxc-browser.css
@@ -18,6 +18,7 @@
.kpxc .ui-dialog {
font-size: 12px !important;
box-shadow: 0 4px 6px 0 hsla(0, 0%, 0%, 0.2);
+ z-index: 2147483645;
}
.kpxc .ui-widget-overlay {
@@ -57,7 +58,7 @@ input.genpw-text {
}
.genpw-input-group-addon {
- font-size: inherit !important;
+ font-size: .9em !important;
background-color: #eee;
border: 1px solid #ccc;
padding: .2em;
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index 88c7064..cd7781d 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -231,7 +231,7 @@ cipPassword.createDialog = function() {
.addClass('genpw-input-group-addon')
.addClass('b2c-add-on')
.attr('id', 'cip-genpw-quality')
- .text('123 Bits');
+ .text('??? Bits');
$inputGroup.append($textfieldPassword).append($quality);
const $checkGroup = jQuery('').addClass('genpw-input-group');
From e5819d6bc1ebe64c823395cbdd9d420abda85270 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Tue, 3 Apr 2018 15:01:57 +0300
Subject: [PATCH 12/22] Revert to default values when saving empty input field
---
keepassxc-browser/options/options.html | 6 +++---
keepassxc-browser/options/options.js | 12 +++++++++---
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html
index 55e060f..dc0266a 100644
--- a/keepassxc-browser/options/options.html
+++ b/keepassxc-browser/options/options.html
@@ -39,7 +39,7 @@
Blink Time:
@@ -55,7 +55,7 @@
Redirect Offset:
@@ -73,7 +73,7 @@
Redirect Allowance:
diff --git a/keepassxc-browser/options/options.js b/keepassxc-browser/options/options.js
index b4d826a..7791a2f 100644
--- a/keepassxc-browser/options/options.js
+++ b/keepassxc-browser/options/options.js
@@ -2,6 +2,12 @@ if (jQuery) {
var $ = jQuery.noConflict(true);
}
+const defaultSettings = {
+ blinkTimeout: 7500,
+ redirectOffset: -1,
+ redirectAllowance: 1
+};
+
$(function() {
browser.runtime.sendMessage({ action: 'load_settings' }).then((settings) => {
options.settings = settings;
@@ -111,7 +117,7 @@ options.initGeneralSettings = function() {
$('#blinkTimeoutButton').click(function(){
const blinkTimeout = $.trim($('#blinkTimeout').val());
- const blinkTimeoutval = Number(blinkTimeout);
+ const blinkTimeoutval = blinkTimeout !== '' ? Number(blinkTimeout) : defaultSettings.blinkTimeout;
options.settings['blinkTimeout'] = String(blinkTimeoutval);
options.saveSetting('blinkTimeout');
@@ -119,7 +125,7 @@ options.initGeneralSettings = function() {
$('#blinkMinTimeoutButton').click(function(){
const blinkMinTimeout = $.trim($('#blinkMinTimeout').val());
- const blinkMinTimeoutval = Number(blinkMinTimeout);
+ const blinkMinTimeoutval = blinkMinTimeout !== '' ? Number(blinkMinTimeout) : defaultSettings.redirectOffset;
options.settings['blinkMinTimeout'] = String(blinkMinTimeoutval);
options.saveSetting('blinkMinTimeout');
@@ -127,7 +133,7 @@ options.initGeneralSettings = function() {
$('#allowedRedirectButton').click(function(){
const allowedRedirect = $.trim($('#allowedRedirect').val());
- const allowedRedirectval = Number(allowedRedirect);
+ const allowedRedirectval = allowedRedirect !== '' ? Number(allowedRedirect) : defaultSettings.redirectAllowance;
options.settings['allowedRedirect'] = String(allowedRedirectval);
options.saveSetting('allowedRedirect');
From 812d816d031faf4a40aa0370871073acb8f140d0 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Wed, 4 Apr 2018 12:07:03 +0300
Subject: [PATCH 13/22] Modify shortcuts
---
keepassxc-browser/manifest.json | 4 ++--
keepassxc-browser/options/options.html | 4 ++--
keepassxc-browser/options/options.js | 12 ++++++++++++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/keepassxc-browser/manifest.json b/keepassxc-browser/manifest.json
index 0838780..f6e0b79 100755
--- a/keepassxc-browser/manifest.json
+++ b/keepassxc-browser/manifest.json
@@ -72,8 +72,8 @@
"fill-password": {
"description": "Insert a password",
"suggested_key": {
- "default": "Alt+Shift+P",
- "mac": "MacCtrl+Shift+P"
+ "default": "Alt+Shift+I",
+ "mac": "MacCtrl+Shift+I"
}
},
"fill-totp": {
diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html
index 55e060f..34961b1 100644
--- a/keepassxc-browser/options/options.html
+++ b/keepassxc-browser/options/options.html
@@ -29,9 +29,9 @@
General Settings
- If you just want to insert username + password into the fields where your focus is, press Alt + Shift + U.
+ If you just want to insert username + password into the fields where your focus is, press Ctrl + Shift + U Alt + Shift + U .
- If you only want to insert the password, just press Alt + Shift + P.
+ If you only want to insert the password, just press Ctrl + Shift + I Alt + Shift + I .
You can customize these shortcuts on chrome://extensions/configureCommands page
diff --git a/keepassxc-browser/options/options.js b/keepassxc-browser/options/options.js
index b4d826a..83fcdeb 100644
--- a/keepassxc-browser/options/options.js
+++ b/keepassxc-browser/options/options.js
@@ -261,4 +261,16 @@ options.initAbout = function() {
if (isFirefox()) {
$('#chrome-only').remove();
}
+
+ if (navigator.platform === 'MacIntel') {
+ $('#default-user-shortcut').hide();
+ $('#default-pass-shortcut').hide();
+ $('#mac-user-shortcut').show();
+ $('#mac-pass-shortcut').show();
+ } else {
+ $('#mac-user-shortcut').hide();
+ $('#mac-pass-shortcut').hide();
+ $('#default-user-shortcut').show();
+ $('#default-pass-shortcut').show();
+ }
};
From 150699cca80171fb4a5bbe3f345aafe1dfe5734e Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Sat, 7 Apr 2018 12:04:01 +0300
Subject: [PATCH 14/22] Added save domain only option
---
keepassxc-browser/background/page.js | 6 +++++-
keepassxc-browser/keepassxc-browser.js | 2 +-
keepassxc-browser/options/options.html | 9 +++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js
index ab7bd27..2d6a2d1 100755
--- a/keepassxc-browser/background/page.js
+++ b/keepassxc-browser/background/page.js
@@ -6,7 +6,8 @@ const defaultSettings = {
autoFillSingleEntry: false,
autoRetrieveCredentials: true,
showNotifications: true,
- showLoginNotifications: true
+ showLoginNotifications: true,
+ saveDomainOnly: true
};
var page = {};
@@ -42,6 +43,9 @@ page.initSettings = function() {
if (!('showLoginNotifications' in page.settings)) {
page.settings.showLoginNotifications = defaultSettings.showLoginNotifications;
}
+ if (!('saveDomainOnly' in page.settings)) {
+ page.settings.saveDomainOnly = defaultSettings.saveDomainOnly;
+ }
browser.storage.local.set({'settings': page.settings});
resolve(page.settings);
});
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index 88c7064..8e19d81 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -1762,7 +1762,7 @@ cip.rememberCredentials = function(usernameValue, passwordValue) {
let url = jQuery(this)[0].action;
if (!url) {
- url = document.location.href;
+ url = cip.settings.saveDomainOnly ? document.location.origin : document.location.href;
if (url.indexOf('?') > 0) {
url = url.substring(0, url.indexOf('?'));
if (url.length < document.location.origin.length) {
diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html
index 55e060f..c7b8d33 100644
--- a/keepassxc-browser/options/options.html
+++ b/keepassxc-browser/options/options.html
@@ -139,6 +139,15 @@
+
+
+
+ Save domain only.
+
+ When saving new credentials save only the domain instead of full URL.
+
+
+
Check for updates of KeePassXC:
From b443843a1855aa4b7a68993ce32fd512c81f5b01 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Fri, 13 Apr 2018 14:16:40 +0300
Subject: [PATCH 15/22] Fixes TOTP filling with multiple credentials
---
keepassxc-browser/keepassxc-browser.js | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index 88c7064..92cecc2 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -3,6 +3,7 @@ var _called = {};
_called.retrieveCredentials = false;
_called.clearLogins = false;
_called.manualFillRequested = 'none';
+let _loginId = -1;
// Count of detected form fields on the page
var _detectedFields = 0;
@@ -15,10 +16,12 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) {
if (cip.u) {
cip.setValueWithChange(cip.u, cip.credentials[req.id].login);
combination = cipFields.getCombination('username', cip.u);
+ _loginId = req.id;
cip.u.focus();
}
if (cip.p) {
cip.setValueWithChange(cip.p, cip.credentials[req.id].password);
+ _loginId = req.id;
combination = cipFields.getCombination('password', cip.p);
}
@@ -1473,17 +1476,21 @@ cip.fillInFromActiveElementTOTPOnly = function(suppressWarnings) {
const el = document.activeElement;
cipFields.setUniqueId(jQuery(el));
const fieldId = cipFields.prepareId(jQuery(el).attr('data-cip-id'));
+ const pos = _loginId;
- if (cip.credentials[0]) {
+ if (pos >= 0 && cip.credentials[pos]) {
+ // Check the value from stringFields (to be removed)
const $sf = _fs(fieldId);
- if (cip.credentials[0].stringFields && cip.credentials[0].stringFields.length > 0) {
- const sFields = cip.credentials[0].stringFields;
+ if (cip.credentials[pos].stringFields && cip.credentials[pos].stringFields.length > 0) {
+ const sFields = cip.credentials[pos].stringFields;
for (const s of sFields) {
const val = s["KPH: {TOTP}"];
if (val) {
cip.setValue($sf, val);
}
}
+ } else if (cip.credentials[pos].totp && cip.credentials[pos].totp.length > 0) {
+ cip.setValue($sf, cip.credentials[pos].totp);
}
}
};
@@ -1555,12 +1562,14 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
let filledIn = false;
if (uField && !onlyPassword) {
cip.setValueWithChange(uField, cip.credentials[0].login);
+ _loginId = 0;
filledIn = true;
}
if (pField) {
pField.attr('type', 'password');
cip.setValueWithChange(pField, cip.credentials[0].password);
pField.data('unchanged', true);
+ _loginId = 0;
filledIn = true;
}
@@ -1585,12 +1594,14 @@ cip.fillIn = function(combination, onlyPassword, suppressWarnings) {
let filledIn = false;
if (uField) {
cip.setValueWithChange(uField, cip.credentials[combination.loginId].login);
+ _loginId = combination.loginId;
filledIn = true;
}
if (pField) {
cip.setValueWithChange(pField, cip.credentials[combination.loginId].password);
pField.data('unchanged', true);
+ _loginId = combination.loginId;
filledIn = true;
}
From 3b357e0100f6743378be9e35b4aaf9f6dbb9132d Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Mon, 30 Apr 2018 12:21:35 +0300
Subject: [PATCH 16/22] Improve detection of username fields
---
keepassxc-browser/keepassxc-browser.js | 36 +++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index 88c7064..89e2522 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -489,7 +489,7 @@ cipForm.init = function(form, credentialFields) {
// TODO: could be called multiple times --> update credentialFields
// not already initialized && password-field is not null
- if (!form.data('cipForm-initialized') && credentialFields.password) {
+ if (!form.data('cipForm-initialized') && (credentialFields.password || credentialFields.username)) {
form.data('cipForm-initialized', true);
cipForm.setInputFields(form, credentialFields);
form.submit(cipForm.onSubmit);
@@ -889,6 +889,15 @@ cipFields.getAllCombinations = function(inputs) {
}
}
+ // If only username field found, add it to the array
+ if (fields.length === 0 && uField) {
+ const combination = {
+ username: uField[0].getAttribute('data-cip-id'),
+ password: null
+ };
+ fields.push(combination);
+ }
+
return fields;
};
@@ -1033,7 +1042,7 @@ cipFields.getPasswordField = function(usernameId, checkDisabled) {
// search all inputs on this one form
if (form) {
passwordField = jQuery('input[type=\'password\']:first', form);
- if (passwordField.length < 1) {
+ if (passwordField && passwordField.length < 1) {
passwordField = null;
}
@@ -1236,6 +1245,11 @@ cip.initCredentialFields = function(forceCall) {
cip.url = document.location.origin;
cip.submitUrl = cip.getFormActionUrl(cipFields.combinations[0]);
+ // Get submitUrl for a single input
+ if (!cip.submitUrl && cipFields.combinations.length === 1 && inputs.length === 1) {
+ cip.submitUrl = cip.getFormActionUrlFromSingleInput(inputs[0]);
+ }
+
if (cip.settings.autoRetrieveCredentials && _called.retrieveCredentials === false && (cip.url && cip.submitUrl)) {
browser.runtime.sendMessage({
action: 'retrieve_credentials',
@@ -1358,7 +1372,9 @@ cip.preparePageForMultipleCredentials = function(credentials) {
cipAutocomplete.init(_f(i.username));
}
} else if (_detectedFields == 1) {
- // If only password field is the visible one
+ if (_f(i.username)) {
+ cipAutocomplete.init(_f(i.username));
+ }
if (_f(i.password)) {
cipAutocomplete.init(_f(i.password));
}
@@ -1392,6 +1408,20 @@ cip.getFormActionUrl = function(combination) {
return action;
};
+cip.getFormActionUrlFromSingleInput = function(field) {
+ if (!field) {
+ return null;
+ }
+
+ let action = field.formAction;
+
+ if (typeof(action) !== 'string' || action === '') {
+ action = document.location.origin + document.location.pathname;
+ }
+
+ return action;
+};
+
cip.fillInCredentials = function(combination, onlyPassword, suppressWarnings) {
const action = cip.getFormActionUrl(combination);
From 36801da0b24cc65be33bbdded620b035dc7fc168 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Fri, 6 Apr 2018 09:38:07 +0300
Subject: [PATCH 17/22] Hide remember popup when database is closed
---
keepassxc-browser/background/event.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js
index e4fe61e..569c06c 100755
--- a/keepassxc-browser/background/event.js
+++ b/keepassxc-browser/background/event.js
@@ -217,7 +217,17 @@ kpxcEvent.onRemoveCredentialsFromTabInformation = function(callback, tab) {
};
kpxcEvent.onSetRememberPopup = function(callback, tab, username, password, url, usernameExists, credentialsList) {
- browserAction.setRememberPopup(tab.id, username, password, url, usernameExists, credentialsList);
+ keepass.testAssociation((response) => {
+ if (response) {
+ keepass.isConfigured().then((configured) => {
+ if (configured) {
+ browserAction.setRememberPopup(tab.id, username, password, url, usernameExists, credentialsList);
+ }
+ }).catch((e) => {
+ console.log(e);
+ });
+ }
+ }, tab);
};
kpxcEvent.onLoginPopup = function(callback, tab, logins) {
From 156310cfdd3ee7c356e6075447f7db60c658deb8 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Mon, 2 Apr 2018 13:29:24 +0300
Subject: [PATCH 18/22] Redetect credential fields after reload
---
keepassxc-browser/background/event.js | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js
index e4fe61e..40c97a8 100755
--- a/keepassxc-browser/background/event.js
+++ b/keepassxc-browser/background/event.js
@@ -72,7 +72,9 @@ kpxcEvent.invoke = function(handler, callback, senderTabId, args, secondTime) {
else {
console.log('undefined handler for tab ' + tab.id);
}
- }).catch((e) => {console.log(e);});
+ }).catch((e) => {
+ console.log(e);
+ });
};
kpxcEvent.onShowNotification = function(callback, tab, message) {
@@ -160,13 +162,18 @@ kpxcEvent.onReconnect = function(callback, tab) {
if (gdRes) {
keepass.testAssociation((response) => {
keepass.isConfigured().then((configured) => {
+ browser.tabs.sendMessage(tab.id, {
+ action: 'redetect_fields'
+ });
kpxcEvent.showStatus(configured, tab, callback);
- }).catch((e) => {console.log(e);});
+ }).catch((e) => {
+ console.log(e);
+ });
}, tab);
}
}, null);
});
- }, 2000);
+ }, 500);
};
kpxcEvent.lockDatabase = function(callback, tab) {
From 358da84180ef68597059c7c91c959fdeebda043c Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Fri, 9 Mar 2018 14:42:56 +0200
Subject: [PATCH 19/22] Fixes memory leaks on idle. Use strict on every script
---
keepassxc-browser/background/browserAction.js | 2 +
keepassxc-browser/background/event.js | 11 +--
keepassxc-browser/background/httpauth.js | 2 +
keepassxc-browser/background/init.js | 2 +
keepassxc-browser/background/keepass.js | 14 +++-
keepassxc-browser/background/page.js | 8 ++-
keepassxc-browser/global.js | 2 +
keepassxc-browser/keepassxc-browser.js | 68 +++++++++----------
keepassxc-browser/options/options.js | 2 +
keepassxc-browser/popups/popup.js | 2 +
keepassxc-browser/popups/popup_functions.js | 2 +
keepassxc-browser/popups/popup_httpauth.js | 2 +
keepassxc-browser/popups/popup_login.js | 2 +
keepassxc-browser/popups/popup_remember.js | 2 +
14 files changed, 71 insertions(+), 50 deletions(-)
diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js
index d2fdb7d..4a5e7e0 100755
--- a/keepassxc-browser/background/browserAction.js
+++ b/keepassxc-browser/background/browserAction.js
@@ -1,3 +1,5 @@
+'use strict';
+
const browserAction = {};
const BLINK_TIMEOUT_DEFAULT = 7500;
diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js
index e4fe61e..de3e6e9 100755
--- a/keepassxc-browser/background/event.js
+++ b/keepassxc-browser/background/event.js
@@ -1,3 +1,5 @@
+'use strict';
+
const kpxcEvent = {};
kpxcEvent.onMessage = function(request, sender, callback) {
@@ -264,19 +266,10 @@ kpxcEvent.pageClearLogins = function(callback, tab, alreadyCalled) {
callback();
};
-kpxcEvent.oldDatabaseHash = 'no-hash';
-kpxcEvent.checkDatabaseHash = function(callback, tab) {
- keepass.checkDatabaseHash((response) => {
- callback({old: kpxcEvent.oldDatabaseHash, new: response});
- kpxcEvent.oldDatabaseHash = response;
- });
-};
-
// all methods named in this object have to be declared BEFORE this!
kpxcEvent.messageHandlers = {
'add_credentials': keepass.addCredentials,
'associate': keepass.associate,
- 'check_databasehash': kpxcEvent.checkDatabaseHash,
'check_update_keepassxc': kpxcEvent.onCheckUpdateKeePassXC,
'generate_password': keepass.generatePassword,
'get_connected_database': kpxcEvent.onGetConnectedDatabase,
diff --git a/keepassxc-browser/background/httpauth.js b/keepassxc-browser/background/httpauth.js
index 5457caa..cdd23ed 100755
--- a/keepassxc-browser/background/httpauth.js
+++ b/keepassxc-browser/background/httpauth.js
@@ -1,3 +1,5 @@
+'use strict';
+
const httpAuth = {};
httpAuth.requests = [];
diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js
index 4f6c6af..ce7fed7 100644
--- a/keepassxc-browser/background/init.js
+++ b/keepassxc-browser/background/init.js
@@ -1,3 +1,5 @@
+'use strict';
+
keepass.migrateKeyRing().then(() => {
page.initSettings().then(() => {
page.initOpenedTabs().then(() => {
diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js
index d7edd2f..6dec6aa 100755
--- a/keepassxc-browser/background/keepass.js
+++ b/keepassxc-browser/background/keepass.js
@@ -18,6 +18,7 @@ keepass.keySize = 24;
keepass.latestVersionUrl = 'https://api.github.com/repos/keepassxreboot/keepassxc/releases/latest';
keepass.cacheTimeout = 30 * 1000; // milliseconds
keepass.databaseHash = 'no-hash'; //no-hash = KeePassXC is too old and does not return a hash value
+keepass.previousDatabaseHash = 'no-hash';
keepass.keyId = 'keepassxc-browser-cryptokey-name';
keepass.keyBody = 'keepassxc-browser-key';
keepass.messageTimeout = 500; // milliseconds
@@ -835,11 +836,22 @@ keepass.onNativeMessage = function(response) {
// Handle database lock/unlock status
if (response.action === kpActions.DATABASE_LOCKED || response.action === kpActions.DATABASE_UNLOCKED) {
- keepass.testAssociation((response) => {
+ keepass.testAssociation((associationResponse) => {
keepass.isConfigured().then((configured) => {
let data = page.tabs[page.currentTabId].stack[page.tabs[page.currentTabId].stack.length - 1];
data.iconType = configured ? 'normal' : 'cross';
browserAction.show(null, {'id': page.currentTabId});
+
+ // Send message to content script
+ browser.tabs.query({ active: true, currentWindow: true }).then((tabs) => {
+ if (tabs.length) {
+ browser.tabs.sendMessage(tabs[0].id, {
+ action: 'check_database_hash',
+ hash: {old: kpxcEvent.previousDatabaseHash, new: keepass.databaseHash}
+ });
+ keepass.previousDatabaseHash = keepass.databaseHash;
+ }
+ });
});
}, null);
}
diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js
index 2d6a2d1..60be892 100755
--- a/keepassxc-browser/background/page.js
+++ b/keepassxc-browser/background/page.js
@@ -1,3 +1,5 @@
+'use strict';
+
const defaultSettings = {
checkUpdateKeePassXC: 3,
autoCompleteUsernames: true,
@@ -11,9 +13,9 @@ const defaultSettings = {
};
var page = {};
-page.tabs = {};
+page.tabs = [];
page.currentTabId = -1;
-page.blockedTabs = {};
+page.blockedTabs = [];
page.initSettings = function() {
return new Promise((resolve, reject) => {
@@ -109,7 +111,7 @@ page.createTabEntry = function(tabId) {
page.tabs[tabId] = {
'stack': [],
'errorMessage': null,
- 'loginList': {}
+ 'loginList': []
};
};
diff --git a/keepassxc-browser/global.js b/keepassxc-browser/global.js
index 558dc9d..55456cd 100755
--- a/keepassxc-browser/global.js
+++ b/keepassxc-browser/global.js
@@ -1,3 +1,5 @@
+'use strict';
+
var isFirefox = function() {
if (!(/Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor))) {
return true;
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index c9561b8..dab0c74 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -1,3 +1,5 @@
+'use strict';
+
// contains already called method names
var _called = {};
_called.retrieveCredentials = false;
@@ -73,6 +75,9 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) {
cip.initCredentialFields(true);
});
}
+ else if (req.action === 'check_database_hash' && 'hash' in req) {
+ cip.detectDatabaseChange(req.hash);
+ }
}
});
@@ -814,7 +819,7 @@ cipFields.prepareId = function(id) {
// Check aria-hidden attribute by looping the parent elements of input field
cipFields.getAriaHidden = function(field) {
let $par = jQuery(field).parents();
- for (p of $par) {
+ for (const p of $par) {
const val = $(p).attr('aria-hidden');
if (val) {
return val;
@@ -825,7 +830,7 @@ cipFields.getAriaHidden = function(field) {
cipFields.getOverflowHidden = function(field) {
let $par = jQuery(field).parents();
- for (p of $par) {
+ for (const p of $par) {
const val = $(p).css('overflow');
if (val === 'hidden') {
return true;
@@ -1155,7 +1160,6 @@ cip.credentials = [];
jQuery(function() {
cip.init();
cip.detectNewActiveFields();
- cip.detectDatabaseChange();
});
cip.init = function() {
@@ -1182,46 +1186,36 @@ cip.detectNewActiveFields = function() {
};
// Switch credentials if database is changed or closed
-cip.detectDatabaseChange = function() {
- let dbDetectInterval = setInterval(function() {
- if (document.visibilityState !== 'hidden') {
+cip.detectDatabaseChange = function(response) {
+ if (document.visibilityState !== 'hidden') {
+ if (response.new === 'no-hash' && response.old !== 'no-hash') {
+ cipEvents.clearCredentials();
+
browser.runtime.sendMessage({
- action: 'check_databasehash'
+ action: 'page_clear_logins'
+ });
+
+ // Switch back to default popup
+ browser.runtime.sendMessage({
+ action: 'get_status',
+ args: [ true ] // Set polling to true, this is an internal function call
+ });
+ } else if (response.new !== 'no-hash' && response.new !== response.old) {
+ browser.runtime.sendMessage({
+ action: 'load_settings',
}).then((response) => {
- if (response.new === 'no-hash' && response.old !== 'no-hash') {
- cipEvents.clearCredentials();
+ cip.settings = response;
+ cip.initCredentialFields(true);
- browser.runtime.sendMessage({
- action: 'page_clear_logins'
- });
-
- // Switch back to default popup
- browser.runtime.sendMessage({
- action: 'get_status',
- args: [ true ] // Set polling to true, this is an internal function call
- });
- } else {
- if (response.new !== 'no-hash' && response.new !== response.old) {
- browser.runtime.sendMessage({
- action: 'load_settings',
- }).then((response) => {
- cip.settings = response;
- cip.initCredentialFields(true);
-
- // If user has requested a manual fill through context menu the actual credential filling
- // is handled here when the opened database has been regognized. It's not a pretty hack.
- if (_called.manualFillRequested && _called.manualFillRequested !== 'none') {
- cip.fillInFromActiveElement(false, (_called.manualFillRequested === 'pass' ? true : false));
- _called.manualFillRequested = 'none';
- }
- });
- }
+ // If user has requested a manual fill through context menu the actual credential filling
+ // is handled here when the opened database has been regognized. It's not a pretty hack.
+ if (_called.manualFillRequested && _called.manualFillRequested !== 'none') {
+ cip.fillInFromActiveElement(false, _called.manualFillRequested === 'pass');
+ _called.manualFillRequested = 'none';
}
- }).catch((e) => {
- console.log(e);
});
}
- }, 1000);
+ }
};
cip.initCredentialFields = function(forceCall) {
diff --git a/keepassxc-browser/options/options.js b/keepassxc-browser/options/options.js
index e7db3aa..2b5cad3 100644
--- a/keepassxc-browser/options/options.js
+++ b/keepassxc-browser/options/options.js
@@ -1,3 +1,5 @@
+'use strict';
+
if (jQuery) {
var $ = jQuery.noConflict(true);
}
diff --git a/keepassxc-browser/popups/popup.js b/keepassxc-browser/popups/popup.js
index be96e5c..98511aa 100644
--- a/keepassxc-browser/popups/popup.js
+++ b/keepassxc-browser/popups/popup.js
@@ -1,3 +1,5 @@
+'use strict';
+
function status_response(r) {
$('#initial-state').hide();
$('#error-encountered').hide();
diff --git a/keepassxc-browser/popups/popup_functions.js b/keepassxc-browser/popups/popup_functions.js
index 1eee4ac..83bd82d 100644
--- a/keepassxc-browser/popups/popup_functions.js
+++ b/keepassxc-browser/popups/popup_functions.js
@@ -1,3 +1,5 @@
+'use strict';
+
var $ = jQuery.noConflict(true);
function updateAvailableResponse(available) {
diff --git a/keepassxc-browser/popups/popup_httpauth.js b/keepassxc-browser/popups/popup_httpauth.js
index 9ce9271..cd68d91 100644
--- a/keepassxc-browser/popups/popup_httpauth.js
+++ b/keepassxc-browser/popups/popup_httpauth.js
@@ -1,3 +1,5 @@
+'use strict';
+
$(function() {
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
diff --git a/keepassxc-browser/popups/popup_login.js b/keepassxc-browser/popups/popup_login.js
index eae62d3..b0c2f74 100644
--- a/keepassxc-browser/popups/popup_login.js
+++ b/keepassxc-browser/popups/popup_login.js
@@ -1,3 +1,5 @@
+'use strict';
+
$(function() {
browser.runtime.getBackgroundPage().then((global) => {
browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => {
diff --git a/keepassxc-browser/popups/popup_remember.js b/keepassxc-browser/popups/popup_remember.js
index be79328..c8de9f1 100644
--- a/keepassxc-browser/popups/popup_remember.js
+++ b/keepassxc-browser/popups/popup_remember.js
@@ -1,3 +1,5 @@
+'use strict';
+
var _tab;
function _initialize(tab) {
From c47e5f86879383e7aa4ab6b694f0cf2574e9e4b5 Mon Sep 17 00:00:00 2001
From: varjolintu
Date: Fri, 6 Apr 2018 11:01:49 +0300
Subject: [PATCH 20/22] Add support for ignored sites
---
keepassxc-browser/background/browserAction.js | 50 ++++++++++++++-
keepassxc-browser/keepassxc-browser.js | 48 ++++++++------
keepassxc-browser/options/options.html | 47 ++++++++++++++
keepassxc-browser/options/options.js | 62 ++++++++++++++++---
keepassxc-browser/popups/popup_remember.html | 1 +
keepassxc-browser/popups/popup_remember.js | 15 +++++
6 files changed, 195 insertions(+), 28 deletions(-)
diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js
index d2fdb7d..98a5bfd 100755
--- a/keepassxc-browser/background/browserAction.js
+++ b/keepassxc-browser/background/browserAction.js
@@ -202,6 +202,14 @@ browserAction.removeRememberPopup = function(callback, tab, removeImmediately) {
browserAction.setRememberPopup = function(tabId, username, password, url, usernameExists, credentialsList) {
browser.storage.local.get({'settings': {}}).then(function(item) {
const settings = item.settings;
+
+ // Don't show anything if the site is in the ignore list
+ for (const site in settings.ignoredSites) {
+ if (site === url) {
+ return;
+ }
+ }
+
const id = tabId || page.currentTabId;
let timeoutMinMillis = Number(getValueOrDefault(settings, 'blinkMinTimeout', BLINK_TIMEOUT_REDIRECT_THRESHOLD_TIME_DEFAULT, 0));
@@ -240,7 +248,29 @@ browserAction.setRememberPopup = function(tabId, username, password, url, userna
browserAction.show(null, {'id': id});
if (page.settings.showLoginNotifications) {
- showNotification('Create or modify the credentials by clicking on the extension icon.');
+ const message = 'Create or modify the credentials by clicking on the extension icon.';
+ const buttons = [
+ {
+ 'title': 'Close'
+ },
+ {
+ 'title': 'Never ask for this page'
+ }];
+
+ browser.notifications.create({
+ 'type': 'basic',
+ 'iconUrl': browser.extension.getURL('icons/keepassxc_64x64.png'),
+ 'title': 'KeePassXC-Browser',
+ 'message': message,
+ 'buttons': buttons
+ });
+
+ browser.notifications.onButtonClicked.addListener((id, index) => {
+ browser.notifications.clear(id);
+ if (index === 1) {
+ browserAction.ignoreSite(url);
+ }
+ });
}
});
};
@@ -269,3 +299,21 @@ browserAction.generateIconName = function(iconType, icon) {
return name;
};
+
+browserAction.ignoreSite = function(url) {
+ browser.windows.getCurrent().then((win) => {
+ // 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.tabs.sendMessage(tab.id, {
+ action: 'ignore-site',
+ args: [url]
+ });
+ });
+ });
+ });
+};
+
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js
index c9561b8..4473548 100755
--- a/keepassxc-browser/keepassxc-browser.js
+++ b/keepassxc-browser/keepassxc-browser.js
@@ -30,48 +30,41 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) {
cipForm.destroy(false, {'password': list.list[0], 'username': list.list[1]});
}
}
- }
- else if (req.action === 'fill_user_pass') {
+ } else if (req.action === 'fill_user_pass') {
_called.manualFillRequested = 'both';
cip.receiveCredentialsIfNecessary().then((response) => {
cip.fillInFromActiveElement(false);
});
- }
- else if (req.action === 'fill_pass_only') {
+ } else if (req.action === 'fill_pass_only') {
_called.manualFillRequested = 'pass';
cip.receiveCredentialsIfNecessary().then((response) => {
cip.fillInFromActiveElement(false, true); // passOnly to true
});
- }
- else if (req.action === 'fill_totp') {
+ } else if (req.action === 'fill_totp') {
cip.receiveCredentialsIfNecessary().then((response) => {
cip.fillInFromActiveElementTOTPOnly(false);
});
- }
- else if (req.action === 'activate_password_generator') {
+ } else if (req.action === 'activate_password_generator') {
cip.initPasswordGenerator(cipFields.getAllFields());
- }
- else if (req.action === 'remember_credentials') {
+ } else if (req.action === 'remember_credentials') {
cip.contextMenuRememberCredentials();
- }
- else if (req.action === 'choose_credential_fields') {
+ } else if (req.action === 'choose_credential_fields') {
cipDefine.init();
- }
- else if (req.action === 'clear_credentials') {
+ } else if (req.action === 'clear_credentials') {
cipEvents.clearCredentials();
callback();
- }
- else if (req.action === 'activated_tab') {
+ } else if (req.action === 'activated_tab') {
cipEvents.triggerActivatedTab();
callback();
- }
- else if (req.action === 'redetect_fields') {
+ } else if (req.action === 'redetect_fields') {
browser.runtime.sendMessage({
action: 'load_settings',
}).then((response) => {
cip.settings = response;
cip.initCredentialFields(true);
});
+ } else if (req.action === 'ignore-site') {
+ cip.ignoreSite(req.args);
}
}
});
@@ -1827,6 +1820,25 @@ cip.rememberCredentials = function(usernameValue, passwordValue) {
return false;
};
+cip.ignoreSite = function(sites) {
+ if (!sites || sites.length === 0) {
+ return;
+ }
+
+ const site = sites[0];
+ if (!cip.settings['ignoredSites']) {
+ cip.settings['ignoredSites'] = {};
+ }
+
+ cip.settings['ignoredSites'][site] = {
+ url: site
+ };
+
+ browser.runtime.sendMessage({
+ action: 'save_settings',
+ args: [cip.settings]
+ });
+};
var cipEvents = {};
diff --git a/keepassxc-browser/options/options.html b/keepassxc-browser/options/options.html
index 4c1a702..597b2af 100644
--- a/keepassxc-browser/options/options.html
+++ b/keepassxc-browser/options/options.html
@@ -20,6 +20,7 @@
General
Connected Databases
Specified credential fields
+ Ignored sites
About
@@ -288,6 +289,52 @@