108 lines
No EOL
3.1 KiB
HTML
108 lines
No EOL
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Minecraft Twitch Chat Overlay</title>
|
|
<style>
|
|
/* Import Minecraft font */
|
|
@import url('https://fonts.googleapis.com/css2?family=Minecraft&display=swap');
|
|
|
|
body {
|
|
background-color: transparent;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#chat {
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 30%;
|
|
padding: 10px;
|
|
box-sizing: border-box;
|
|
overflow-y: auto;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: flex-end;
|
|
background-color: transparent;
|
|
}
|
|
|
|
.message {
|
|
font-family: 'Minecraft', sans-serif;
|
|
font-size: 16px;
|
|
color: white;
|
|
text-shadow: 2px 2px 0 #3f3f3f;
|
|
margin-bottom: 5px;
|
|
opacity: 0;
|
|
animation: fadeIn 0.5s ease-in-out forwards;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(10px);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
}
|
|
|
|
/* Fade out older messages */
|
|
.message.fade-out {
|
|
animation: fadeOut 0.5s ease-in-out forwards;
|
|
}
|
|
|
|
@keyframes fadeOut {
|
|
from {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
to {
|
|
opacity: 0;
|
|
transform: translateY(-10px);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="chat"></div>
|
|
<script>
|
|
// Extract the channel name from the URL
|
|
const channel = window.location.pathname.split('/')[2];
|
|
|
|
// Function to fetch chat messages
|
|
async function fetchChat() {
|
|
const response = await fetch(`/chat/${channel}`);
|
|
const data = await response.json();
|
|
const chat = document.getElementById('chat');
|
|
|
|
// Clear existing messages
|
|
chat.innerHTML = '';
|
|
|
|
// Add new messages with fade-in animation
|
|
data.messages.forEach((msg, index) => {
|
|
const messageElement = document.createElement('div');
|
|
messageElement.classList.add('message');
|
|
messageElement.textContent = msg;
|
|
|
|
// Fade out older messages if there are more than 10
|
|
if (data.messages.length > 10 && index < data.messages.length - 10) {
|
|
messageElement.classList.add('fade-out');
|
|
}
|
|
|
|
chat.appendChild(messageElement);
|
|
});
|
|
|
|
// Scroll to the bottom
|
|
chat.scrollTop = chat.scrollHeight;
|
|
}
|
|
|
|
// Fetch chat messages every second
|
|
setInterval(fetchChat, 1000);
|
|
</script>
|
|
</body>
|
|
</html> |