title: Chrome extensions (can't get and click elements on new chrome tabs)
body: <p>That's it. Lemme explaim myself.
  I coded a chrome extension that when clicking on a button, it will open a new resized tab (a paypal login) , but I can't manage to click the &quot;log in button&quot; of paypal because trying to</p>
  <pre><code>document.getElementById('btnLogin').click();
  </code></pre>
  <p>isn't working, neither adding that:</p>
  <pre><code>var paypal = window.open(&quot;https://www.paypal.com/es/signin&quot;, &quot;PayPal&quot;, &quot;width=400,height=400,location=yes,menubar=yes,status=yes,titilebar=yes,resizable=yes&quot;);
  paypal.onload = function() {
      paypal.document.getElementById('btnLogin').click();
  }
  </code></pre>
  <p>Check out all of my code:</p>
  <p><strong>manifest.json</strong></p>
  <pre><code>{
      &quot;manifest_version&quot;: 2,
      &quot;name&quot;: &quot;Zapatillao&quot;,
      &quot;description&quot;: &quot;Yatusabe te cojo sapatilla&quot;,
      &quot;version&quot;: &quot;2.0.0&quot;,
      &quot;content_scripts&quot;: [
          {
          &quot;matches&quot;: [&quot;&lt;all_urls&gt;&quot;],
          &quot;js&quot;: [&quot;content.js&quot;]
          }
      ],
      &quot;browser_action&quot;: {
          &quot;default_popup&quot;: &quot;popup.html&quot;,
          &quot;default_icon&quot;: &quot;icon128.jpg&quot;
      },
      &quot;permissions&quot;: [
          &quot;tabs&quot;,
          &quot;http://*/*&quot;,
          &quot;https://*/*&quot;,
          &quot;chrome://*/*&quot;
      ]
  }
  </code></pre>
  <p><strong>content.js</strong></p>
  <pre><code>document.getElementById('paypal_prelog').addEventListener('click', function() {
      chrome.tabs.executeScript({
        file: &quot;paypal_prelog.js&quot;
      });
  });
  
  </code></pre>
  <p><strong>popup.html</strong></p>
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;style&gt;
              html, body {
                  height: 200px;
                  width: 200px;
              }
          &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Discord: Loan#2334&lt;/h1&gt;
          &lt;button id='paypal_prelog'&gt;PayPal Prelogin&lt;/button&gt;
          &lt;script src='content.js'&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p><strong>paypal_prelog.js</strong></p>
  <pre><code>function sleep (ms) {
      return new Promise(resolve =&gt; setTimeout(resolve, ms));
  }
  
  var paypal = window.open(&quot;https://www.paypal.com/es/signin&quot;, &quot;PayPal&quot;, &quot;width=400,height=400,location=yes,menubar=yes,status=yes,titilebar=yes,resizable=yes&quot;);
  paypal.onload = function() {
      paypal.document.getElementById('btnLogin').click();
  }
  
  function closeWin() {
      paypal.close();
  }
  </code></pre>
  <blockquote>
  <p>I have tried thousand of things, hope you can help me.</p>
  </blockquote>