title: Clicking Buttons on a Website with a chrome extension
body: <p>I am trying to make a google chrome extension that allows the user to press a button in the chrome extension menu and that causes a button on a selected webpage to be clicked.The problem I have currently is the syntax and code in my injector.js. It says unexpected token ; and unexpected token [. I would appreciate any help.
  Here is my manifest.json:</p>
  
  <pre><code>    {
    "manifest_version":2,
  
    "name": "Button Click",
    "description": "Be able to press buttons",
    "version": "1.0",
  
    "browser_action": {
      "default_icon": "icon.png",
      "default_popup": "popup.html"
    },
    "permissions": [
      "activeTab",
      "storage"
    ]
  }
  </code></pre>
  
  <p>Here is my html</p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  
  &lt;html&gt;  
      &lt;head&gt;
      &lt;title&gt;Fill&lt;/title&gt;
  
      &lt;/script&gt;&lt;script src="popup.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
    &lt;body&gt;
      &lt;h2 id="htwo"&gt;Button presser&lt;/h2&gt;
      &lt;button id="press"&gt;Press Button&lt;/button&gt;
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>and my javascript:</p>
  
  <pre><code>window.onload=function(){
      if(document.getElementById("press")){
          document.getElementById("press").addEventListener('click',function(){
              document.getElementById("htwo").innerHTML="yay";
              chrome.tabs.executeScript({
                  file:"injector.js"
              });
          });
      }
  }
  </code></pre>
  
  <p>injector.js:</p>
  
  <pre><code>function pressButton(){
      var buttons=document.getElementsByClassName("button"),
      button[0].click();
  }
  pressButton();
  </code></pre>
  
  <p>By the way, the button I am trying to click is an input button  in which I inspect element, I get:
  "(input type="submit" name="commit" value="add to cart" class="button")"
  for some reason wont display
  This button can be found here:
  <a href="http://www.supremenewyork.com/shop/accessories/p840x2jsc/yks6zay73" rel="noreferrer">http://www.supremenewyork.com/shop/accessories/p840x2jsc/yks6zay73</a></p>
  
  <p>Note: I know there were other people asking questions about the same topic, but the method that they used didn't work for me. 
  Thanks for helping me out!</p>