mirror of
https://git.sr.ht/~iwakuralain/text0Nly
synced 2025-07-27 15:36:11 +00:00
whoopsie x@
This commit is contained in:
parent
183d432ef1
commit
69869073ab
@ -147,13 +147,26 @@ try {
|
||||
</div>
|
||||
|
||||
<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(() => {
|
||||
fetch(window.location.href)
|
||||
.then(response => response.text())
|
||||
.then(html => {
|
||||
const parser = new DOMParser();
|
||||
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);
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user