title: How can I sync to extension local storage in content script?
body: <p>Now I use <code>chrome.extension.sendMessage</code> in content script and <code>chrome.extension.onMessage.addListener</code> in background script. But the problem appears when I need to sync to extension's local storage in real time (several checkboxes with options in extension popup). </p>
  
  <p>Popup with checkbox (to control content-script.js options) -> checkbox state stored in extension's local storage.</p>
  
  <p>Content script need to know changes made by user in popup window -> send request to Background page to access extension's local storage keys.</p>
  
  <p>Background page -> send response to Content script -> callback function replicate all keys from extension's local storage to web local storage.</p>
  
  <p>Content script read replicated keys and turn on/off it's options.</p>
  
  <p>But this process is not real-time and I need it to be reactive.</p>
  
  <p>Content-script.js: </p>
  
  <pre><code>chrome.extension.sendMessage({
      name: "cache"
  },
  function(response) {
      var status = response.url;
      if (status == 'enabled') {
          localStorage['cache'] = 'enabled';
      }
      if (status == 'disabled') {
          localStorage['cache'] = 'disabled';
      }
  }
  );
  </code></pre>
  
  <p>Backround.js:</p>
  
  <pre><code>chrome.extension.onMessage.addListener(
  function(request, sender, sendResponse) {
      console.log("request recieved is " + request);
      if (request.name == "cache") {
          sendResponse({
              url: JSON.parse(localStorage['cache']).status
          });
      } else {}
  }
  );
  </code></pre>
  
  <p>Thanks for your help!</p>