title: Chrome extension code vs Content scripts vs Injected scripts
body: <p>I am trying to get my Chrome Extension to run the function <code>init()</code> whenever a new page is loaded, but I am having trouble trying to understand how to do this. From what I understand, I need to do the following in background.html:</p>
  
  <ol>
  <li>Use <code>chrome.tabs.onUpdated.addListener()</code> to check when the page is
  changed</li>
  <li>Use <code>chrome.tabs.executeScript</code> to run a script.</li>
  </ol>
  
  <p>This is the code I have:</p>
  
  <pre><code>//background.html
  chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
      chrome.tabs.executeScript(null, {code:"init();"});
  });
  
  //script.js
  function init() {
      alert("It works!");
  }
  </code></pre>
  
  <p><strong>I am also wondering if the init() function will have access to my other functions located in other JS files?</strong></p>