mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Add option for auto-submit
This commit is contained in:
parent
3fef9eb9dc
commit
9ac45e132b
6 changed files with 58 additions and 9 deletions
|
|
@ -535,6 +535,14 @@
|
|||
"message": "Activate autocomplete for username fields.",
|
||||
"description": "Activate autocomplete for username fields checkbox text."
|
||||
},
|
||||
"optionsCheckboxAutoSubmit": {
|
||||
"message": "Auto-submit login forms",
|
||||
"description": "Auto-submit checkbox text."
|
||||
},
|
||||
"optionsAutoSubmitHelpText": {
|
||||
"message": "Automatically submits selected credentials. This is disabled for single entry auto-fill.",
|
||||
"description": "Auto-submit help text."
|
||||
},
|
||||
"optionsCheckboxShowNotifications": {
|
||||
"message": "Show notifications.",
|
||||
"description": "Show notifications checkbox text."
|
||||
|
|
@ -878,5 +886,9 @@
|
|||
"httpAuthDialog": {
|
||||
"message": "HTTP Basic Authentication dialog",
|
||||
"description": "Options page HTTP Basic Auth dialog text"
|
||||
},
|
||||
"autocompleteSubmitMessage": {
|
||||
"message": "Your selection will be auto-submitted",
|
||||
"description": "Message shown at the bottom of autocomplete menu."
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ const defaultSettings = {
|
|||
autoFillAndSend: false,
|
||||
usePasswordGenerator: true,
|
||||
autoFillSingleEntry: false,
|
||||
autoSubmit: false,
|
||||
autoRetrieveCredentials: true,
|
||||
showNotifications: true,
|
||||
showLoginNotifications: true,
|
||||
|
|
@ -40,6 +41,9 @@ page.initSettings = function() {
|
|||
if (!('autoFillSingleEntry' in page.settings)) {
|
||||
page.settings.autoFillSingleEntry = defaultSettings.autoFillSingleEntry;
|
||||
}
|
||||
if (!('autoSubmit' in page.settings)) {
|
||||
page.settings.autoSubmit = defaultSettings.autoSubmit;
|
||||
}
|
||||
if (!('autoRetrieveCredentials' in page.settings)) {
|
||||
page.settings.autoRetrieveCredentials = defaultSettings.autoRetrieveCredentials;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
var kpxcAutocomplete = {};
|
||||
kpxcAutocomplete.elements = [];
|
||||
|
||||
kpxcAutocomplete.create = function(input, showListInstantly = false) {
|
||||
kpxcAutocomplete.create = function(input, showListInstantly = false, autoSubmit = false) {
|
||||
let _index = -1;
|
||||
|
||||
input.addEventListener('click', function(e) {
|
||||
|
|
@ -67,6 +67,12 @@ kpxcAutocomplete.create = function(input, showListInstantly = false) {
|
|||
div.appendChild(item);
|
||||
}
|
||||
|
||||
// Add a footer message for auto-submit
|
||||
if (autoSubmit) {
|
||||
const footer = kpxcUI.createElement('footer', '', {}, tr('autocompleteSubmitMessage'));
|
||||
div.appendChild(footer);
|
||||
}
|
||||
|
||||
// Activate the first item automatically
|
||||
const items = getAllItems();
|
||||
_index = 0;
|
||||
|
|
|
|||
|
|
@ -942,9 +942,6 @@ kpxc.prepareFieldsForCredentials = function(autoFillInForSingle) {
|
|||
action: 'popup_login',
|
||||
args: [ [ kpxc.credentials[0].login + ' (' + kpxc.credentials[0].name + ')' ] ]
|
||||
});
|
||||
|
||||
// Auto-submit
|
||||
kpxc.p.form.submit();
|
||||
} else if (kpxc.credentials.length > 1 || (kpxc.credentials.length > 0 && (!kpxc.settings.autoFillSingleEntry || !autoFillInForSingle))) {
|
||||
kpxc.preparePageForMultipleCredentials(kpxc.credentials);
|
||||
}
|
||||
|
|
@ -978,14 +975,14 @@ kpxc.preparePageForMultipleCredentials = function(credentials) {
|
|||
// Both username and password fields are visible
|
||||
if (_detectedFields >= 2) {
|
||||
if (_f(i.username)) {
|
||||
kpxcAutocomplete.create(_f(i.username));
|
||||
kpxcAutocomplete.create(_f(i.username), false, kpxc.settings.autoSubmit);
|
||||
}
|
||||
} else if (_detectedFields === 1) {
|
||||
if (_f(i.username)) {
|
||||
kpxcAutocomplete.create(_f(i.username));
|
||||
kpxcAutocomplete.create(_f(i.username), false, kpxc.settings.autoSubmit);
|
||||
}
|
||||
if (_f(i.password)) {
|
||||
kpxcAutocomplete.create(_f(i.password));
|
||||
kpxcAutocomplete.create(_f(i.password), false, kpxc.settings.autoSubmit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1225,6 +1222,7 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) {
|
|||
args: [ message ]
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if (combination.loginId !== undefined && kpxc.credentials[combination.loginId]) {
|
||||
// Specific login ID given
|
||||
|
|
@ -1260,6 +1258,7 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) {
|
|||
args: [ message ]
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else { // Multiple credentials available
|
||||
// Check if only one password for given username exists
|
||||
|
|
@ -1307,7 +1306,7 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) {
|
|||
if (countPasswords > 1) {
|
||||
if (!suppressWarnings) {
|
||||
const target = onlyPassword ? pField : uField;
|
||||
kpxcAutocomplete.create(target, true);
|
||||
kpxcAutocomplete.create(target, true, kpxc.settings.autoSubmit);
|
||||
target.focus();
|
||||
}
|
||||
} else if (countPasswords < 1) {
|
||||
|
|
@ -1322,11 +1321,20 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) {
|
|||
} else {
|
||||
if (!suppressWarnings) {
|
||||
const target = onlyPassword ? pField : uField;
|
||||
kpxcAutocomplete.create(target, true);
|
||||
kpxcAutocomplete.create(target, true, kpxc.settings.autoSubmit);
|
||||
target.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-submit
|
||||
if (kpxc.settings.autoSubmit) {
|
||||
if (kpxc.u.form) {
|
||||
kpxc.u.form.submit();
|
||||
} else if (kpxc.p.form) {
|
||||
kpxc.u.form.submit();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
kpxc.contextMenuRememberCredentials = function() {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,16 @@
|
|||
font-size: .9em !important;
|
||||
}
|
||||
|
||||
.kpxcAutocomplete-items footer {
|
||||
padding: 5px;
|
||||
background-color: #ddd;
|
||||
border: 1px solid #d4d4d4 !important;
|
||||
width: auto;
|
||||
color: #000;
|
||||
font-size: .8em !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.kpxcAutocomplete-active {
|
||||
background-color: #6cac4d !important;
|
||||
color: #ffffff !important;
|
||||
|
|
|
|||
|
|
@ -162,6 +162,15 @@
|
|||
</div>
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" name="autoSubmit" value="false" /><span data-i18n="optionsCheckboxAutoSubmit"></span>
|
||||
</label>
|
||||
<span class="help-block" data-i18n="optionsAutoSubmitHelpText"></span>
|
||||
</div>
|
||||
</p>
|
||||
<hr />
|
||||
<p>
|
||||
<div class="checkbox">
|
||||
<label class="checkbox">
|
||||
|
|
|
|||
Loading…
Reference in a new issue