-
Notifications
You must be signed in to change notification settings - Fork 1
/
caub.html
335 lines (315 loc) · 13.2 KB
/
caub.html
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Caub + DNS</title>
<style>
* {
background-color: black;
color: rgb(196, 196, 196);
}
body {
background-color: black;
font-family: monospace;
font-size: 15px;
margin: 35px;
margin-top: 5px;
}
a {
color: cyan;
}
input, button {
background-color: #131313;
border: #0a0a0a;
border-width: 3px;
border-radius: 3px;
border-style: solid;
margin: 1.4px;
cursor: pointer;
}
.list {
line-height: 1.8;
}
.border {
border: 2px solid white;
padding: 5px;
}
.wrapper {
margin: 0 auto;
}
.block1 {
float: left;
}
.block2 {
float: right;
}
code {
background-color: #131313;
border-radius: 5px;
color: rgb(168, 92, 255);
}
#logBox {
font-size: 12px;
color: white;
background-color: black; /* Changed to black */
padding: 5px;
border: 2px solid #0a0a0a;
margin-top: 5px; /* Adjusted to move it higher */
max-height: 180px;
top:-30px !important;
max-width: 570px;
overflow-y: auto;
overflow-x: auto;
position:relative;
}
.timestamp {
color: #888;
font-weight: bold;
user-select: none; /* Prevents selection */
}
.timestamp-colon {
user-select: none; /* Prevents selection */
}
.error {
color: #ff3d51;
}
.info {
color: #a8aaff; /* For info messages, or any color you choose */
}
.no-select {
user-select: none; /* Prevents selection */
}
</style>
</head>
<body>
<div class="wrapper">
<div class="block1">
<h1>Caub + DNS + Proxy editor</h1>
<input id="meteredToggle" type="checkbox" checked>enable metered (update blocker)</input>
<br>
<input id="dnsEnabled" type="checkbox">edit dns</input> <code>(OmadaDNS on the side)</code>
<br>
<input type="text" id="dns1" placeholder="Enter IP..." /> <code>(167.86.91.171)</code>
<br>
<input type="text" id="dns2" placeholder="Enter IP..." /> <code>(66.94.105.229)</code>
<br>
<input type="text" id="dns3" placeholder="Enter IP..." /> <code>(213.109.163.210)</code>
<br>
<input type="text" id="dns4" placeholder="Enter IP..." /> <code>(92.60.37.102)</code>
<br>
<br>
<input id="proxyEnabled" type="checkbox">edit proxy</input>
<br>
<br>
ftp proxy <input type="text" id="ftpProxy" placeholder="socks4://localhost" /><input value="1080" type="number" id="ftpProxyPort"></input>
<br>
HTTP proxy <input type="text" id="httpProxy" placeholder="socks4://localhost" /><input value="1080" type="number" id="httpProxyPort"></input>
<br>
secure HTTPS proxy <input type="text" id="secureHttpProxy" placeholder="socks4://localhost" /><input value="1080" type="number" id="secureHttpProxyPort"></input>
<br>
socks host <input type="text" id="socks" placeholder="localhost" /><input value="1080" type="number" id="socksProxyPort"></input>
<br>
domains to exclude as json array <input type="text" value="[]" id="excludeDomains" />
<br>
example:
<code style="margin-bottom: 60px;">["*.com", "google.com"]</code>
</div>
<div class="block2">
<h1>Instructions</h1>
<div class="list">
1. Edit the settings above<br>
2. Go to <code>chrome://network#state</code><br>
3. Scroll to <code>"Favourite Networks"</code><br>
4. Find the wifi network that you are currently connected to<br>
5. Click the <code>+</code> next to the wifi name<br>
6. Copy all the data that appears (the <code>{}</code> curly braces)<br>
7. Paste the data into the box below and press the generate button<br>
8. Click the <code>+</code> under the box to add multiple networks<br>
</div>
<br>
<input class="inputData" placeholder="read instructions" />
<div id="extraInputs"></div>
<button onclick="addInput()">+</button>
<button onclick="removeInput()">-</button>
<br>
<button onclick="generateONC()" style="color:rgb(168, 92, 255)">Generate ONC file</button>
<button onclick="downloadONC()" style="margin-bottom: 60px; color: rgb(68, 255, 124);">Download ONC file</button>
<button onclick="copyLog()" style="color:#a8aaff">Copy Log</button>
<br>
<div id="logBox" class="border">
<strong>Log:</strong>
<pre id="logContent"></pre>
</div>
<br>
</div>
</div>
<div class="block3">
<h1> </h1>
<br>
<h1 style="margin-top: 370px;">Importing the ONC file</h1>
<div class="list">
Once you have downloaded the file, go to <code>chrome://network#general</code><br>
Scroll to the bottom and click <code>"Import ONC"</code><br>
Open the downloaded file, it should say <code>"Networks imported: 1"</code><br>
Your network should be configured now.
</div>
</div>
<script>
let oncData = null; // Store ONC data for download
function logMessage(message, type = 'info') {
const logContent = document.querySelector("#logContent");
const time = new Date();
const timeString = time.toISOString().slice(11, 23).replace('T', ' '); // hh:mm:ss:ms
const className = type === 'error' ? 'error' : 'info'; // Default to 'info' if not 'error'
logContent.innerHTML += `<span class="timestamp">${timeString}<span class="timestamp-colon">:</span></span> <span class="${className}">${message}</span>\n`;
logContent.scrollTop = logContent.scrollHeight; // Auto-scroll to the latest log
}
function addInput() {
logMessage("Added new input field.");
document.querySelector("#extraInputs").innerHTML += `<input type="text" class="inputData" />`;
}
function removeInput() {
if (document.querySelector("#extraInputs").lastChild) {
logMessage("Removed last input field.");
document.querySelector("#extraInputs").lastChild.remove();
}
}
function generateONC() {
logMessage("Generation started");
let inputDataElements = document.querySelectorAll(".inputData");
let onc = { Type: "UnencryptedConfiguration", NetworkConfigurations: [] };
inputDataElements.forEach(inputDataElement => {
try {
logMessage(`Checking input field: ${inputDataElement.id}`);
let network = JSON.parse(inputDataElement.value);
if (!network.GUID || !network.Name || !network.WiFi) {
throw new Error("Invalid network data");
}
logMessage(`Valid network data found: GUID=${network.GUID}, Name=${network.Name}`);
let configuration = {
GUID: network.GUID,
Metered: document.querySelector("#meteredToggle").checked,
Name: network.Name,
Type: "WiFi",
WiFi: {
AutoConnect: true,
SSID: network.Name,
Security: "None",
},
};
// Logging DNS settings
if (document.querySelector("#dnsEnabled").checked) {
logMessage("DNS Edit enabled. Configuring DNS settings.");
let nameServers = [];
["#dns1", "#dns2", "#dns3", "#dns4"].forEach(dnsSelector => {
let element = document.querySelector(dnsSelector);
nameServers.push(element.value === "" ? "0.0.0.0" : element.value);
});
logMessage(`DNS Servers: ${nameServers.join(", ")}`);
configuration.NameServersConfigType = "Static";
configuration.StaticIPConfig = {
NameServers: nameServers
};
} else {
logMessage("DNS Edit disabled.");
configuration.NameServersConfigType = "DHCP";
}
// Logging Proxy settings
if (document.querySelector("#proxyEnabled").checked) {
logMessage("Proxy Edit enabled. Configuring proxy settings.");
let parsedExcludeList;
try {
parsedExcludeList = JSON.parse(document.querySelector("#excludeDomains").value);
logMessage(`Exclude Domains: ${JSON.stringify(parsedExcludeList)}`);
} catch (e) {
logMessage("Failed to parse exclude domains list for proxy", 'error');
parsedExcludeList = [];
}
configuration.ProxySettings = {
ExcludeDomains: parsedExcludeList,
Manual: {
FTPProxy: {
Host: document.querySelector("#ftpProxy").value,
Port: parseInt(document.querySelector("#ftpProxyPort").value)
},
HTTPProxy: {
Host: document.querySelector("#httpProxy").value,
Port: parseInt(document.querySelector("#httpProxyPort").value)
},
SOCKS: {
Host: document.querySelector("#socks").value,
Port: parseInt(document.querySelector("#socksProxyPort").value)
},
SecureHTTPProxy: {
Host: document.querySelector("#secureHttpProxy").value,
Port: parseInt(document.querySelector("#secureHttpProxyPort").value)
}
},
Type: "Manual"
};
} else {
logMessage("Proxy Edit disabled.");
configuration.ProxySettings = {
Type: "Direct"
};
}
onc.NetworkConfigurations.push(configuration);
inputDataElement.style.borderColor = "lime";
logMessage(`Configuration added for network: ${network.Name}`);
} catch (error) {
console.error(error);
inputDataElement.style.borderColor = "red";
logMessage(`Error processing input: ${error.message}`, 'error');
}
});
if (onc.NetworkConfigurations[0]) {
oncData = onc;
logMessage("ONC file generation complete. Ready for download.");
} else {
logMessage("No valid configurations found.");
}
}
function downloadONC() {
if (oncData) {
logMessage("Downloading ONC file...");
let link = document.createElement("a");
link.href = URL.createObjectURL(new Blob([JSON.stringify(oncData)]));
link.download = "network.onc";
link.click();
link.remove();
logMessage("ONC file download triggered.");
} else {
logMessage("No ONC data available for download. Please generate ONC file first.", 'error');
}
}
function copyLog() {
const logContent = document.querySelector("#logContent").textContent;
navigator.clipboard.writeText(logContent).then(() => {
logMessage("Log copied to clipboard.");
}).catch(err => {
logMessage("Failed to copy log to clipboard.", 'error');
});
}
document.querySelector("#meteredToggle").addEventListener('change', function() {
logMessage(`Metered Toggle ${this.checked ? 'enabled' : 'disabled'}`);
});
document.querySelector("#dnsEnabled").addEventListener('change', function() {
logMessage(`DNS Edit ${this.checked ? 'enabled' : 'disabled'}`);
});
document.querySelector("#proxyEnabled").addEventListener('change', function() {
logMessage(`Proxy Edit ${this.checked ? 'enabled' : 'disabled'}`);
});
document.querySelectorAll("input[type='text'], input[type='number']").forEach(input => {
input.addEventListener('change', function() {
logMessage(`Input changed: ${this.id} = ${this.value}`);
});
});
document.querySelectorAll("input[type='checkbox']").forEach(checkbox => {
checkbox.addEventListener('change', function() {
logMessage(`Checkbox changed: ${this.id} = ${this.checked}`);
});
});
</script>
</body>
</html>