diff --git a/extension/foreground.js b/extension/foreground.js index ebc827d..3ca0d77 100644 --- a/extension/foreground.js +++ b/extension/foreground.js @@ -3,6 +3,7 @@ let currentForm = null; let successfulAttachment = false; let focusedField = null; + let loginForms = []; function generateQuerySelector(el) { if (el.tagName.toLowerCase() === 'html') { @@ -184,10 +185,9 @@ }); } - function init() { - const forms = lookForLoginForms(); - if (forms.length) { - forms.forEach((form) => attachLoginFormHighlight(form)); + function createFormHighlights() { + if (loginForms.length) { + loginForms.forEach((form) => attachLoginFormHighlight(form)); } } @@ -209,7 +209,7 @@ ) { if (request.message === 'has_entries') { currentPageMatches = request.payload; - init(); + createFormHighlights(); sendResponse(true); } @@ -244,7 +244,9 @@ } if (e.target && e.target.tagName === 'INPUT') { - init(); + createFormHighlights(); } }); + + loginForms = lookForLoginForms(); })(); diff --git a/host/server.js b/host/server.js index 0313e16..b92160c 100755 --- a/host/server.js +++ b/host/server.js @@ -36,7 +36,8 @@ async function findSiteInPasswords(siteDomain) { .filter((item) => { const name = item.toLowerCase(); return name.includes(siteDomain) || (sdwTLD && name.includes(sdwTLD)); - }); + }) + .slice(0, 4); } async function getPassword(password) {