title: Sending message from a background script to a content script, then to a injected script
body: <p>I'm trying to send messages from the background page to a content script, then send a message from that content script to an injected script. I've tried this, but it isn't working. </p>
  
  <p>Here's what my code looks like.</p>
  
  <p><strong>manifest.json</strong></p>
  
  <pre><code>{
    "manifest_version": 2,
  
    "name": "NAME",
    "description": ":D",
    "version": "0.0",
    "permissions": [
      "tabs","&lt;all_urls&gt;"
    ],
    "content_scripts": [
      {
        "matches": ["&lt;all_urls&gt;"],
        "js": ["content_script.js"]
      }
    ],
    "web_accessible_resources": [
        "injected.js"
    ],
    "background":{
        "scripts":["background.js"]
    }
  }
  </code></pre>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    chrome.tabs.sendMessage(tabs[0].id, {greeting: "hello"}, function(response){});
  });
  </code></pre>
  
  <p><strong>content_script.js</strong></p>
  
  <pre><code>var s = document.createElement('script');
  s.src = chrome.extension.getURL('injected.js');
  s.onload = function(){ 
          this.parentNode.removeChild(this);
  };
  (document.head||document.documentElement).appendChild(s);
  
  
  chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
      document.dispatchEvent(new CustomEvent('Buffer2Remote', {todo: "LOL"}));
  });
  </code></pre>
  
  <p><strong>injected.js</strong></p>
  
  <pre><code>document.addEventListener('Buffer2Remote', function(e){
      alert(e.todo);
  });
  </code></pre>
  
  <p>The message sending doesn't work from the first part, background -> content_script.
  Is there anything wrong with my code?</p>