title: chrome.tabs.executeScript: How to get access to variable from content script in background script?
body: <p>How to get access to variable <code>app</code> from content script <code>app.js</code> in background script <code>background.js</code>?</p>
  
  <p>Here is how I try it (<code>background.js</code>):</p>
  
  <pre><code>chrome.tabs.executeScript(null, { file: "app.js" }, function() {
     app.getSettings('authorizeInProgress'); //...
  });
  </code></pre>
  
  <p>Here is what I get:
  <img src="https://i.stack.imgur.com/NBgYx.png" alt="Error during tabs.executeScript: Cannot access contents of url &quot;chrome-devtools://devtools/devtools.html?docked=true&amp;dockSide=bottom&amp;toolbarColor=rgba(223,223,223,1)&amp;textColor=rgba(0,0,0,1)&quot;. Extension manifest must request permission to access this host. \n Uncaught ReferenceError: app is not defined "></p>
  
  <p>Here is <code>manifest.json</code>:</p>
  
  <pre><code>{
    "name": "ctrl-vk",
    "version": "0.1.3",
    "manifest_version": 2,
    "description": "Chrome extension for ctrl+v insertion of images to vk.com",
  
    "content_scripts": [{
      "matches": [
          "http://*/*",
          "https://*/*"
      ],
      "js": ["jquery-1.9.1.min.js"
      ],
      "run_at": "document_end"
    }],
  
    "web_accessible_resources": [
      "jquery-1.9.1.min.js"
    ],
  
    "permissions" : [
      "tabs",
      "http://*/*",
      "https://*/*"
    ],
  
    "background": {
      "persistent": false,
      "scripts": ["background.js"]
    }
  }
  </code></pre>
  
  <h1>Full code for instance, at github</h1>
  
  <p><a href="https://github.com/MaxLord/ctrl-vk/tree/with_bug" rel="noreferrer">https://github.com/MaxLord/ctrl-vk/tree/with_bug</a></p>