-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprivacy.html
49 lines (48 loc) · 1.83 KB
/
privacy.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
<!DOCTYPE html>
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<link href='/style.css' rel='stylesheet' type='text/css'>
<style>
body {
font-family: Consolas;
}
</style>
</head>
<body>
<div style="display: flex; justify-content: center; flex-direction: column; align-items: center;">
<div id="content">
Fetching
</div>
</div>
<script>
fetch("/privacy.txt").then(res => {
res.text().then(res => {
var links = []
const websiteRegex = /https?\:\/\/([^ ()\n\t]+(\/)?)/g
while ((match = websiteRegex.exec(res)) !== null) {
var replacement = `<a href="${match[0]}" target="_blank">${match[0]}</a>`
links.push({
absolute: replacement,
relative: match[0],
start: match.index,
end: websiteRegex.lastIndex
})
}
var length = 0
links.forEach(link => {
res = res.substring(0, link.start + length) + res.substring(link.end + length, res.length)
res = InsertString(link.absolute, link.start + length, res)
length += link.absolute.length - link.relative.length
})
res = res.replace(/\n/g, "<br>")
res = res.replace(/\t/g, "    ")
document.getElementById("content").innerHTML = res
})
})
function InsertString(toInsert, position, text) {
return [text.slice(0, position), toInsert, text.slice(position)].join('')
}
</script>
</body>
</html>