简体   繁体   中英

How can I detect a successful login in my firefox extension?

I am trying to create a firefox extension to detect if someone successfully logs into a site, but am having a little difficulty determining an algorithm to do this.

My thoughts right now are to use javascript to accomplish this and to firstly check to make sure the user is on a page with a login, for all intensive purposes a password field. Then after a login attempt has occurred, I would check to see if it is successful by looking to see if a password field is still on the page.

Another idea would be to compare the url before and after the login and see if they are different, yet within the same domain. This however, has drawbacks for sites like facebook, for which the login and the landing page are the same.

Does anyone have any other ideas on how I might make this detection?

Thanks in advance!

You pretty much can't make a generalized detection algorithm that would work on each page. As you yourself mentioned, different pages have different schemes.

Even in the scheme where the login and landing page are different, how would you know whether the post-login page displays an error or notifies somebody of a successful login?

The first method you mention actually has some merit and might really work for most of the sites, but again there is a good chance you will run into problems when we talk about logging in using FB authentication or Google Accounts authentication, as there are multiple redirects, and also a password input may never appear (in case I am already logged in to Google Accounts, then jut choosing Google as my ID provider logs me in to StackOverflow).

If you could consider the above mentioned case and come up with a workaround (checking redirects for specific providers.. there are not many of them, so you could cover most of the cases), then yes, your first solution combined with this could provide a workable method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM