title: Chrome Extension - Run content script only when button is clicked
body: <p>I've had a good look, but I can't seem to find and answer to this question (well, one that works for me anyway).</p>
  
  <p>I've made a Chrome extension that should run the code that's in my content script on click of the icon only, but it always runs as soon as the page loads. Is there a way to prevent this from happening? None of the possible strings I can enter for run_at really cater for this.</p>
  
  <p>Here is example code in both scripts:</p>
  
  <p>Content Script:</p>
  
  <pre><code>function runIt() {
      console.log('working');
  }
  runIt();
  </code></pre>
  
  <p>background.js:</p>
  
  <pre><code>chrome.browserAction.onClicked.addListener(function(activeTab) {
      chrome.tabs.executeScript(null, {file: "content.js"});
  });
  </code></pre>
  
  <p>It will log 'working' as soon as the page loads, and for each button click after that. Is there a way to stop it running as soon as the page loads?</p>
  
  <p>Thanks in advance for all contributions.</p>