-
Notifications
You must be signed in to change notification settings - Fork 0
/
undata.htm
43 lines (42 loc) · 1.45 KB
/
undata.htm
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Undata</title>
<meta name="description" content="Give us a data URI. Get a page with a download link.">
<script>
let file = document.location.search.substring(1);
if (!file.startsWith("data:")) {
file = "";
}
const index = file.indexOf(";");
if (index < 0) {
file = "";
}
const mimeType = index < 0 ? "" : file.substring("data:".length, index);
function write(selector, text) {
const e = document.querySelector(selector);
if (typeof text === "object") {
for (const [k, v] of Object.entries(text)) {
e[k] = v;
}
} else {
e.innerText = text;
}
}
</script>
</head>
<body>
<h1>Undata</h1>
<p>Mime type: <span id="mimeType"></span></p>
<p>File length: <span id="fileLength"></span> characters.</p>
<p><a id="download" download="undata">DOWNLOAD</a></p>
<h2>WARNING: The file you are about to download could come from anyone and could contain any data. Download at your own risk.</h2>
<script>
write("#mimeType", mimeType);
write("#fileLength", file.length);
write("#download", { href: file, innerText: file === "" ? "INVALID FILE" : "DOWNLOAD" });
</script>
</body>
</html>