-
Notifications
You must be signed in to change notification settings - Fork 2
/
bgm_preview.html
49 lines (45 loc) · 1.46 KB
/
bgm_preview.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
<body>
<style>
html,
body {
height: 100vh;
}
body {
margin: 0;
display: flex;
flex-direction: column;
flex-wrap: wrap;
align-items: center;
justify-content: center;
background-color: black;
}
audio {
margin-top: 16px;
}
</style>
<script>
const params = new URL(location.href).searchParams;
const theme = params.get('theme');
const append = (parent, children) => { children.forEach(el => parent.appendChild(el)); return parent; }
const body = (...children) => append(document.body, children);
const element = (tagName, attrs, ...children) => append(Object.assign(document.createElement(tagName), attrs), children);
if (theme) {
body(
element('img', {
src: `https://raw.githubusercontent.com/OnionUI/Themes/main/themes/${encodeURIComponent(theme)}/preview.png`
}),
element('audio', {
controls: true,
autoplay: true,
src: `https://github.com/OnionUI/Themes/raw/main/themes/${encodeURIComponent(theme)}/sound/bgm.mp3`
})
)
} else {
body(
element('h1', {
textContent: "No theme found"
})
)
}
</script>
</body>