title: How to set input on chrome extension to text from dom?
body: <p>I am trying to get text from the web page on click into the input on my chrome extension.
  Content script</p>
  <pre><code>document.addEventListener('click', function (e) {
    let target = e.target
    let text = target.textContent || target.innerText;
    chrome.runtime.sendMessage({ text }, function (response) {
      console.log(response.farewell);
    });
  }, false);
  </code></pre>
  <p>and background script</p>
  <pre><code>chrome.runtime.onMessage.addListener(
    function (request, sender, sendResponse) {
      document.getElementById(&quot;userinput&quot;).value = &quot;My value&quot;;
      sendResponse({ farewell: request.text });
    }
  );
  </code></pre>
  <p>My popup.html just has id of 'userinput' and i am getting <code>unchecked runtime.lastError: The message port closed before a response was received.</code> Error</p>