mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Support for OTP codes via context menu
This commit is contained in:
parent
030257203c
commit
1f9b76178b
2 changed files with 25 additions and 0 deletions
|
|
@ -79,6 +79,7 @@ browser.runtime.onMessage.addListener(kpxcEvent.onMessage);
|
|||
const contextMenuItems = [
|
||||
{title: 'Fill User + Pass', action: 'fill_user_pass'},
|
||||
{title: 'Fill Pass Only', action: 'fill_pass_only'},
|
||||
{title: 'Fill TOTP', action: 'fill_totp'},
|
||||
{title: 'Show Password Generator Icons', action: 'activate_password_generator'},
|
||||
{title: 'Save credentials', action: 'remember_credentials'}
|
||||
];
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ browser.runtime.onMessage.addListener(function(req, sender, callback) {
|
|||
cip.receiveCredentialsIfNecessary();
|
||||
cip.fillInFromActiveElementPassOnly(false);
|
||||
}
|
||||
else if (req.action === 'fill_totp') {
|
||||
cip.receiveCredentialsIfNecessary();
|
||||
cip.fillInFromActiveElementTOTPOnly(false);
|
||||
}
|
||||
else if (req.action === 'activate_password_generator') {
|
||||
cip.initPasswordGenerator(cipFields.getAllFields());
|
||||
}
|
||||
|
|
@ -1445,6 +1449,26 @@ cip.fillInFromActiveElementPassOnly = function(suppressWarnings) {
|
|||
cip.fillInCredentials(combination, true, suppressWarnings);
|
||||
};
|
||||
|
||||
cip.fillInFromActiveElementTOTPOnly = function(suppressWarnings) {
|
||||
const el = document.activeElement;
|
||||
cipFields.setUniqueId(jQuery(el));
|
||||
const fieldId = cipFields.prepareId(jQuery(el).attr('data-cip-id'));
|
||||
|
||||
|
||||
if (cip.credentials[0]) {
|
||||
const $sf = _fs(fieldId);
|
||||
if (cip.credentials[0].stringFields && cip.credentials[0].stringFields.length > 0) {
|
||||
const sFields = cip.credentials[0].stringFields;
|
||||
for (const s of sFields) {
|
||||
const val = s["KPH: {TOTP}"];
|
||||
if (val) {
|
||||
cip.setValue($sf, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cip.setValue = function(field, value) {
|
||||
if (field.is('select')) {
|
||||
value = value.toLowerCase().trim();
|
||||
|
|
|
|||
Loading…
Reference in a new issue