-
Notifications
You must be signed in to change notification settings - Fork 0
/
v.html
82 lines (68 loc) · 2.79 KB
/
v.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, viewport-fit=contain">
<title>ıllıllı a bad deed ıllıllı</title>
<link rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌀</text></svg>">
<script src="assets/ansi_up.js"></script>
<script>
async function loadContent(filename) {
const file = await fetch(filename);
if (file.status !== 200) {
return await loadContent('notfound');
}
const content = document.getElementById('content');
const fileContents = await file.text();
content.innerHTML = formatContent(fileContents);
window.location.hash = filename;
}
function formatContent(content) {
const nothing = '';
// clean website specific stuff
content = content.replace(/<script>.*<\/script>/ig, nothing);
content = content.replace(/<style>.*<\/style>/ig, nothing);
content = content.replace(/<!--.*-->/ig, nothing);
// render that sweet ANSI baby
content = new AnsiUp().ansi_to_html(content);
content = content.replace(/http(s?):\/\/([^\s]+)/ig, hyperlink);
content = content.replace(/\n/g, '<br>');
return content;
}
function makeExternalLink(match) {
return `<a href="${match}" rel="noopener noreferrer" target="_blank">${match}</a>`
}
function makeInternalLink(match, currentDomain) {
const localPath = match.split(currentDomain)[1].substr(1);
return `<a href="${currentDomain}/v.html#${localPath}">${localPath}</a>`
}
function startsWith(value, start) {
return value.substring(0, start.length) === start;
}
function hyperlink(rawLink) {
const domain = window.location.origin;
return startsWith(rawLink, domain) ?
makeInternalLink(rawLink, domain) :
makeExternalLink(rawLink);
}
function extractHashFromUrl(url) {
return url.split('#')[1];
}
window.addEventListener('DOMContentLoaded', () => {
const destination = extractHashFromUrl(window.location.hash) || 'index.html';
return loadContent(destination);
});
window.addEventListener('hashchange', ({newURL}) => {
loadContent(extractHashFromUrl(newURL));
});
</script>
<link rel="stylesheet" href="assets/0xdeadbeef.css">
</head>
<body>
<div align="center">
<pre id="content"></pre>
</div>
<a rel="me" href="https://infosec.exchange/@device"></a>
</body>
</html>