title: Can the window object be modified from a Chrome extension?
body: <p>I would like to make a Chrome extension that provides a new object inside <code>window</code>. When a web page is viewed in a browser with the extension loaded, I would like <code>window.mything</code> to be available via Javascript. The <code>window.mything</code> object will have some functions that I will define in the extension, and these functions should be callable from <code>console.log</code> or any Javascript file when the page is viewed in a browser with the extension enabled. </p>
  
  <p>I was able to successfully inject a Javascript file into the page by using a <a href="http://developer.chrome.com/extensions/content_scripts.html" rel="noreferrer">Content Script</a>: </p>
  
  <pre><code>var s = document.createElement("script"); 
  s.src = chrome.extension.getURL("mything.js");
  document.getElementsByTagName("head")[0].appendChild(s);
  </code></pre>
  
  <p>mything.js looks like this:</p>
  
  <pre><code>window.mything = {thing: true};
  console.log(window);
  </code></pre>
  
  <p>Whenever a page loads, I see the entire <code>window</code> object as I expect it to be in the console. However, I can't interact with the <code>window.mything</code> object from the console. It seems at if the injected script hasn't really modified the global <code>window</code> object. </p>
  
  <p>How can I modify the global <code>window</code> object from a Chrome extension? </p>