title: How to execute my content script on a newly opened chrome tab?
body: <p>I am calling a Chrome extension from a web portal to open a URL in a new tab, and on the newly opened tab I want to perform <code>executeScript</code>:</p>
  
  <p><strong>manifest.json</strong></p>
  
  <pre><code>"externally_connectable": {
    "matches": ["http://localhost:3000/*"]
  },
  "permissions": ["tabs", "http://*/*", "https://*/*"]
  </code></pre>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>// listen to webportal
  chrome.runtime.onMessageExternal.addListener(
    function(request, sender, sendResponse) {
      a = chrome.tabs.create({ url: request.openUrlInEditor });
      chrome.tabs.insertCSS(a.id, { file: "combined.css" });
      chrome.tabs.executeScript(a.id, { file: "combined.js" });
    }
  );
  </code></pre>
  
  <p>If I try to perform <code>insertCSS</code> and <code>executeScript</code> on extension click,
  it works fine</p>
  
  <p><strong>background.js</strong></p>
  
  <pre><code>chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.insertCSS(tab.id, { file: "combined.css" });
    chrome.tabs.executeScript(tab.id, { file: "combined.js" });
  });
  </code></pre>