javascript - Extract input element value from current tab -


in chrome extension, i'm trying extract values of input tags, because page hasn't been submitted yet, null each value. know normal behavior, there way extract them without submitting page?

my code below extracts input tags null values:

so here's content.js:

var elements = new array("input"); var output = ""; (var = 0; < elements.length; i++) {     var current = document.getelementsbytagname(elements[i]);     if(current.length>0)     {         (var y = 0; y<current.length; y++)         {             output += "&" + current[y].id + "=" + current[y].value;         }     } } chrome.runtime.sendmessage({data: output}); 

and here's background.js:

var output2 = ""; chrome.extension.onmessage.addlistener(function(request, sender, sendresponse) {     output2 += request.data; }); chrome.browseraction.onclicked.addlistener(function() {     chrome.tabs.create({url: "http://www.google.com?" + output2}, function(tab) {         chrome.tabs.executescript(tab.id, {file: "content.js"}, function() {             sendmessage();         });     }); }); 


Comments