-
Notifications
You must be signed in to change notification settings - Fork 73
/
main.js
206 lines (197 loc) · 4.18 KB
/
main.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
var dedns = "38.175.197.10";
var nydns = "66.94.105.229";
var idkdns = "213.109.163.210";
var lastdns = "92.60.37.102";
document
.getElementById("ip1")
.value = dedns;
document
.getElementById("ip2")
.value = nydns;
document
.getElementById("ip3")
.value = idkdns;
document
.getElementById("ip4")
.value = lastdns;
/*
var proxysettings=document.getElementById("proxysettings");
var proxy=document.getElementById("proxy");
proxy.onchange=function (){
if (proxy.value!="direct"){
proxysettings.style.display="flex";
} else {
proxysettings.style.display="none";
}
}
*/
var advanced = document.getElementById("advanced");
advanced.addEventListener("animationend", () => {
advanced.style.animation = "none";
inprogress = false;
if (advanced.dataset.pos == "up") {
advanced.style.top = "0%";
document
.getElementById("advancedbutton")
.innerText = "Advanced -";
} else if (advanced.dataset.pos == "down") {
document
.getElementById("advancedbutton")
.innerText = "Advanced +";
advanced.style.top = "100%";
} else {
alert("error");
}
});
var inprogress = false;
function adv() {
if (inprogress == false) {
inprogress = true;
if (advanced.dataset.pos == "down") {
advanced.style.animation = "0.5s linear slideup";
advanced.dataset.pos = "up";
} else if (advanced.dataset.pos == "up") {
advanced.style.animation = "0.5s linear slidedown";
advanced.dataset.pos = "down";
} else {
alert("error");
}
}
}
document
.getElementById("button")
.style
.left = window.innerWidth / 2 - document
.getElementById("button")
.offsetWidth / 2 + "px";
document
.getElementById("credits")
.style
.left = window.innerWidth / 2 - document
.getElementById("credits")
.offsetWidth / 2 + "px";
async function load() {
var zip = new JSZip();
var onc = {
Type: "UnencryptedConfiguration",
NetworkConfigurations: []
};
var nameservers = [
document
.getElementById("ip1")
.value,
document
.getElementById("ip2")
.value,
document
.getElementById("ip3")
.value,
document
.getElementById("ip4")
.value
];
for (var i = 0; i < 4; i++) {
if (i == 0) {
if (nameservers[i] == "") {
nameservers[i] = dns;
}
}
if (nameservers[i] == "") {
nameservers[i] = "0.0.0.0";
}
}
var input = document.getElementById("input");
var network = JSON.parse(input.value);
if (!network.GUID || !network.Name || !network.WiFi) {
alert("please read the instructions carefully.");
} else {
let configuration = {
GUID: network.GUID,
Metered: document
.getElementById("caub")
.checked,
Name: network.Name,
Type: "WiFi",
WiFi: {
AutoConnect: true,
SSID: network.Name,
Security: "None"
},
NameServersConfigType: "Static",
StaticIPConfig: {
NameServers: nameservers
},
ProxySettings: {
Type: "Direct"
}
}
onc
.NetworkConfigurations
.push(configuration);
zip.file("kill.onc", JSON.stringify(onc));
var onc2 = {
Type: "UnencryptedConfiguration",
NetworkConfigurations: []
};
let configuration2 = {
GUID: network.GUID,
Metered: false,
Name: network.Name,
Type: "WiFi",
WiFi: {
AutoConnect: true,
SSID: network.Name,
Security: "None"
},
NameServersConfigType: "DHCP",
IPAddressConfigType: "DHCP",
StaticIPConfig: {
NameServers: []
},
ProxySettings: {
Type: "Direct"
}
}
onc2
.NetworkConfigurations
.push(configuration2);
zip.file("revive.onc", JSON.stringify(onc2));
zip
.generateAsync({type: "blob"})
.then(function (content) {
saveAs(content, "network.zip");
});
document
.getElementById("started")
.style
.display = "none";
document
.getElementById("input")
.style
.display = "none";
document
.getElementById("button")
.style
.display = "none";
document
.getElementById("finished")
.style
.display = "inline-block";
document
.getElementById("advanced")
.style
.display = "none";
document
.getElementById("advancedbutton")
.style
.display = "none";
}
}
function download(object, fileName) {
let link = document.createElement("a");
link.href = URL.createObjectURL(new Blob([JSON.stringify(object)]));
link.download = fileName;
link
.click()
.remove();
}