skip vis checks for notification bar collect()

This commit is contained in:
Kyle Spearrin 2017-10-02 09:22:46 -04:00
parent 9aaf080716
commit 9f51f005b0
5 changed files with 37 additions and 13 deletions

View File

@ -67,7 +67,7 @@ var bg_isBackground = true,
hitType: 'event',
eventAction: 'Autofilled From Command'
});
collectPageDetailsForContentScript(tabs[0], 'autofill_cmd');
collectPageDetailsForContentScript(tabs[0], 'autofill_cmd', false);
}
});
}
@ -101,7 +101,7 @@ var bg_isBackground = true,
messageTab(sender.tab.id, 'adjustNotificationBar', msg.data);
}
else if (msg.command === 'bgCollectPageDetails') {
collectPageDetailsForContentScript(sender.tab, msg.sender);
collectPageDetailsForContentScript(sender.tab, msg.sender, msg.noVisibleChecks);
}
else if (msg.command === 'bgAddLogin') {
addLogin(msg.login, sender.tab);
@ -560,12 +560,17 @@ var bg_isBackground = true,
});
}
function collectPageDetailsForContentScript(tab, sender) {
function collectPageDetailsForContentScript(tab, sender, noVisibleChecks) {
if (!tab || !tab.id) {
return;
}
chrome.tabs.sendMessage(tab.id, { command: 'collectPageDetails', tab: tab, sender: sender }, function () {
chrome.tabs.sendMessage(tab.id, {
command: 'collectPageDetails',
tab: tab,
sender: sender,
noVisibleChecks: noVisibleChecks
}, function () {
if (chrome.runtime.lastError) {
return;
}
@ -737,7 +742,12 @@ var bg_isBackground = true,
return;
}
chrome.tabs.sendMessage(tab.id, { command: 'collectPageDetails', tab: tab, sender: 'contextMenu' }, function () {
chrome.tabs.sendMessage(tab.id, {
command: 'collectPageDetails',
tab: tab,
sender: 'contextMenu',
noVisibleChecks: false
}, function () {
});
});
}

View File

@ -36,7 +36,7 @@
3. Unminify and format to meet Mozilla review requirements.
*/
function collect(document, undefined) {
function collect(document, undefined, noVisibleChecks) {
var isFirefox = navigator.userAgent.indexOf('Firefox') !== -1 || navigator.userAgent.indexOf('Gecko/') !== -1;
document.elementsByOPID = {};
@ -457,6 +457,10 @@
// is a dom element visible on screen?
function isElementVisible(el) {
if (noVisibleChecks) {
return true;
}
var theEl = el;
el = (el = el.ownerDocument) ? el.defaultView : {};
@ -480,6 +484,10 @@
// is a dom element "viewable" on screen?
function isElementViewable(el) {
if (noVisibleChecks) {
return true;
}
var theDoc = el.ownerDocument.documentElement,
rect = el.getBoundingClientRect(),
docScrollWidth = theDoc.scrollWidth,
@ -958,7 +966,7 @@
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
if (msg.command === 'collectPageDetails') {
var pageDetails = collect(document);
var pageDetails = collect(document, msg.noVisibleChecks || false);
var pageDetailsObj = JSON.parse(pageDetails);
chrome.runtime.sendMessage({
command: 'collectPageDetailsResponse',

View File

@ -9,7 +9,8 @@
function fill() {
chrome.runtime.sendMessage({
command: 'bgCollectPageDetails',
sender: 'autofiller'
sender: 'autofiller',
noVisibleChecks: false
});
}
});

View File

@ -42,7 +42,8 @@
if (!obj || !obj.disableAddLoginNotification) {
chrome.runtime.sendMessage({
command: 'bgCollectPageDetails',
sender: 'notificationBar'
sender: 'notificationBar',
noVisibleChecks: true
});
}
});

View File

@ -37,10 +37,14 @@ angular
return;
}
chrome.tabs.sendMessage(tabs[0].id,
{ command: 'collectPageDetails', tab: tabs[0], sender: 'currentController' }, function () {
canAutofill = true;
});
chrome.tabs.sendMessage(tabs[0].id, {
command: 'collectPageDetails',
tab: tabs[0],
sender: 'currentController',
noVisibleChecks: false
}, function () {
canAutofill = true;
});
$q.when(loginService.getAllDecryptedForDomain(domain)).then(function (logins) {
$scope.loaded = true;