#1501 clickSubmit - trim FIX

This commit is contained in:
GrzegorzZajac000 2024-02-13 12:38:11 +01:00
parent dd25e9ebe5
commit 73c2d38f4d
3 changed files with 63 additions and 8 deletions

View File

@ -62,10 +62,19 @@ const clickSubmit = (inputElement, siteURL) => {
if (form) {
const formSubmit = Array.from(form.querySelectorAll('button[type="submit"], input[type="submit"]'));
if (formSubmit && formSubmit.length === 1 && !ignoreButtonTexts().includes(formSubmit[0].innerText.trim().toLowerCase())) {
try {
formSubmit[0].click();
} catch (e) {}
if (formSubmit && formSubmit.length === 1) {
const formSubmitText = formSubmit[0]?.innerText;
if (
formSubmitText &&
typeof formSubmitText.trim === 'function' &&
typeof formSubmitText.toLowerCase === 'function' &&
!ignoreButtonTexts().includes(formSubmitText.trim().toLowerCase())
) {
try {
formSubmit[0].click();
} catch (e) {}
}
return true;
}

View File

@ -46,14 +46,36 @@ const getFormElements = () => {
}
if (element.nodeName.toLowerCase() === 'button') {
return buttonsTexts.includes(element.innerText.trim().toLowerCase())
const elementText = element?.innerText;
if (
elementText &&
typeof elementText.trim === 'function' &&
typeof elementText.toLowerCase === 'function'
) {
return buttonsTexts.includes(elementText.trim().toLowerCase())
} else {
return false;
}
}
return false;
})
}
return elements.filter(element => !ignoreButtonTexts().includes(element.innerText.trim().toLowerCase()));
return elements.filter(element => {
const elementText = element?.innerText;
if (
elementText &&
typeof elementText.trim === 'function' &&
typeof elementText.toLowerCase === 'function'
) {
return !ignoreButtonTexts().includes(elementText.trim().toLowerCase());
} else {
return false;
}
});
};
module.exports = getFormElements;

View File

@ -35,10 +35,34 @@ const getFormSubmitElements = () => {
if (submits.length <= 0) {
const buttons = Array.from(document.querySelectorAll('input[type="button"],button'));
submits = buttons.filter(button => buttonsTexts.includes(button.innerText.trim().toLowerCase()));
submits = buttons.filter(button => {
const buttonText = button?.innerText;
if (
buttonText &&
typeof buttonText.trim === 'function' &&
typeof buttonText.toLowerCase === 'function'
) {
return buttonsTexts.includes(buttonText.trim().toLowerCase())
} else {
return false;
}
});
}
return submits.filter(button => !ignoreButtonTexts().includes(button.innerText.trim().toLowerCase()));
return submits.filter(button => {
const buttonText = button?.innerText;
if (
buttonText &&
typeof buttonText.trim === 'function' &&
typeof buttonText.toLowerCase === 'function'
) {
return !ignoreButtonTexts().includes(button.innerText.trim().toLowerCase());
} else {
return false;
}
});
};
module.exports = getFormSubmitElements;