-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathindex.html
115 lines (105 loc) · 2.83 KB
/
index.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
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>URL Pages</title>
<meta
name="description"
content="Create and view web pages stored entirely in the URL"
/>
<link rel="shortcut icon" href="favicon.ico" />
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
html,
body {
border: 0;
width: 100vw;
width: 100dvw;
height: 100vh;
height: 100dvh;
}
body {
display: flex;
flex-direction: column;
align-items: center;
}
iframe {
border: 1px solid black;
width: 100%;
height: 100%;
display: none;
}
.warning {
padding: 0.5em;
margin: 0.5em;
font-family: sans-serif;
border: 2px solid red;
max-width: 80ch;
display: flex;
flex-direction: column;
gap: 0.5em;
}
#run {
border: 1px solid black;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
button {
cursor: pointer;
user-select: none;
-webkit-user-select: none;
padding: 0.5em 1em;
}
</style>
</head>
<body>
<noscript>
JavaScript is required to convert the URL into a usable web page.
</noscript>
<div class="warning">
<p>
The page below may be malicious. For example, it could be a phishing
page to steal your data, or it could try to download dangerous code onto
your computer. Do not load the page below unless you trust the person
who sent you the link.
</p>
<p>Do not enter any personal information into the page below.</p>
</div>
<iframe id="frame"></iframe>
<div id="run">
<button onclick="runCode()">Load page</button>
</div>
<script type="text/javascript" src="b64.js"></script>
<script type="text/javascript" src="api.js"></script>
<script type="text/javascript">
function write(html) {
window.frames[0].location.replace(
`data:text/html;charset=utf-8;base64,${b64.encode(html)}`,
);
}
if (!window.location.hash) {
window.location.replace("./editor/");
}
function runCode() {
document.getElementById("frame").style.display = "block";
document.getElementById("run").remove();
var hash = window.location.hash.slice(1);
var data = b64.decode(hash);
try {
var urlDataObject = JSON.parse(data);
var api = apiVersions[urlDataObject.version];
write(api.decode(urlDataObject));
} catch (err) {
write(decodeURIComponent(data));
}
}
</script>
</body>
</html>