0

I am currently working on chrome extension which can auto-fill and auto-login and I have figured a way out for detecting and submitting the login info but now there are many websites which have popup login such as twitter.com some have single input submit like amazon.com. It is working on many websites but it also puts a lot of load on the tab. How can I solve the performance issue?

to detect input fields I have used type = password,email,text with the non hidden attribute and to find submit button I have used below logic to find submit button

const buttonElementsList = ['input', 'button', 'a', 'p', 'span', 'div',];

document.evaluate(`//${buttonElementsList[i]}[contains(.,'${btnText}')]`, mutation.target, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
// btnText picks one everytime from below array
[
    "Log In",
    "LogIn",
    "LogIN",
    "log in",
    "login",
    "log IN",
    "Login",
    "LOG IN",
    "LOGIN",
    "Log in",
    "Log in ",...]

to keep an eye on the dom tree to look for popup based login I have used Mutation Obersver

manifest version is 3.

Thanks in advance

  • document.evaluate is super slow by itself and you exacerbate the situation by using it in a loop for each tag. Things to try: [define all tags in one condition](/a/722251) so you use just one call. 2) Use documents.querySelectorAll to find the elements and check their textContent explicitly. Note that there's no need to check `input` element for it, just specify its types in querySelectorAll. See also [Performance of MutationObserver to detect nodes in entire DOM](https://stackoverflow.com/a/39332340) – wOxxOm Mar 06 '23 at 12:01

0 Answers0