From 4a6c09c55b8d7489ed4a1726761fe2c314f7afa7 Mon Sep 17 00:00:00 2001 From: skocheri Date: Mon, 2 Nov 2020 09:20:14 -0800 Subject: [PATCH] Fixing review comments --- modules/idLibrary.js | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/modules/idLibrary.js b/modules/idLibrary.js index 10c4dcd8b7d..dc1844a137f 100644 --- a/modules/idLibrary.js +++ b/modules/idLibrary.js @@ -36,14 +36,10 @@ function getEmail(value) { if (!matched) { return null; } + logInfo('Email found' + matched[0]); return matched[0]; } -function hasEmail(value) { - const email = getEmail(value); - return !!email; -} - function bodyAction(conf, mutations, observer) { logInfo('BODY observer on debounce called'); @@ -53,10 +49,8 @@ function bodyAction(conf, mutations, observer) { } const body = document.body.innerHTML; - - if (hasEmail(body)) { - email = getEmail(body); - + email = getEmail(body); + if (email != null) { logInfo(`Email obtained from the body ${email}`); observer.disconnect(); logInfo('Post data on email found in body'); @@ -104,9 +98,8 @@ function removeInputElementsElementListner(conf) { function processInputChange(event, conf) { const value = event.target.value; logInfo(`Modified Value of input ${event.target.value}`); - if (hasEmail(value)) { - email = getEmail(value); - + email = getEmail(value); + if (email != null) { logInfo('Email found in input ' + email); postData(conf.url); removeInputElementsElementListner(conf); @@ -161,9 +154,8 @@ function handleBodyElements(conf) { postData(conf.url); return; } - if (hasEmail(document.body.innerHTML)) { - email = getEmail(document.body.innerHTML); - + email = getEmail(document.body.innerHTML); + if (email != null) { logInfo('Email found in body ' + email); logInfo(' Post data on email found in the body without observer'); postData(conf.url); @@ -182,9 +174,8 @@ function doesInputElementsHaveEmail() { for (let index = 0; index < inputs.length; ++index) { const curInput = inputs[index]; - - if (hasEmail(curInput.value)) { - email = getEmail(curInput.value); + email = getEmail(curInput.value); + if (email != null) { return true; } }