mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-10 01:28:36 +02:00
notification bar detection improvements
This commit is contained in:
parent
c2c65baadb
commit
e288ade266
@ -50,39 +50,63 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (form) {
|
if (form) {
|
||||||
forms[i].formElement = form;
|
var formDataObj = {
|
||||||
formData.push(forms[i]);
|
data: forms[i],
|
||||||
|
formEl: form,
|
||||||
|
usernameEl: null,
|
||||||
|
passwordEl: null
|
||||||
|
};
|
||||||
|
locateFields(formDataObj);
|
||||||
|
formData.push(formDataObj);
|
||||||
form.addEventListener('submit', formSubmitted, false);
|
form.addEventListener('submit', formSubmitted, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formSubmitted(e) {
|
function locateFields(formDataObj) {
|
||||||
for (var i = 0; i < formData.length; i++) {
|
var passwordId = formDataObj.data.password ? formDataObj.data.password.htmlID : null,
|
||||||
if (formData[i].formElement === e.target) {
|
usernameId = formDataObj.data.username ? formDataObj.data.username.htmlID : null,
|
||||||
var password = null,
|
passwordName = formDataObj.data.password ? formDataObj.data.password.htmlName : null,
|
||||||
username = null,
|
usernameName = formDataObj.data.username ? formDataObj.data.username.htmlName : null,
|
||||||
passwordId = formData[i].password ? formData[i].password.htmlID : null,
|
|
||||||
usernameId = formData[i].username ? formData[i].username.htmlID : null,
|
|
||||||
inputs = document.getElementsByTagName('input');
|
inputs = document.getElementsByTagName('input');
|
||||||
|
|
||||||
if (passwordId && passwordId !== '') {
|
if (passwordId && passwordId !== '') {
|
||||||
password = document.getElementById(passwordId);
|
formDataObj.passwordEl = formDataObj.formEl.querySelector('#' + passwordId);
|
||||||
}
|
}
|
||||||
else if (formData[i].password) {
|
if (!formDataObj.passwordEl && passwordName !== '') {
|
||||||
password = inputs[formData[i].password.elementNumber];
|
formDataObj.passwordEl = formDataObj.formEl.querySelector('input[name="' + passwordName + '"]');
|
||||||
|
}
|
||||||
|
if (!formDataObj.passwordEl && formDataObj.passwordEl) {
|
||||||
|
formDataObj.passwordEl = inputs[formDataObj.data.password.elementNumber];
|
||||||
|
if (formDataObj.passwordEl && formDataObj.passwordEl.type !== 'password') {
|
||||||
|
formDataObj.passwordEl = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!formDataObj.passwordEl) {
|
||||||
|
formDataObj.passwordEl = formDataObj.formEl.querySelector('input[type="password"]');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usernameId && usernameId !== '') {
|
if (usernameId && usernameId !== '') {
|
||||||
username = document.getElementById(usernameId);
|
formDataObj.usernameEl = formDataObj.formEl.querySelector('#' + usernameId);
|
||||||
}
|
}
|
||||||
else if (formData[i].username) {
|
if (!formDataObj.usernameEl && usernameName !== '') {
|
||||||
username = inputs[formData[i].username.elementNumber];
|
formDataObj.usernameEl = formDataObj.formEl.querySelector('input[name="' + usernameName + '"]');
|
||||||
|
}
|
||||||
|
if (!formDataObj.usernameEl && formDataObj.data.username) {
|
||||||
|
formDataObj.usernameEl = inputs[formDataObj.data.username.elementNumber];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formSubmitted(e) {
|
||||||
|
for (var i = 0; i < formData.length; i++) {
|
||||||
|
if (formData[i].formEl === e.target) {
|
||||||
|
if (!formData[i].usernameEl || !formData[i].passwordEl) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var login = {
|
var login = {
|
||||||
username: username.value,
|
username: formData[i].usernameEl.value,
|
||||||
password: password.value,
|
password: formData[i].passwordEl.value,
|
||||||
url: document.URL
|
url: document.URL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user