-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbca.js
More file actions
165 lines (152 loc) · 6.8 KB
/
bca.js
File metadata and controls
165 lines (152 loc) · 6.8 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const { ipcRenderer } = require('electron');
const ipc = ipcRenderer;
const moment = require("moment");
var data = localStorage.getItem("data") ? JSON.parse(localStorage.getItem("data")) : localStorage.getItem("data");
ipc.on("data", (event, params) => {
data = params,
localStorage.setItem("data", JSON.stringify(params));
});
window.alert = (message) => ipc.send("errorProses", {data: data, message: message});
document.addEventListener("DOMContentLoaded", async function() {
if(checkHalaman.login()) {
console.log("di halaman login");
if (data.data) {
ipc.send("win:close", {
child: true,
id: data.account.username
})
}else{
func.input();
}
}else if(checkHalaman.home()) {
console.log("di halaman home");
if (data.type == "saldo") {
func.saldo();
}else if (data.type == "mutasi") {
func.mutasi();
}else{
console.log("gak tau di halaman mana");
}
}else{
console.log("halaman tidak di ketahui");
}
})
const checkHalaman = {
login: () => {
return document.body.textContent.includes("Registrasi Internet melalui ATM BCA");
},
home: () => {
return document.querySelectorAll("frame").length > 0 ? true : false;
}
}
const func = {
input: () => {
setTimeout(() => {
document.getElementById("user_id").value = data.account.username;
setTimeout(() => {
document.getElementById("pswd").value = data.account.password;
setTimeout(() => {
document.querySelector('input[value="LOGIN"]').click();
}, 1000);
}, 1000);
}, 1000);
},
saldo: () => {
var menu = document.querySelector('frame[name="menu"]');
var atm = document.querySelector('frame[name="atm"]');
setTimeout(() => {
console.log("click informasi account");
menu.contentWindow.document.querySelector('a[href="account_information_menu.htm"]').click();
setTimeout(() => {
console.log("click informasi saldo");
menu.contentWindow.document.querySelector(`a[onclick="javascript:goToPage('balanceinquiry.do');return false;"]`).click();
var check = 0;
var int = setInterval(() => {
check += 1;
if (check > 10) clearTimeout(int);
if(atm.contentWindow.document.body.textContent.includes('INFORMASI REKENING - INFORMASI SALDO')) {
console.log("Proses saldo");
var html = atm.contentWindow.document.body.outerHTML;
data.data = html;
localStorage.setItem("data", JSON.stringify(data));
ipc.send("update:data", {
id: data.id,
data: html
});
func.logout();
}else{
console.log("rekening belum di temuin ke => ", check);
if (check > 10) func.logout();
}
}, 1000);
}, 3000);
}, 3000);
},
mutasi: () => {
var menu = document.querySelector('frame[name="menu"]');
var atm = document.querySelector('frame[name="atm"]');
const start = func.convertDate(data.date_start);
const end = func.convertDate(data.date_end);
setTimeout(() => {
console.log("click informasi account");
menu.contentWindow.document.querySelector('a[href="account_information_menu.htm"]').click();
setTimeout(() => {
console.log("click informasi saldo");
menu.contentWindow.document.querySelector(`a[onclick="javascript:goToPage('accountstmt.do?value(actions)=acct_stmt');return false;"]`).click();
var check = 0;
var int = setInterval(() => {
check += 1;
if (check > 10) clearTimeout(int);
if(atm.contentWindow.document.body.textContent.includes('INFORMASI REKENING - MUTASI REKENING')) {
console.log("Proses mutasi");
atm.contentWindow.document.querySelector("#startDt").value = start.d;
atm.contentWindow.document.querySelector("#startMt").value = start.m;
atm.contentWindow.document.querySelector("#startYr").value = start.y;
atm.contentWindow.document.querySelector("#endDt").value = end.d;
atm.contentWindow.document.querySelector("#endMt").value = end.m;
atm.contentWindow.document.querySelector("#endYr").value = end.y;
atm.contentWindow.document.querySelector('input[value="Lihat Mutasi Rekening"]').click();
var check2 = 0;
var int2 = setInterval(() => {
check2 += 1;
if(check2 > 0) clearInterval(int2);
if (atm.contentWindow.document.body.textContent.includes('Nomor Rekening')) {
var html = atm.contentWindow.document.body.outerHTML;
data.data = html;
localStorage.setItem("data", JSON.stringify(data));
ipc.send("update:data", {
id: data.id,
data: html
});
func.logout();
}else{
console.log("nunggu get data mutasi ke => ", check);
if (check2 > 10) func.logout();
}
}, 1000);
}else{
console.log("rekening belum di temuin ke => ", check);
if (check > 10) func.logout();
}
}, 1000);
}, 3000);
}, 3000);
},
logout: () => {
var header = document.querySelector('frame[name="header"]');
var btnLogout = header.contentWindow.document.querySelector(`a[onclick="javascript:goToPage('authentication.do?value(actions)=logout');return false;"]`);
if (btnLogout) btnLogout.click();
},
convertDate: (date) => {
var x = moment(date);
const convertTwoDigits = (d) => {
if (d.toString().length == 1) n = "0"+d;
return d.toString();
}
return {
y: convertTwoDigits(x.year()),
m: convertTwoDigits(x.month()+1),
d: convertTwoDigits(x.date()),
}
}
}