

// This is a content script that runs on all webpages visited by the user.
chrome.storage.sync.get("whitepage",function(item){
	if(typeof(item["whitepage"]) !== 'undefined' && item["whitepage"] instanceof Array && item.whitepage.indexOf('"'+window.location.href+'"') != -1)
	{console.log("Page has been whitelisted.")}
	else{
		passwordGrab();
		dataLoad();
	};
	//window.location.href.localeCompare(item.whitepage[0].replace(/['"]+/g, '')));
});

function passwordGrab(){
	// Locate input fields with type "password". Stores list of fields as a static NodeList object
	var password = document.querySelectorAll('input[type=password]');
	// Adds a listener on the each occurrence of a password field that triggers when field loses focus. This is intended to trigger when user clicks on the submit button for a login form.
	for (var x=0; x < password.length; x++){
			//password[x].addEventListener("focusout", alertContent);
			var parentForm = password[x].form;
			parentForm.addEventListener("submit", function(){alertContent(parentForm)});
			
	}

	function alertContent(form){
		var detectedPass = form.querySelector('input[type=password]').value;
		chrome.runtime.sendMessage({passvalue: detectedPass.toLowerCase()}, function(response){
			console.log(response.complete);
		});
		}
	}

function dataLoad(){
	chrome.storage.sync.get("userdata", function(item){
		if (item.userdata){
		chrome.runtime.sendMessage({greeting: "secure"}, function(response){
			console.log(response.complete);
		});
	}
	else{
		chrome.runtime.sendMessage({greeting: "insecure"}, function(response){
			console.log(response.complete);
		});
	}
	
	});
}

@@ -1,8 +1,6 @@
-%0A%0A/
 /
+*
  Thi
@@ -67,16 +67,219 @@
 he user.
+ It searches for password input fields and captures the input of the field%0A   when the user submits the form. */%0A   %0A// If the user has whitelisted the current webpage, don't run the detection script.   
 %0Achrome.
@@ -545,107 +545,24 @@
 );%0A%09
-%09dataLoad();%0A%09%7D;%0A%09//window.location.href.localeCompare(item.whitepage%5B0%5D.replace(/%5B'%22%5D+/g, '')));%0A%7D
+%7D;%0A%7D);%0AdataLoad(
 );%0A%0A
@@ -835,339 +835,324 @@
 hen 
-field loses focus. This is intended to trigger when user clicks on the submit button for a login form.%0A%09for (var x=0; x %3C password.length; x++)%7B%0A%09%09%09//password%5Bx%5D.addEventListener(%22focusout%22, alertContent);%0A%09%09%09var parentForm = password%5Bx%5D.form;%0A%09%09%09parentForm.addEventListener(%22submit%22, function()%7BalertContent(parentForm)%7D);%0A%09%09%09%0A%09%7D%0A
+the parent form is submitted.%0A%09for (var x=0; x %3C password.length; x++)%7B%0A%09%09%09var parentForm = password%5Bx%5D.form;%0A%09%09%09parentForm.addEventListener(%22submit%22, function()%7BalertContent(parentForm)%7D);%0A%09%7D%0A%0A%09// Function that sends the detected password value to the background script for comparison and alert creation if matched.
 %0A%09fu
@@ -1384,19 +1384,147 @@
 %7D);%0A%09%09%7D%0A
-%09
 %7D%0A
+// Function that checks if user has previously stored personal information from a Facebook login. This allows a persistent login.
 %0Afunctio

Clean up of passwordDetect.js