From 84868b1f68433058c2ec4592ac31b9ff042604a1 Mon Sep 17 00:00:00 2001 From: Ziga Date: Tue, 1 Jun 2021 10:15:37 +0200 Subject: [PATCH] Add Password dialog will now autofill website hostname --- js/passwords.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/passwords.js b/js/passwords.js index 86574ec..b801080 100644 --- a/js/passwords.js +++ b/js/passwords.js @@ -301,6 +301,14 @@ function changeDialog(style, text){ document.getElementById("website").value = data[1]; document.getElementById("username").value = data[2]; document.getElementById("password").value = data[3]; + }else{ + try{ + chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => { + if(tabs[0].url !== null && typeof(tabs[0].url) !== 'undefined'){ + document.getElementById("website").value = new URL(tabs[0].url).hostname.replace("www.", ""); + } + }); + }catch{} } document.getElementById('btn-password-generator').onclick = () => changeDialog(5, "-1" + " " + document.getElementById("website").value + " " + document.getElementById("username").value + " " + document.getElementById("password").value);