diff --git a/keepassxc-browser/background/httpauth.js b/keepassxc-browser/background/httpauth.js index cdd23ed..3209507 100755 --- a/keepassxc-browser/background/httpauth.js +++ b/keepassxc-browser/background/httpauth.js @@ -85,7 +85,7 @@ httpAuth.loginOrShowCredentials = function(logins, details, resolve, reject) { }); } else { if (page.settings.showNotifications) { - showNotification('Multiple credentials detected. Click on the extension icon to choose the correct one.'); + showNotification('HTTP authentication with multiple credentials detected. Click on the extension icon to choose the correct one.'); } kpxcEvent.onHTTPAuthPopup(null, { 'id': details.tabId }, { 'logins': logins, 'url': details.searchUrl, 'resolve': resolve }); } diff --git a/keepassxc-browser/popups/popup.css b/keepassxc-browser/popups/popup.css index baf8215..235a88b 100644 --- a/keepassxc-browser/popups/popup.css +++ b/keepassxc-browser/popups/popup.css @@ -7,33 +7,15 @@ body { font-size: 15px; padding: 8px; } -.credentials ul { - margin-left: 0; - margin-right: 0; - padding-left: 0; - padding-right: 0; - list-style-position: inside; +.list-group { + font-size: .9em !important; } -.credentials li { - list-style: none; - padding-top: 1px; - padding-bottom: 1px; - padding-left: 5px; - padding-right: 5px; - margin-left: 10px; - margin-right: 5px; +.list-group-item { + padding: 5px 10px !important; } -.credentials a { - color: #333; -} -.credentials a:hover { - text-decoration: none; -} -.credentials li:hover { +.list-group-item:hover { cursor: pointer; - background: #ddd; } - .settings { padding-bottom: 10px; margin-bottom: 10px; diff --git a/keepassxc-browser/popups/popup_httpauth.html b/keepassxc-browser/popups/popup_httpauth.html index 2f43070..8edb0ce 100644 --- a/keepassxc-browser/popups/popup_httpauth.html +++ b/keepassxc-browser/popups/popup_httpauth.html @@ -29,7 +29,10 @@

Select the login information you would like to get logged in with:

- +
+

+ +

diff --git a/keepassxc-browser/popups/popup_httpauth.js b/keepassxc-browser/popups/popup_httpauth.js index cd68d91..8ff0e13 100644 --- a/keepassxc-browser/popups/popup_httpauth.js +++ b/keepassxc-browser/popups/popup_httpauth.js @@ -1,37 +1,57 @@ 'use strict'; -$(function() { - browser.runtime.getBackgroundPage().then((global) => { - browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => { - let tab = tabs[0]; - const data = global.page.tabs[tab.id].loginList; - let ul = document.getElementById('login-list'); - for (let i = 0; i < data.logins.length; i++) { - const li = document.createElement('li'); - const a = document.createElement('a'); - a.textContent = data.logins[i].login + " (" + data.logins[i].name + ")"; - li.appendChild(a); - $(a).data('creds', data.logins[i]); - $(a).click(function () { - if (data.resolve) { - const creds = $(this).data('creds'); - data.resolve({ - authCredentials: { - username: creds.login, - password: creds.password - } - }); - } - close(); - }); - ul.appendChild(li); - } +const getLoginData = function() { + return new Promise((resolve, reject) => { + browser.runtime.getBackgroundPage().then((global) => { + browser.tabs.query({'active': true, 'currentWindow': true}).then((tabs) => { + resolve(global.page.tabs[tabs[0].id].loginList); + }); }); }); +}; + +$(function() { + getLoginData().then((data) => { + let ll = document.getElementById('login-list'); + for (let i = 0; i < data.logins.length; ++i) { + const a = document.createElement('a'); + a.setAttribute('class', 'list-group-item'); + a.textContent = data.logins[i].login + " (" + data.logins[i].name + ")"; + $(a).data('creds', data.logins[i]); + $(a).click(function () { + if (data.resolve) { + const creds = $(this).data('creds'); + data.resolve({ + authCredentials: { + username: creds.login, + password: creds.password + } + }); + } + close(); + }); + ll.appendChild(a); + } + }); $('#lock-database-button').click(function() { browser.runtime.sendMessage({ action: 'lock-database' }).then(status_response); }); + + $('#btn-dismiss').click(function() { + getLoginData().then((data) => { + // Using reject won't work with every browser. So return empty credentials instead. + if (data.resolve) { + data.resolve({ + authCredentials: { + username: '', + password: '' + } + }); + } + close(); + }); + }); }); diff --git a/keepassxc-browser/popups/popup_login.html b/keepassxc-browser/popups/popup_login.html index 14d4584..09391e0 100644 --- a/keepassxc-browser/popups/popup_login.html +++ b/keepassxc-browser/popups/popup_login.html @@ -29,7 +29,7 @@

Select the login information you would like to get entered into the page:

- +
diff --git a/keepassxc-browser/popups/popup_login.js b/keepassxc-browser/popups/popup_login.js index b0c2f74..9ed3d02 100644 --- a/keepassxc-browser/popups/popup_login.js +++ b/keepassxc-browser/popups/popup_login.js @@ -9,13 +9,11 @@ $(function() { const tab = tabs[0]; const logins = global.page.tabs[tab.id].loginList; - let ul = document.getElementById('login-list'); + let ll = document.getElementById('login-list'); for (let i = 0; i < logins.length; i++) { - const li = document.createElement('li'); const a = document.createElement('a'); a.textContent = logins[i]; - li.setAttribute('class', 'list-group-item'); - li.appendChild(a); + a.setAttribute('class', 'list-group-item'); a.setAttribute('id', '' + i); a.addEventListener('click', (e) => { const id = e.target.id; @@ -25,7 +23,7 @@ $(function() { }); close(); }); - ul.appendChild(li); + ll.appendChild(a); } }); });