I am currently working on an application with a built-in web browser. To make life easier for our customers, we have the ability to store passwords for our websites in our database. We are currently using Javascript to output information to the browser after the page loads.
Here is the script that we run on the page that requires the user / password to load ....
JavaScript:
var pwd="{0}"; //get password from vb.net app var usr="{1}"; //get username from vb.net app var inputs=document.getElementsByTagName("input"); //look for all inputs for(var i=0;i<inputs.length;i++){{ //for each input on document var input=inputs[i]; //look at whatever input if(input.type=="password"&&(input.name.toLowerCase().indexOf("auth")==-1)){ {input.value=pwd} } if(input.type=="text"&&(input.name.toLowerCase().indexOf("login")!=-1||input.name.toLowerCase().indexOf("user")!=-1||input.name=="AgentAccount")){ {input.value=usr} } }}; undefined;
One of the pages I'm looking at is https://www.pagepluscellular.com/login/ - the code of the form I'm looking at is this.
<div class="row"> <label for="username">Username:</label> <input name="username" type="text" maxlength="75"> </div> <div class="row"> <label for="password">Password:</label> <input name="password" type="password" maxlength="50"> </div>
And again, it works great. It fills in the password / username field just fine.
My question is why / how, in particular, in relation to .indexOf ("independently"). In my opinion, the current script is looking for input, checking if this is a password field or what you have, and then setting this field ...
But he never searches for these fields. For example, on the pagepluscellular website above, the input names are "username" and "password", but in our script it never looks for the name "username" or "password" .... since this is done you know how to fill out this specific data?
What I'm trying to do is this. We found a website for which it DOES NOT WORK. Namely, https://www.boostmobilesales.com/boost-sales-portal/faces/login.jsp . The form code on this page ...
<input id="loginform:username" type="text" name="loginform:username" "class="outputtext" size="20"> <input id="loginform:password" type="password" name="loginform:password" value="" size="20" class="inputSecret">
So, I'm 99.99% sure, because the name is "loginform: whatever". I DO NOT know how to tell my script to include this if the name is actually "loginform: whatever". I tried changing my script to this ... (just checked if it equals "loginform: whatever")
JavaScript:
var pwd="{0}"; //get password from vb.net app var usr="{1}"; //get username from vb.net app var inputs=document.getElementsByTagName("input"); //look for all inputs for(var i=0;i<inputs.length;i++){{ //for each input on document var input=inputs[i]; //look at whatever input if((input.type=="password"&&(input.name.toLowerCase().indexOf("auth")==-1)) || input.name.toLowerCase() == "loginform:password"){ {input.value=pwd} } if((input.type=="text"&&(input.name.toLowerCase().indexOf("login")!=-1||input.name.toLowerCase().indexOf("user")!=-1||input.name=="AgentAccount")) || input.name.toLowerCase() == "loginform:username"){ {input.value=usr} } }}; undefined;
but instead of giving me the desired behavior, it ended up breaking the original behavior so that none of them work (the pageplus site stopped pulling out the username / password). When I get back to the original script, it started working again.
Can someone explain to me the logic of this line of code?
input.name.toLowerCase().indexOf("auth") == -1 // or !=-1 for "login", etc
I understand that you look at the input name in lowercase and see if it contains the words "auth". If it contains "auth" in the first space, it should fill in the password ... right?
Sorry for the long post, I just wanted to clear my thoughts and explain everything that I have tried so far.