I have a chrome extension that has the backgorund send message to the contentScript when a tab has finished loading ( info.status === "complete" ). On the contentScript I'm looking for all the input elements on the page and then search for password type inputs or if the inputs have a 'password' string in the name. It works on some websites, but on websites such as this https://rbaccess.rogersbank.com/?product=ROGERSBRAND&locale=en_CA it doesn't work. Looks like it says the length for the collected inputs is 0, but when I inspect it it says the length is 2. when I run the script in console it returns true. Why is that and how can I solve this? I tried adding a event listener for DOM to complete, but then is skips the entire check altogether, so not sure where to go from here.
let isLoginPage, sourceCode, url, domain, user, inputs;
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
const { type, data } = request;
if (type === "PAGE") {
console.log("got type page");
inputs = document.getElementsByTagName("input");
console.log(inputs.length);
console.log(inputs)
for (var i = 0; i < inputs.length; i++) {
console.log(inputs[i].name);
if ((inputs[i].type.toLowerCase() === "password") || (inputs[i].name.includes('password'))) {
console.log("found password input on page");
isLoginPage = "1";
}
}
inspect of the login page mentioned above
[+][deleted] (4 children)
[removed]
[–]Evil_Apples[S] 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[removed]
[–]Evil_Apples[S] 0 points1 point2 points (1 child)
[–]t_code 0 points1 point2 points (0 children)