-
Notifications
You must be signed in to change notification settings - Fork 0
/
WalmartAddress.js
executable file
·62 lines (50 loc) · 1.75 KB
/
WalmartAddress.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* for https://www.walmart.com/wmflows/checkout* */
window.onload=function(){
if(typeof WalmartStepChecker !== 'undefined'){
var WalmartStepChecker = 1;
console.debug("js loaded properly");
var customerInfo = prompt("please paste address here");
populate(customerInfo);
}else{
populateCCInfo();
}
function populateCCInfo(){
console.debug("cc pop code");
}
function populate(customerInfo){
console.debug("populate();");
//var customerInfo = prompt("paste address below:");
//var customerInfo = "Jennifer Chatelle:5 HAYFIELD LN:HOLDEN, MA 01520-2185:5084142051";
var customerInfoArray = customerInfo.split(":");
//NAME
var nameArray = customerInfoArray[0].trim().split(" ");
var firstName=nameArray[0];
var lastName;
if(nameArray.length==1){
lastName=nameArray[0];
}else{
for(var i=1;i<nameArray.length-1;i++)
firstName+=nameArray[i];
lastName=nameArray[nameArray.length-1];
}
//STREET ADDRESS
var street = customerInfoArray[1].trim();
//CITY, STATE ZIP
var city, state, zip;
var cityArray = customerInfoArray[2].split(",");
city = cityArray[0].trim();
var state_zip = cityArray[1];
var index = state_zip.search(/\d/);
state = state_zip.substring(0, index-1).trim();
zip = state_zip.substring(index-1).trim();
//PHONE
var phone = customerInfoArray[3].trim();
console.debug("starting population");
console.debug(firstName + " " + lastName);
document.getElementById("firstName").value=firstName;
document.getElementById("lastName").value=lastName;
document.getElementById("street1").value=street;
document.getElementById("zip").value=zip;
document.getElementById("phone").value=phone;
}
};