简体   繁体   English

如何在firefox扩展中检测到成功登录?

[英]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. 我正在尝试创建一个firefox扩展来检测是否有人成功登录到某个站点,但是在确定执行此操作的算法时遇到了一些困难。

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. 我现在的想法是使用javascript来实现这一点,并首先检查以确保用户在登录的页面上,为了所有密集的目的,密码字段。 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. 另一个想法是比较登录前后的URL,看看它们是否不同,但在同一个域内。 This however, has drawbacks for sites like facebook, for which the login and the landing page are the same. 然而,这对于诸如facebook之类的站点具有缺点,其登录和登陆页面是相同的。

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). 你提到的第一种方法实际上有一些优点,可能真的适用于大多数网站,但是当我们谈论使用FB身份验证或Google帐户身份验证登录时,你很可能会遇到问题,因为有多个重定向,并且密码输入可能永远不会出现(如果我已经登录到Google帐户,那么选择Google作为我的ID提供商会将我登录到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. 如果您可以考虑上述情况并提出解决方法(检查特定提供商的重定向......其中没有很多,所以您可以覆盖大多数情况),然后是的,您的第一个解决方案与此相结合可以提供一种可行的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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