-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
41 lines (41 loc) · 1.6 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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="js/tmi.min.js"></script>
<script src="js/purify.min.js"></script>
<!-- <link rel="stylesheet" href="configs/config.css"> -->
<script type="module">
const configs = {
default: {
css: './configs/config.default.css',
js: './configs/config.default.js',
},
rl: {
css: './configs/config.rocketleague.css',
js: './configs/config.rocketleague.js',
}
}
const urlParams = new URLSearchParams(window.location.search);
const config = (urlParams.get('config')) || 'default';
const head = document.getElementsByTagName("head")[0];
const styleConfig = { rel: "stylesheet", type: "text/css", href: configs[config].css };
const stylesheet = head.appendChild(Object.assign(document.createElement('link'),styleConfig));
import(configs[config].js).then(({default: Config})=>{
const chat = document.querySelector('#chat');
const conf = new Config(urlParams.get('users'), urlParams.get('max'), chat);
const users = conf.getUsers();
chat.innerHTML = `Loading messages from ${users.join(', ')}`;
const client = new tmi.Client({ connection: { secure: true, reconnect: true }, channels: users });
client.connect();
client.on('message', (channel, tags, message, self) => {
conf.logicMessage(tags.username, message);
});
}).catch(error=>console.log(error));
</script>
</head>
<body>
<div id="chat"></div>
</body>
</html>