-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (62 loc) · 2.14 KB
/
index.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const { ipcRenderer } = require('electron');
const fs = require('fs');
//buttons
const followBtn = document.getElementById('followBtn');
const unfollowBtn = document.getElementById('unfollowBtn');
//inputs
const username = document.getElementById('username');
const password = document.getElementById('password');
const followTarget = document.getElementById('followTarget');
const followAmount = document.getElementById('followAmount');
const unfollowAmount = document.getElementById('unfollowAmount');
const checkbox = document.getElementById('checkbox');
let userData = JSON.parse(fs.readFileSync('./resources/userData/data.json'));
//fill
username.value = userData.username;
password.value = userData.password;
followTarget.value = userData.followTarget;
followAmount.value = userData.followAmount;
unfollowAmount.value = userData.unfollowAmount;
let Data = {
action: "",
username: "",
password: "",
followTarget: "",
amount: ""
};
function saveData() {
if (checkbox.checked) {
var newUserData = {
"username": username.value,
"password": password.value ,
"followTarget": followTarget.value ,
"followAmount": followAmount.value ,
"unfollowAmount": unfollowAmount.value
}
fs.writeFile('./resources/userData/data.json', JSON.stringify(newUserData, null, 2), () => console.log('Saved user data.'));
}
}
followBtn.addEventListener("click", () => {
saveData();
console.log("Running Follow");
Data = {
action: "follow",
username: username.value,
password: password.value,
followTarget: followTarget.value,
amount: followAmount.value
};
ipcRenderer.send('request-mainprocess-action', Data);
});
unfollowBtn.addEventListener("click", () => {
saveData();
console.log("Running Unfollow");
Data = {
action: "unfollow",
username: username.value,
password: password.value,
followTarget: username.value,
amount: unfollowAmount.value
}
ipcRenderer.send('request-mainprocess-action', Data);
});