title: Chrome extension Javascript running only on icon click
body: <p>I want my Chrome Extension to load Javascript once user visits a website. But currently, the Javascript is executed only when user click the extension icon and till the extension popup is open.</p>
  
  <p>I saw the answer in this <a href="https://stackoverflow.com/questions/37468774/chrome-extension-to-load-the-script-without-clicking-on-icon">Chrome extension to load the script without clicking on icon</a> question.</p>
  
  <p>My manifest.json is:</p>
  
  <pre><code>{
    "manifest_version": 2,
  
    "name": "Javascript example",
    "description": "Some description.",
    "version": "1.1",
  
    "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html"
    },
    "permissions": [
      "activeTab",
      "storage"
    ],
    "content_scripts": [
      {
        "matches": ["*://*/*"],
        "js": ["popup.js"]
      }
    ]
  }
  </code></pre>
  
  <p>The popup.js is:</p>
  
  <pre><code>document.addEventListener('DOMContentLoaded', () =&gt; {
  
    alert("Working");
  });
  </code></pre>
  
  <p>popup.html is:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Getting Started Extension's Popup&lt;/title&gt;
      &lt;script src="popup.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The alert dialog is shown only when I click the extension icon (i.e. when popup.html is run), not when a page loads. I want the popup.js file to execute without user needing to click the extension icon. What am I missing?</p>