2

i got the username and password using javascript, but the code wont work for all sites. gmail uses a different id's than face books, and many sites probably do also, so how can make the code work for any site logging in?

heres how it gets the username/password now:

if (navigationType == UIWebViewNavigationTypeFormSubmitted) {
    //works for gmail
    NSString *username = [WebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('Email')[0].value"];
    NSString *password = [WebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('Passwd')[0].value"];

    //works for facebook?
    //NSString *username = [WebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('email')[0].value"];
    //NSString *password = [WebView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('pass')[0].value"];
    NSLog(@"username is %@\npassword is %@",username,password);
}

so i just want to know how to get the username and password for any site the user logs into so i can make it save, and then auto-fill when they go back and it is logged out so its an easy login.

Maximilian Litteral
  • 3,059
  • 2
  • 31
  • 41

2 Answers2

2

To Get all text fields you can place a js query like this

document.querySelectorAll("input[type='text']")

Hope this help. :)

Also to get more details, refer this post

Community
  • 1
  • 1
DivineDesert
  • 6,924
  • 1
  • 29
  • 61
-1

If you want it to work for ANY site, you're going to have to do something completely different. Perhaps create an array of sites and then store the fields to that object. You could search for each "password" input and then try to move up to the previous input since most of the time it's username then password fields.

But you won't be able to get it to work for every site out there.

romo
  • 1,990
  • 11
  • 10
  • well i know how to store them for any site, but getting them is the issue, because the getelementbyname text is different for tons of sites, i dont know how i can get it for any site, apple somehow does and i think dolphin browser can to. – Maximilian Litteral Sep 02 '12 at 02:21