forked from amanraox/share-bits-wirelessly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdl.html
30 lines (29 loc) · 1.1 KB
/
dl.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
<!DOCTYPE html>
<html>
<!-- Made by Aman Umrao -->
<body>
<script>
function downloadBase64File(base64Data, filename) {
const ascii = atob(base64Data);
const bytes = new Array(ascii.length);
for (let i = 0; i < ascii.length; i++) {
bytes[i] = ascii.charCodeAt(i);
}
const byteArray = new Uint8Array(bytes);
const blob = new Blob([byteArray], { type: "application/octet-stream" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = filename;
// :P
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
const params = new URLSearchParams(window.location.search);
// use fragment so data not sent to server, idea: @[email protected] and @amanraox.com
const data = window.location.hash.substring(1);
const filename = params.get("f");
downloadBase64File(decodeURIComponent(data), filename);
</script>
</body>
</html>