diff --git a/keepassxc-browser/background/browserAction.js b/keepassxc-browser/background/browserAction.js index 4a5e7e0..c728f6d 100755 --- a/keepassxc-browser/background/browserAction.js +++ b/keepassxc-browser/background/browserAction.js @@ -204,6 +204,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)); @@ -242,7 +250,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); + } + }); } }); }; @@ -271,3 +301,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 dab0c74..c399a8c 100755 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -32,48 +32,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); } else if (req.action === 'check_database_hash' && 'hash' in req) { cip.detectDatabaseChange(req.hash); @@ -1821,6 +1814,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 @@
+ Sites in this list are ignored when new credentials are detected.
+
+ Go to the page with new credentials, click the blinking KeePassXC-Browser icon or the notification and select Never ask for this page.
+
| Page URL | +Delete | +
|---|---|
| No ignored sites found. | +|
| + | + |