cancel
Showing results for 
Search instead for 
Did you mean: 

Chrome extensions (can't get and click elements on new chrome tabs)

Options
summary90
Contributor
Posted on

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 "log in button" of paypal because trying to

document.getElementById('btnLogin').click();

isn't working, neither adding that:

var paypal = window.open("https://www.paypal.com/es/signin", "PayPal", "width=400,height=400,location=yes,menubar=yes,status=yes,titilebar=yes,resizable=yes");
paypal.onload = function() {
    paypal.document.getElementById('btnLogin').click();
}

Check out all of my code for the Website:

manifest.json

{
    "manifest_version": 2,
    "name": "Zapatillao",
    "description": "Yatusabe te cojo sapatilla",
    "version": "2.0.0",
    "content_scripts": [
        {
        "matches": ["<all_urls>"],
        "js": ["content.js"]
        }
    ],
    "browser_action": {
        "default_popup": "popup.html",
        "default_icon": "icon128.jpg"
    },
    "permissions": [
        "tabs",
        "http://*/*",
        "https://*/*",
        "chrome://*/*"
    ]
}

content.js

document.getElementById('paypal_prelog').addEventListener('click', function() {
    chrome.tabs.executeScript({
      file: "paypal_prelog.js"
    });
});

popup.html

<html>
    <head>
        <style>            html, body {
                height: 200px;
                width: 200px;
            }
        </style>
    </head>
    <body>
        <h1>Discord: Loan#2334</h1>
        <button id='paypal_prelog'>PayPal Prelogin</button>
        <script src='content.js'></script>
    </body>
</html>

paypal_prelog.js

function sleep (ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

var paypal = window.open("https://www.paypal.com/es/signin", "PayPal", "width=400,height=400,location=yes,menubar=yes,status=yes,titilebar=yes,resizable=yes");
paypal.onload = function() {
    paypal.document.getElementById('btnLogin').click();
}

function closeWin() {
    paypal.close();
}

I have tried thousand of things, hope you can help me.

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.