Skip to content

fix code auto-pasting by using better heuristics to find the input box #1423

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mikelei8291
Copy link

Instead of checking for specific keywords in the name or id attributes of HTML input elements, we only need to find the first visible input element with correct type attributes and with no value or OTP-code-like values.

I think it's really unstable to check for the appearance of an arbitrary list of keywords in the name or id attributes, since website maintainers could use anything and it's never going to be exhaustive to match them all. Not to mention the current implementation could really match any hidden inputs that has these keywords in their name or id. What I think a better way is to find the first visible input element on the page that also has the correct type attribute, because it's usually the case that the website will present a single page which includes a single visible input element to the user when asking for their OTP codes.

Also, the new implementation always checks for the active element first and if it's a valid input element it will be used directly. I think this was the intention of the original implementation but I've encountered websites (e.g. Steam) that had hidden input elements that will be matched in the first stage and the function will simply return early.

I also use a single CSS selector to get all input elements with valid type attributes, instead of using a loop and an intermediate array to populate them.

I've tested the new implementation on Steam (which the old implementation doesn't work) and other websites and can confirm that it's working fine. However, please do keep in mind that this is a completely different heuristic than the original one so it might break on certain websites, but I think we can improve this on future user reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant