forked from gildas-lormeau/SingleFile-Archives
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
32 lines (28 loc) · 1.1 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Archives</title>
</head>
<body>
<script>
(async () => {
const response = await fetch(`https://api.github.com/repos/${location.hostname.match(/(.*)\.github\.io/)[1]}${location.pathname.match(/\/.*\//)[0]}contents/`);
const files = await response.json();
const listElement = document.createElement("ul");
for (const file of files) {
if (file.name != "index.html") {
const itemElement = document.createElement("li");
const linkElement = document.createElement("a");
linkElement.href = file.path;
linkElement.textContent = file.name;
linkElement.target = "_blank";
itemElement.appendChild(linkElement);
listElement.appendChild(itemElement);
}
}
document.body.appendChild(listElement);
})();
</script>
<body>
</html>