whoopsie x@

This commit is contained in:
Lain Iwakura 2025-06-16 03:16:50 +03:00
parent 183d432ef1
commit 69869073ab
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8

View File

@ -147,13 +147,26 @@ try {
</div> </div>
<script> <script>
let isScrolledToBottom = true;
const messagesContainer = document.getElementById('messages');
messagesContainer.addEventListener('scroll', () => {
const { scrollTop, scrollHeight, clientHeight } = messagesContainer;
isScrolledToBottom = Math.abs(scrollHeight - clientHeight - scrollTop) < 1;
});
setInterval(() => { setInterval(() => {
fetch(window.location.href) fetch(window.location.href)
.then(response => response.text()) .then(response => response.text())
.then(html => { .then(html => {
const parser = new DOMParser(); const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html'); const doc = parser.parseFromString(html, 'text/html');
document.getElementById('messages').innerHTML = doc.getElementById('messages').innerHTML; const oldHeight = messagesContainer.scrollHeight;
messagesContainer.innerHTML = doc.getElementById('messages').innerHTML;
if (isScrolledToBottom) {
window.scrollTo(0, document.body.scrollHeight);
}
}); });
}, 5000); }, 5000);
</script> </script>