title: Clicking an element on a page through Chrome Extension
body: <p>I am trying to create a chrome extension that will click on an element on a webpage when you click a button on the extension, but for some reason it does nothing no matter what I try.</p>
  
  <p>I've got this so far</p>
  
  <p>manifest.json</p>
  
  <pre><code>{  
    "manifest_version": 2,  
  
    "name": "Such Activity",  
    "description": "Wow",  
    "version": "1.0",    
    "permissions": [  
          "tabs", "&lt;all_urls&gt;"  
      ],  
  
    "browser_action": {  
      "default_icon": "icon.png",  
      "default_popup": "popup.html"  
    },  
       "content_scripts": [  
          {  
              "matches": [ "&lt;all_urls&gt;" ],  
             "js": ["content_script.js"]  
              }  
          ]  
  }
  </code></pre>
  
  <p>popup.html</p>
  
  <pre><code>&lt;!doctype html&gt;  
  &lt;html&gt;  
    &lt;head&gt;  
      &lt;title&gt;activity&lt;/title&gt;  
      &lt;style&gt;  
      &lt;/style&gt;  
      &lt;script src="content_script.js"&gt;&lt;/script&gt;  
    &lt;/head&gt;  
    &lt;body&gt;  
    &lt;button id="clickactivity"&gt;click&lt;/button&gt;  
    &lt;/body&gt;  
  &lt;/html&gt;  
  </code></pre>
  
  <p>content_script.js</p>
  
  <pre><code>function ClickPlanet()
      {
          var planets = document.getElementsByClassName("planet-name");
          var randomplanet = Math.floor(Math.random() * planets.length);
          var clickplanet = planets[randomplanet];
          clickplanet.click();
          setInterval(function () { ClickPlanet() }, 2000);
      }
  
  document.addEventListener('DOMContentLoaded', function () {
      document.getElementById('clickactivity').addEventListener('click', ClickPlanet);
  });
  </code></pre>
  
  <p>All I seem to be getting is this error</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'click' of undefined
  </code></pre>
  
  <p>I've been fiddling around with this for hours, but I can't get it to work. Any and all help is appreciated!</p>