From 9e2b64d0c44eaf504986189e59551c11d81e09a2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 13 Oct 2016 23:42:08 -0400 Subject: [PATCH] Adjust autofill to handle sites with no username/password --- src/background.js | 56 +++++++++++--------- src/popup/app/vault/views/vaultViewSite.html | 8 +-- src/popup/less/popup.less | 4 ++ src/services/autofillService.js | 2 +- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/background.js b/src/background.js index d324dab52a..5274dbebbd 100644 --- a/src/background.js +++ b/src/background.js @@ -336,39 +336,45 @@ function buildContextMenuOptions(url) { } function loadSiteContextMenuOptions(site) { - var title = site.name + ' (' + site.username + ')'; - loadContextMenuOptions(title, site.id); + var title = site.name + (site.username && site.username !== '' ? ' (' + site.username + ')' : ''); + loadContextMenuOptions(title, site.id, site); } function loadNoSitesContextMenuOptions() { var title = 'No matching sites.'; - loadContextMenuOptions(title, 'noop'); + loadContextMenuOptions(title, 'noop', null); } -function loadContextMenuOptions(title, idSuffix) { - chrome.contextMenus.create({ - type: 'normal', - id: 'autofill_' + idSuffix, - parentId: 'autofill', - contexts: ['all'], - title: title - }); +function loadContextMenuOptions(title, idSuffix, site) { + if (site.password && site.password !== '') { + chrome.contextMenus.create({ + type: 'normal', + id: 'autofill_' + idSuffix, + parentId: 'autofill', + contexts: ['all'], + title: title + }); + } - chrome.contextMenus.create({ - type: 'normal', - id: 'copy-username_' + idSuffix, - parentId: 'copy-username', - contexts: ['all'], - title: title - }); + if (site.username && site.username !== '') { + chrome.contextMenus.create({ + type: 'normal', + id: 'copy-username_' + idSuffix, + parentId: 'copy-username', + contexts: ['all'], + title: title + }); + } - chrome.contextMenus.create({ - type: 'normal', - id: 'copy-password_' + idSuffix, - parentId: 'copy-password', - contexts: ['all'], - title: title - }); + if (site.password && site.password !== '') { + chrome.contextMenus.create({ + type: 'normal', + id: 'copy-password_' + idSuffix, + parentId: 'copy-password', + contexts: ['all'], + title: title + }); + } } function copyToClipboard(text) { diff --git a/src/popup/app/vault/views/vaultViewSite.html b/src/popup/app/vault/views/vaultViewSite.html index 2c7ecf4a9d..221cedd4f7 100644 --- a/src/popup/app/vault/views/vaultViewSite.html +++ b/src/popup/app/vault/views/vaultViewSite.html @@ -18,7 +18,7 @@ Name {{site.name}} -
+ - -
+
Notes
diff --git a/src/popup/less/popup.less b/src/popup/less/popup.less index 62db90b492..3a9b3a828d 100644 --- a/src/popup/less/popup.less +++ b/src/popup/less/popup.less @@ -6,6 +6,10 @@ @import "plugins.less"; @import "pages.less"; +html { + -webkit-font-smoothing: antialiased; +} + body { width: 320px !important; height: 568px !important; diff --git a/src/services/autofillService.js b/src/services/autofillService.js index fd29c25012..84f590448f 100644 --- a/src/services/autofillService.js +++ b/src/services/autofillService.js @@ -4,7 +4,7 @@ function initAutofill() { AutofillService.prototype.generateFillScript = function (pageDetails, fillUsername, fillPassword) { - if (!pageDetails) { + if (!pageDetails || !fillPassword || fillPassword === '') { return null; }