Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login input detection #33

Closed
4 tasks
btxtiger opened this issue Mar 2, 2021 · 1 comment
Closed
4 tasks

Login input detection #33

btxtiger opened this issue Mar 2, 2021 · 1 comment

Comments

@btxtiger
Copy link

btxtiger commented Mar 2, 2021

I actually didn't find yet how the login input field detection works. I would be open to contribute some improvements.
There are a couple of sites, where the login field is not recognized, especially if it is behind a modal.

You can comment more, if you have the issue.

@RoelVB
Copy link
Owner

RoelVB commented Mar 2, 2021

Sometime you have to "redetect fields" using the right-click menu or the keyboardshortcut.
I've tested this with Instagram and Twitter and it works fine.

I appreciate you wanting to contribute. This is how the detection flow is now:
The content_script calls the detectFields() method after the page is loaded:

$(document).ready(()=>{
pageControl.detectFields();
});

Then the PageControl class tries to find credential fields:

public detectFields()
{
const fieldSets: FieldSet[] = [];
let passwordFields: JQuery<HTMLElement> = $('input[type="password"]');
if(passwordFields.length) // Found some password fields?
{
passwordFields.each((passwordIndex, passwordField)=>{ // Loop through password fields
let prevField: JQuery<HTMLElement>;
$('input').each((inputIndex, input)=>{ // Loop through input fields to find the field before our password field
const inputType = $(input).attr('type') || 'text'; // Get input type, if none default to "text"
if(inputType != 'password') // We didn't reach our password field?
{
if($(input).is(':visible') && (inputType === 'text' || inputType === 'email' || inputType === 'tel')) // Is this a possible username field?
prevField = $(input);
}
else if($(input).is($(passwordField))) // Found our password field?
{
if(prevField) // Is there a previous field? Than this should be our username field
{
fieldSets.push(new FieldSet(this, $(passwordField), prevField));
return; // Break the each() loop
}
else if($(input).is(':visible')) // We didn't find the username field. Check if it's actually visible
{
fieldSets.push(new FieldSet(this, $(passwordField)));
return; // Break the each() loop
}
else // We didn't find a visible username of password field
return;
}
});
});
}
// Remember the fields we've found
this._fieldSets = fieldSets;
this._findCredentials();
this._attachEscapeEvent();
}

@RoelVB RoelVB closed this as completed Mar 13, 2021
Repository owner locked and limited conversation to collaborators Mar 13, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants