title: Content script to update specific tab popup
body: <p>Let's have an imaginary extension which takes everything after '/' from url, which is done in content script. Also updates badge and change text in popup.html, which different for every tab (different tab, diff. url)</p>
  
  <p><em>contentscript.js:</em>  </p>
  
  <pre><code>var str = document.URL;
  var n = str.lastIndexOf('/');
  var result = str.substring(n + 1);
  chrome.runtime.sendMessage({message: "result", url: result});
  </code></pre>
  
  <p><em>eventpage.js:</em></p>
  
  <pre><code>chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
      if (request.message == "result") {
          chrome.browserAction.setBadgeText({tabId:sender.tab.id, "text" : "1"});      
        links = request.url;
          }
  </code></pre>
  
  <p><em>popup.js:</em></p>
  
  <pre><code>$(function () {
      var bg = chrome.extension.getBackgroundPage();
      $('#total').text(bg.links);
  });
  </code></pre>
  
  <p><em>popup.html</em></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Plugin&lt;/title&gt;
          &lt;script type="text/javascript" src="jquery-1.11.3.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="popup.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id='total'&gt;Nothing&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This works only on new loaded tabs, not when I click between them. For example, when I load first page "webpage.com/first" my popup's got 'first'. When I load second page(on different tab) "webpage.com/second" popup is 'second'. After that I click on the first page (on the first tab) and my popup is 'second' which I meant to be 'first'.  </p>
  
  <p>//badge in my project is counter, I wrote it here only for getting an idea</p>