title: Exchanging Settings from Options Page to Content-Script in Chrome Extension
body: <p>I got a chrome extension which has the following manifest (part)</p>
  
  <pre><code>  "content_scripts": [
      {
        "matches": ["https://plus.google.com/*"],      
        "js": ["jquery-1.10.2.min.js","filter.js"]
      }
    ],
    "options_page": "settings.html",
  </code></pre>
  
  <p>I successfully read and write settings into the localstorage from within the "settings.js" which is called from the settings-page "settings.html"</p>
  
  <p>Now I need to access these values from the content-script "filter.js"</p>
  
  <p>I followed the example of <a href="http://developer.chrome.com/extensions/messaging.html" rel="nofollow">http://developer.chrome.com/extensions/messaging.html</a> creating a listener to the "settings.js" and a request to the "filter.js":</p>
  
  <p>settings.js:</p>
  
  <pre><code>chrome.runtime.sendMessage({greeting: "hello"}, function(response) {
          console.log(response.farewell);
      });
  </code></pre>
  
  <p>filter.js:</p>
  
  <pre><code>chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
      console.log(sender.tab ?
                  "from a content script:" + sender.tab.url :
                  "from the extension");
      if (request.greeting == "hello")
        sendResponse({farewell: "goodbye"});
    });
  </code></pre>
  
  <p>It does not look like the listener and the request can "find each other".</p>
  
  <p>All I get on the console is:</p>
  
  <pre><code>Error in event handler for (unknown): TypeError: Cannot read property 'farewell' of undefined
          at chrome-extension://opojapnnibghjncfphindgjhddljcgej/settings.js:30:23
          at extensions::messaging:320:11
          at Function.target.(anonymous function) (extensions::SafeBuiltins:19:14)
          at Event.dispatchToListener (extensions::event_bindings:386:22)
          at Event.dispatch_ (extensions::event_bindings:371:27)
          at Event.dispatch (extensions::event_bindings:392:17)
          at dispatchOnDisconnect (extensions::messaging:280:27)
  </code></pre>
  
  <p>What am I doing wrong? </p>