Hide the option with older KeePassXC versions

This commit is contained in:
varjolintu 2025-03-22 16:31:19 +02:00
parent d488496ae1
commit 2c2283444a
4 changed files with 39 additions and 19 deletions

View file

@ -27,11 +27,12 @@ kpxcEvent.showStatus = async function(tab, configured, internalPoll) {
const errorMessage = page.tabs[tab.id]?.errorMessage ?? undefined;
const usernameFieldDetected = page.tabs[tab.id]?.usernameFieldDetected ?? false;
const iframeDetected = page.tabs[tab.id]?.iframeDetected ?? false;
const compareResult = keepass.compareMultipleVersions([ '2.7.11' ], keepass.currentKeePassXC);
return {
associated: keepass.isAssociated(),
configured: configured,
compareResult: compareResult,
databaseClosed: keepass.isDatabaseClosed,
encryptionKeyUnrecognized: keepass.isEncryptionKeyUnrecognized,
error: errorMessage,

View file

@ -10,7 +10,7 @@ HTMLElement.prototype.hide = function() {
this.style.display = 'none';
};
async function statusResponse(r) {
async function statusResponse(response) {
$('#initial-state').hide();
$('#error-encountered').hide();
$('#need-reconfigure').hide();
@ -22,44 +22,47 @@ async function statusResponse(r) {
$('#database-not-opened').hide();
$('#add-credentials-button').hide();
if (!r.keePassXCAvailable) {
$('#error-message').textContent = r.error;
if (!response?.keePassXCAvailable) {
$('#error-message').textContent = response?.error;
$('#error-encountered').show();
if (r.showGettingStartedGuideAlert) {
if (response?.showGettingStartedGuideAlert) {
$('#getting-started-guide').show();
}
if (r.showTroubleshootingGuideAlert && reloadCount >= 2) {
if (response?.showTroubleshootingGuideAlert && reloadCount >= 2) {
$('#troubleshooting-guide').show();
} else {
$('#troubleshooting-guide').hide();
}
} else if (r.keePassXCAvailable && r.databaseClosed) {
$('#database-error-message').textContent = r.error;
} else if (response?.keePassXCAvailable && response?.databaseClosed) {
$('#database-error-message').textContent = response?.error;
$('#database-not-opened').show();
} else if (!r.configured) {
} else if (!response?.configured) {
$('#not-configured').show();
} else if (r.encryptionKeyUnrecognized) {
} else if (response?.encryptionKeyUnrecognized) {
$('#need-reconfigure').show();
$('#need-reconfigure-message').textContent = r.error;
} else if (!r.associated) {
$('#need-reconfigure-message').textContent = response?.error;
} else if (!response?.associated) {
$('#need-reconfigure').show();
$('#need-reconfigure-message').textContent = r.error;
} else if (r.error) {
$('#need-reconfigure-message').textContent = response?.error;
} else if (response?.error) {
$('#error-encountered').show();
$('#error-message').textContent = r.error;
$('#error-message').textContent = response?.error;
} else {
$('#configured-and-associated').show();
$('#associated-identifier').textContent = r.identifier;
$('#associated-identifier').textContent = response?.identifier;
$('#lock-database-button').show();
$('#add-credentials-button').show();
if (r.usernameFieldDetected) {
if (response?.compareResult['2.7.11']) {
$('#add-credentials-button').show();
}
if (response?.usernameFieldDetected) {
$('#username-field-detected').show();
}
if (r.iframeDetected) {
if (response?.iframeDetected) {
$('#iframe-detected').show();
}

View file

@ -35,6 +35,7 @@ async function initSettings() {
$('#add-credentials-url').value = tab?.url;
if ($('#add-credentials')?.style?.display === 'none') {
$('#add-credentials').show();
$('input#add-credentials-username')?.focus();
} else {
$('#add-credentials').hide();
}

View file

@ -1,5 +1,18 @@
'use strict';
async function hideAddCredentialsButton() {
const keePassVersions = await browser.runtime.sendMessage({
action: 'get_keepassxc_versions'
});
const versionResults = await browser.runtime.sendMessage({
action: 'compare_versions',
args: [ [ '2.7.11' ], keePassVersions.current ],
});
if (!versionResults['2.7.11']) {
$('#add-credentials-button').hide();
}
}
(async () => {
await initColorTheme();
@ -10,6 +23,8 @@
return [];
}
await hideAddCredentialsButton();
const logins = await getLoginData();
const ll = document.getElementById('login-list');