-
Notifications
You must be signed in to change notification settings - Fork 231
/
Copy pathpw_autofill.js
35 lines (34 loc) · 1.32 KB
/
pw_autofill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function retrievePasswordFromPage() {
let password = "";
let formData = {};
let inputList = document.getElementsByTagName("input");
for(let i=0;i<inputList.length && inputList[i];i++){
if(inputList[i].type === "password" && inputList[i].value != ""){
password = inputList[i].value;
}
else if(inputList[i].type != "hidden" && inputList[i].value != ""){
if(inputList[i].id != ""){
formData[inputList[i].id] = inputList[i].value;
} else if (inputList[i].name != "") {
formData[inputList[i].name] = inputList[i].value;
}
}
}
return [password, formData];
}
function autofillPassword(password){
let formData = %1
let inputList = document.getElementsByTagName("input");
for(let i=0;i<inputList.length && inputList[i];i++){
if(inputList[i].type === "password"){
inputList[i].value = password;
}
else if(inputList[i].type != "hidden"){
if (inputList[i].id != "" && formData[inputList[i].id] != undefined){
inputList[i].value = formData[inputList[i].id];
} else if (inputList[i].name != "" && formData[inputList[i].name] != undefined){
inputList[i].value = formData[inputList[i].name];
}
}
}
}