From 2fcf3ff1297f0a04bc19f221b585cd5e7e9ad432 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 16 Sep 2016 22:48:41 -0400 Subject: [PATCH] adjust context menus to "all" context. cleanup autofill in current --- src/background.js | 10 +++++++++- src/popup/app/current/currentController.js | 23 +++++++++++----------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/background.js b/src/background.js index af89d732aa..c0a6c3b008 100644 --- a/src/background.js +++ b/src/background.js @@ -11,28 +11,33 @@ function buildContextMenu() { chrome.contextMenus.create({ type: 'normal', id: 'autofill', + contexts: ['all'], title: 'Auto-fill' }); chrome.contextMenus.create({ type: 'normal', id: 'copy-username', + contexts: ['all'], title: 'Copy Username' }); chrome.contextMenus.create({ type: 'normal', id: 'copy-password', + contexts: ['all'], title: 'Copy Password' }); chrome.contextMenus.create({ - type: 'separator' + type: 'separator', + contexts: ['all'] }); chrome.contextMenus.create({ type: 'normal', id: 'generate-password', + contexts: ['all'], title: 'Generate Password' }); } @@ -156,6 +161,7 @@ function loadContextMenuOptions(site) { type: 'normal', id: 'autofill_' + site.id, parentId: 'autofill', + contexts: ['all'], title: title }); @@ -163,6 +169,7 @@ function loadContextMenuOptions(site) { type: 'normal', id: 'copy-username_' + site.id, parentId: 'copy-username', + contexts: ['all'], title: title }); @@ -170,6 +177,7 @@ function loadContextMenuOptions(site) { type: 'normal', id: 'copy-password_' + site.id, parentId: 'copy-password', + contexts: ['all'], title: title }); } diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index c220831650..701709c56d 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -5,9 +5,8 @@ angular var pageDetails = null, tabId = null, url = null, - domain = null; - - $scope.canAutofill = false; + domain = null, + canAutofill = false; chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { if (tabs.length > 0) { @@ -26,7 +25,7 @@ angular chrome.tabs.sendMessage(tabId, { command: 'collectPageDetails' }, function (details) { pageDetails = details; - $scope.canAutofill = true; + canAutofill = true; }); var filteredSites = []; @@ -61,7 +60,7 @@ angular $scope.fillSite = function (site) { var fillScript = null; - if (site && $scope.canAutofill && pageDetails) { + if (site && canAutofill && pageDetails) { fillScript = makeFillScript(site.username, site.password); } @@ -94,7 +93,7 @@ angular var passwordFields = []; for (var i = 0; i < pageDetails.fields.length; i++) { - if (pageDetails.fields[i].type == 'password') { + if (pageDetails.fields[i].type === 'password') { passwordFields.push(pageDetails.fields[i]); } } @@ -102,7 +101,7 @@ angular var passwordForms = []; for (var formKey in pageDetails.forms) { for (var j = 0; j < passwordFields.length; j++) { - if (formKey == passwordFields[j].form) { + if (formKey === passwordFields[j].form) { passwordForms.push(pageDetails.forms[formKey]); break; } @@ -139,8 +138,8 @@ angular for (i = 0; i < passwordForms.length; i++) { var passwordFieldCount = 0; - for (var j = 0; j < passwordFields.length; j++) { - if (passwordForms[i].opid == passwordFields[j].form) { + for (j = 0; j < passwordFields.length; j++) { + if (passwordForms[i].opid === passwordFields[j].form) { passwordFieldCount++; } } @@ -160,7 +159,7 @@ angular var password = null; for (i = 0; i < pageDetails.fields.length; i++) { var f = pageDetails.fields[i]; - if (f.form == loginForm.opid && f.type == 'password') { + if (f.form === loginForm.opid && f.type === 'password') { password = f; break; } @@ -168,8 +167,8 @@ angular var username = null; for (i = 0; i < pageDetails.fields.length; i++) { - var f = pageDetails.fields[i]; - if (f.form == loginForm.opid && (f.type == 'text' || f.type == 'email') + f = pageDetails.fields[i]; + if (f.form === loginForm.opid && (f.type === 'text' || f.type === 'email') && f.elementNumber < password.elementNumber) { username = f; }