diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js index 264a70a..275a360 100644 --- a/keepassxc-browser/background/event.js +++ b/keepassxc-browser/background/event.js @@ -128,17 +128,24 @@ kpxcEvent.onSaveSettings = function(callback, tab, settings) { }); }; -kpxcEvent.onGetStatus = function(callback, tab) { - keepass.testAssociation((response) => { - if (!response) { - kpxcEvent.showStatus(false, tab, callback); - return; - } +kpxcEvent.onGetStatus = function(callback, tab, internalPoll = false) { + // When internalPoll is true the event is triggered from content script in intervals -> don't poll KeePassXC + if (!internalPoll) { + keepass.testAssociation((response) => { + if (!response) { + kpxcEvent.showStatus(false, tab, callback); + return; + } + keepass.isConfigured().then((configured) => { + kpxcEvent.showStatus(configured, tab, callback); + }); + }, tab, true); + } else { keepass.isConfigured().then((configured) => { kpxcEvent.showStatus(configured, tab, callback); }); - }, tab, true); + } }; kpxcEvent.onReconnect = function(callback, tab) { diff --git a/keepassxc-browser/background/keepass.js b/keepassxc-browser/background/keepass.js index a7252a8..6f2244d 100644 --- a/keepassxc-browser/background/keepass.js +++ b/keepassxc-browser/background/keepass.js @@ -631,7 +631,7 @@ keepass.generateNewKeyPair = function() { keepass.isConfigured = function() { return new Promise((resolve, reject) => { - if (typeof(keepass.databaseHash) === 'undefined' || keepass.databaseHash === 'no-hash') { + if (typeof(keepass.databaseHash) === 'undefined') { keepass.getDatabaseHash((hash) => { resolve(hash in keepass.keyRing); }); diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index 41962ac..1b4b5ca 100644 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -396,7 +396,6 @@ cipPassword.callbackPasswordCopied = function(bool) { cipPassword.callbackGeneratedPassword = function(entries) { if (entries && entries.length >= 1) { - console.log(entries[0]); jQuery('#cip-genpw-btn-clipboard:first').removeClass('btn-success'); jQuery('input#cip-genpw-textfield-password:first').val(entries[0].password); if (isNaN(entries[0].login)) { @@ -408,7 +407,7 @@ cipPassword.callbackGeneratedPassword = function(entries) { } else { if (jQuery('div#cip-genpw-error:first').length === 0) { - jQuery('button#cip-genpw-btn-generate:first').after('
Cannot receive generated password.
Is your version of KeePassXC up-to-date?

Please visit the KeePassXC homepage
'); + jQuery('button#cip-genpw-btn-generate:first').after('
Cannot receive generated password.
Is KeePassXC opened?
'); jQuery('input#cip-genpw-textfield-password:first').parent().hide(); jQuery('input#cip-genpw-checkbox-next-field:first').parent('label').hide(); jQuery('button#cip-genpw-btn-generate').hide(); @@ -1117,21 +1116,15 @@ cip.init = function() { }; cip.detectNewActiveFields = function() { - const hiddenFields = cipFields.getHiddenFieldCount(); - - // If hidden fields aren't detected, setInterval is being looped in each frame of the page - //if (hiddenFields > 0) { - const divDetect = setInterval(function() { - const fields = cipFields.getAllFields(); - if (fields.length > 1) { - cip.initCredentialFields(true); - clearInterval(divDetect); - } - }, 1000); - //} + const divDetect = setInterval(function() { + const fields = cipFields.getAllFields(); + if (fields.length > 1) { + cip.initCredentialFields(true); + clearInterval(divDetect); + } + }, 1000); }; -// Try to do this in a way that database value if checked without polling the KeePassXC.. too many messages jumping around // Switch credentials if database is changed or closed cip.detectDatabaseChange = function() { let dbDetectInterval = setInterval(function() { @@ -1148,7 +1141,8 @@ cip.detectDatabaseChange = function() { // Switch back to default popup browser.runtime.sendMessage({ - action: 'get_status' + 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) {