title: How to grab data from webpage in Chrome and output into Chrome extension popup?
body: <p>For a Google Chrome extension, none of the Javascript I write to manipulate the DOM of the extension popup.html seems to have any effect on the popup's DOM.  I can manipulate the DOM of the current webpage in the browser just fine by using content_script.js, and I'm interested in grabbing data from the webpage and outputting it into the extension popup, like so (below: popup.html):</p>
  
  <pre><code>&lt;div id="extensionpopupcontent"&gt;Links&lt;/div&gt;
  &lt;a onclick="click()"&gt;Some Link&lt;/a&gt;
  
  &lt;script type="text/javascript"&gt;
   function click() {
    chrome.tabs.executeScript(null, {file: "content_script.js"});
    document.getElementById("extensionpopupcontent").innerHTML = variableDefinedInContentScript;
    window.close();
   }
  &lt;/script&gt;
  </code></pre>
  
  <p>I tried using chrome.extension.sendRequest from the documentation at <a href="http://code.google.com/chrome/extensions/messaging.html" rel="noreferrer">http://code.google.com/chrome/extensions/messaging.html</a>, but I'm not sure how to properly use it in my case, specifically the greeting and the response.</p>
  
  <pre><code>contentscript.js
  ================
  chrome.extension.sendRequest({greeting: "hello"}, function(response) {
    console.log(response.farewell);
  });
  </code></pre>