From 65a13e3dcbc08abdcadbaca0e7e8477389f9af76 Mon Sep 17 00:00:00 2001 From: FURiOUS Date: Mon, 24 Feb 2020 10:54:11 -0300 Subject: [PATCH] Centralizes the window popup for multiple credentials HTTP authentication, also better UI if have a lot of credentials --- keepassxc-browser/background/event.js | 17 +++++++++++++---- keepassxc-browser/popups/popup.css | 5 +++++ keepassxc-browser/popups/popup_httpauth.html | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js index 8839275..f2c4a31 100755 --- a/keepassxc-browser/background/event.js +++ b/keepassxc-browser/background/event.js @@ -179,10 +179,15 @@ kpxcEvent.onHTTPAuthPopup = async function(tab, data) { page.tabs[tab.id].loginList = data; browserAction.show(tab); + const tabinfo = await browser.tabs.get(tab.id); + const windowinfo = await browser.windows.get(tabinfo.windowId); + + const width = 480; + const height = 250; const dialogData = { - width: 480, height: 250, - left: (window.screen.width/2) - (480/2), - top: (window.screen.height/2) - (250/2) + width: width, height: height, + left: Math.round(windowinfo.left + ((windowinfo.width/2) - (width/2))), + top: Math.round(windowinfo.top + ((windowinfo.height/2) - (height/2))) }; const httpAuthDialog = page.tabs[tab.id].httpAuthDialog; @@ -192,11 +197,15 @@ kpxcEvent.onHTTPAuthPopup = async function(tab, data) { return Promise.resolve(); } - dialogData.type = "popup"; + dialogData.type = 'popup'; dialogData.url = `/popups/popup_httpauth.html?tab=${tab.id}`; + dialogData.titlePreface = `${data.details.realm} (${data.details.challenger.host}) - `; const wnd = await browser.windows.create(dialogData); page.tabs[tab.id].httpAuthDialog = wnd.id; + if (isFirefox()) { // workaround for firefox bug that ignores top/left for new windows + browser.windows.update(wnd.id, { left: dialogData.left, top: dialogData.top }); + } return Promise.resolve(); }; diff --git a/keepassxc-browser/popups/popup.css b/keepassxc-browser/popups/popup.css index d36b48d..61fd069 100644 --- a/keepassxc-browser/popups/popup.css +++ b/keepassxc-browser/popups/popup.css @@ -109,6 +109,11 @@ body { width: 100%; } +#login-list { + height: 100px; + overflow: hidden auto; +} + @media (prefers-color-scheme: dark), (prefers-color-scheme: light) { body { background: var(--background-color) !important; diff --git a/keepassxc-browser/popups/popup_httpauth.html b/keepassxc-browser/popups/popup_httpauth.html index 8c2c0bd..0770953 100644 --- a/keepassxc-browser/popups/popup_httpauth.html +++ b/keepassxc-browser/popups/popup_httpauth.html @@ -20,7 +20,7 @@

- +