2023-09-15 00:33:08 +00:00
|
|
|
function formatDate(d) {
|
|
|
|
const hour = ("0" + d.getHours()).slice(-2);
|
|
|
|
const minute = ("0" + d.getMinutes()).slice(-2);
|
|
|
|
const second = ("0" + d.getSeconds()).slice(-2);
|
|
|
|
return hour + ":" + minute + ":" + second;
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-15 00:33:08 +00:00
|
|
|
for (const e of timestamps) {
|
|
|
|
e.innerHTML = formatDate(new Date(e.dataset.time*1000));
|
|
|
|
};
|
|
|
|
|
2023-01-21 10:36:21 +00:00
|
|
|
const ua=window.navigator.userAgent
|
|
|
|
let socket
|
|
|
|
|
|
|
|
socket=io()
|
|
|
|
|
|
|
|
const chatline = document.getElementsByClassName('chat-line')[0]
|
|
|
|
const box = document.getElementById('chat-window')
|
2023-03-04 23:07:05 +00:00
|
|
|
const ta = document.getElementById('input-text')
|
2023-01-22 02:43:28 +00:00
|
|
|
const icon = document.querySelector("link[rel~='icon']")
|
|
|
|
|
2023-01-21 10:36:21 +00:00
|
|
|
const vid = document.getElementById('vid').value
|
|
|
|
const site_name = document.getElementById('site_name').value
|
|
|
|
const slurreplacer = document.getElementById('slurreplacer').value
|
|
|
|
|
|
|
|
let notifs = 0;
|
|
|
|
let focused = true;
|
|
|
|
let is_typing = false;
|
|
|
|
let alert=true;
|
|
|
|
|
|
|
|
function flash(){
|
|
|
|
let title = document.getElementsByTagName('title')[0]
|
|
|
|
if (notifs >= 1 && !focused){
|
2023-09-24 22:12:42 +00:00
|
|
|
title.innerHTML = `[+${notifs}] Chat`;
|
2023-01-21 10:36:21 +00:00
|
|
|
if (alert) {
|
2023-01-22 02:43:28 +00:00
|
|
|
icon.href = `/i/${site_name}/alert.ico?v=3009`
|
2023-01-21 10:36:21 +00:00
|
|
|
alert=false;
|
|
|
|
}
|
|
|
|
else {
|
2023-06-29 20:14:30 +00:00
|
|
|
icon.href = `/i/${site_name}/icon.webp?x=6`
|
2023-01-21 10:36:21 +00:00
|
|
|
alert=true;
|
|
|
|
}
|
|
|
|
setTimeout(flash, 500)
|
|
|
|
}
|
|
|
|
else {
|
2023-06-29 20:14:30 +00:00
|
|
|
icon.href = `/i/${site_name}/icon.webp?x=6`
|
2023-01-21 10:36:21 +00:00
|
|
|
notifs = 0
|
2023-09-24 22:12:42 +00:00
|
|
|
title.innerHTML = 'Chat';
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_typing) {
|
|
|
|
is_typing = false
|
|
|
|
socket.emit('typing', false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-08-11 16:40:28 +00:00
|
|
|
const blocked_user_ids = document.getElementById('blocked_user_ids').value.split(', ')
|
2023-08-09 15:19:43 +00:00
|
|
|
|
2023-01-22 02:43:28 +00:00
|
|
|
socket.on('speak', function(json) {
|
2023-08-09 15:19:43 +00:00
|
|
|
if (blocked_user_ids.includes(json.user_id.toString())) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-08-01 06:43:32 +00:00
|
|
|
let text
|
2023-01-21 10:36:21 +00:00
|
|
|
let text_html
|
|
|
|
|
2023-08-01 06:43:32 +00:00
|
|
|
if (slurreplacer != '0') {
|
2023-08-09 15:19:32 +00:00
|
|
|
text = json.text_censored
|
|
|
|
text_html = json.text_html_censored
|
2023-08-01 06:43:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2023-08-09 15:19:32 +00:00
|
|
|
text = json.text
|
|
|
|
text_html = json.text_html
|
2023-08-01 06:43:32 +00:00
|
|
|
}
|
2023-01-21 10:36:21 +00:00
|
|
|
|
2023-01-22 05:30:57 +00:00
|
|
|
chatline.classList.remove('chat-mention');
|
2023-08-20 15:57:31 +00:00
|
|
|
if (text_html.includes(`<a href="/id/${vid}"`)){
|
2023-01-21 10:36:21 +00:00
|
|
|
chatline.classList.add('chat-mention');
|
|
|
|
}
|
|
|
|
|
|
|
|
notifs = notifs + 1;
|
|
|
|
if (notifs == 1) {
|
|
|
|
setTimeout(flash, 500);
|
|
|
|
}
|
|
|
|
|
2023-01-22 05:30:57 +00:00
|
|
|
const users = document.getElementsByClassName('user_id');
|
|
|
|
const last_user = users[users.length-1].value;
|
2023-01-21 10:36:21 +00:00
|
|
|
const scrolled_down = (box.scrollHeight - box.scrollTop <= window.innerHeight)
|
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
if (last_user != json.user_id) {
|
|
|
|
document.getElementsByClassName('avatar-pic')[0].src = '/pp/' + json.user_id
|
2023-01-22 02:43:28 +00:00
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
if (json.hat)
|
|
|
|
document.getElementsByClassName('avatar-hat')[0].src = json.hat + "?h=7"
|
2023-01-21 10:36:21 +00:00
|
|
|
else
|
|
|
|
document.getElementsByClassName('avatar-hat')[0].removeAttribute("src")
|
|
|
|
|
2023-01-25 03:30:08 +00:00
|
|
|
const userlink = document.getElementsByClassName('userlink')[0]
|
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
userlink.href = '/@' + json.username
|
|
|
|
userlink.style.color = '#' + json.namecolor
|
2023-01-22 02:43:28 +00:00
|
|
|
|
2023-08-14 12:26:42 +00:00
|
|
|
const username = document.getElementsByClassName('username')[0]
|
|
|
|
username.textContent = json.username
|
|
|
|
if (json.patron) {
|
|
|
|
username.classList.add('patron')
|
|
|
|
username.style.backgroundColor = '#' + json.namecolor
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
username.classList.remove('patron')
|
|
|
|
username.style.backgroundColor = null
|
|
|
|
}
|
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
document.getElementsByClassName('user_id')[0].value = json.user_id
|
2023-01-22 05:30:57 +00:00
|
|
|
|
2023-09-15 00:33:08 +00:00
|
|
|
document.getElementsByClassName('time')[0].innerHTML = formatDate(new Date(json.time*1000))
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
document.getElementsByClassName('chat-line')[0].id = json.id
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementsByClassName('text')[0].innerHTML = escapeHTML(text)
|
2023-08-24 02:17:58 +00:00
|
|
|
document.getElementsByClassName('chat-message')[0].innerHTML = text_html.replace(/data-src/g, 'src').replace(/data-cfsrc/g, 'src').replace(/style="display:none;visibility:hidden;"/g, '').replace(/ loading="lazy"/g, '')
|
2023-01-21 10:36:21 +00:00
|
|
|
|
2023-01-21 23:19:46 +00:00
|
|
|
document.getElementsByClassName('quotes')[0].classList.add("d-none")
|
2023-08-09 15:19:32 +00:00
|
|
|
if (json.quotes) {
|
|
|
|
const quoted = document.getElementById(json.quotes)
|
2023-01-21 23:19:46 +00:00
|
|
|
if (quoted) {
|
2023-01-22 05:30:57 +00:00
|
|
|
const quoted_user = quoted.parentElement.querySelector('.user_id').value
|
|
|
|
if (quoted_user == vid){
|
|
|
|
chatline.classList.add('chat-mention');
|
|
|
|
}
|
2023-01-21 23:19:46 +00:00
|
|
|
document.getElementsByClassName('quotes')[0].classList.remove("d-none")
|
2023-08-09 15:19:32 +00:00
|
|
|
document.getElementsByClassName('QuotedMessageLink')[0].href = '#' + json.quotes
|
2023-01-25 03:30:08 +00:00
|
|
|
document.getElementsByClassName('QuotedUser')[0].innerHTML = quoted.parentElement.querySelector('.userlink').textContent
|
2023-01-21 23:19:46 +00:00
|
|
|
document.getElementsByClassName('QuotedMessage')[0].innerHTML = quoted.querySelector('.text').innerHTML
|
|
|
|
}
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let line = document.getElementsByClassName('chat-line')[0].cloneNode(true)
|
2023-02-18 21:45:37 +00:00
|
|
|
register_new_elements(line);
|
|
|
|
bs_trigger(line)
|
2023-08-09 15:19:32 +00:00
|
|
|
if (last_user == json.user_id) {
|
2023-01-21 10:36:21 +00:00
|
|
|
box.querySelector('.chat-group:last-child').append(line)
|
|
|
|
}
|
|
|
|
else {
|
2023-01-22 02:43:28 +00:00
|
|
|
const chatgroup = document.getElementsByClassName('chat-group')[0].cloneNode(true)
|
2023-01-21 10:36:21 +00:00
|
|
|
chatgroup.append(line)
|
|
|
|
box.append(chatgroup)
|
|
|
|
}
|
|
|
|
|
2023-08-09 15:19:32 +00:00
|
|
|
const line2 = document.getElementById(json.id)
|
2023-02-18 16:08:48 +00:00
|
|
|
register_new_elements(line2);
|
|
|
|
bs_trigger(line2)
|
|
|
|
|
2023-08-20 17:03:20 +00:00
|
|
|
if (scrolled_down || json.user_id == vid) {
|
2023-01-21 10:36:21 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
2023-08-20 17:03:20 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 200);
|
2023-08-20 19:31:06 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 500);
|
2023-08-20 17:03:20 +00:00
|
|
|
}
|
2023-01-21 10:36:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
function send() {
|
2023-03-04 23:07:05 +00:00
|
|
|
const text = ta.value.trim();
|
2023-02-27 15:02:35 +00:00
|
|
|
const input = document.getElementById('file');
|
|
|
|
const files = input.files;
|
2023-01-21 10:36:21 +00:00
|
|
|
if (text || files)
|
|
|
|
{
|
|
|
|
let sending;
|
|
|
|
if (files[0]) sending = files[0]
|
|
|
|
else sending = ''
|
|
|
|
socket.emit('speak', {
|
|
|
|
"message": text,
|
|
|
|
"quotes": document.getElementById('quotes_id').value,
|
|
|
|
"file": sending,
|
|
|
|
});
|
2023-03-04 23:07:05 +00:00
|
|
|
ta.value = ''
|
2023-01-21 10:36:21 +00:00
|
|
|
is_typing = false
|
|
|
|
socket.emit('typing', false);
|
2023-03-04 23:07:05 +00:00
|
|
|
autoExpand(ta);
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementById("quotes").classList.add("d-none")
|
2023-01-21 11:05:58 +00:00
|
|
|
document.getElementById('quotes_id').value = null;
|
2023-08-08 10:52:07 +00:00
|
|
|
oldfiles[ta.id] = new DataTransfer();
|
2023-02-27 15:02:35 +00:00
|
|
|
input.value = null;
|
2023-03-06 18:02:12 +00:00
|
|
|
input.previousElementSibling.innerHTML = '<i class="fas fa-image" style="font-size:1.3rem!important"></i>'
|
2023-02-27 15:02:35 +00:00
|
|
|
|
2023-01-21 11:58:10 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight);
|
2023-03-10 03:21:02 +00:00
|
|
|
setTimeout(function () {
|
2023-01-21 11:58:10 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 200);
|
2023-08-20 19:31:06 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 500);
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function quote(t) {
|
|
|
|
document.getElementById("quotes").classList.remove("d-none")
|
|
|
|
|
2023-02-10 13:44:47 +00:00
|
|
|
const text = t.parentElement.parentElement.getElementsByClassName("text")[0].innerHTML.replace(/\*/g,"\\*").split('\n').pop()
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementById('QuotedMessage').innerHTML = text
|
|
|
|
|
2023-02-10 13:44:47 +00:00
|
|
|
const username = t.parentElement.parentElement.parentElement.parentElement.parentElement.getElementsByClassName('userlink')[0].textContent
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementById('QuotedUser').innerHTML = username
|
|
|
|
|
2023-02-10 13:44:47 +00:00
|
|
|
const id = t.parentElement.parentElement.parentElement.parentElement.id
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementById('quotes_id').value = id
|
|
|
|
document.getElementById('QuotedMessageLink').href = `#${id}`
|
2023-01-21 11:05:58 +00:00
|
|
|
|
2023-03-04 23:07:05 +00:00
|
|
|
ta.focus()
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-04 19:47:50 +00:00
|
|
|
ta.addEventListener("keydown", function(e) {
|
2023-08-02 07:53:26 +00:00
|
|
|
if (e.key === 'Enter' && !current_word) {
|
2023-01-21 10:36:21 +00:00
|
|
|
e.preventDefault();
|
|
|
|
send();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
socket.on('online', function(data){
|
2023-01-23 06:04:02 +00:00
|
|
|
document.getElementsByClassName('board-chat-count')[0].innerHTML = data[0].length
|
2023-09-13 23:21:46 +00:00
|
|
|
document.getElementById('chat-count-header-bar').innerHTML = data[0].length
|
2023-01-24 05:28:56 +00:00
|
|
|
const admin_level = parseInt(document.getElementById('admin_level').value)
|
2023-01-21 10:36:21 +00:00
|
|
|
let online = ''
|
|
|
|
let online2 = '<b>Users Online</b>'
|
2023-01-23 06:04:02 +00:00
|
|
|
for (const u of data[0])
|
2023-01-21 10:36:21 +00:00
|
|
|
{
|
2023-08-14 12:26:42 +00:00
|
|
|
let patron = ''
|
|
|
|
if (u[3])
|
|
|
|
patron = ` class="patron" style="background-color:#${u[2]}"`
|
|
|
|
|
2023-01-23 06:04:02 +00:00
|
|
|
online += `<li>`
|
2023-01-27 17:52:47 +00:00
|
|
|
if (admin_level && Object.keys(data[1]).includes(u[0].toLowerCase()))
|
2023-01-23 06:04:02 +00:00
|
|
|
online += '<b class="text-danger muted" data-bs-toggle="tooltip" title="Muted">X</b> '
|
2023-08-14 12:26:42 +00:00
|
|
|
online += `<a class="font-weight-bold" target="_blank" href="/@${u[0]}" style="color:#${u[2]}"><img loading="lazy" class="mr-1" src="/pp/${u[1]}"><span${patron}>${u[0]}</span></a></li>`
|
2023-01-27 17:52:47 +00:00
|
|
|
online2 += `<br>@${u[0]}`
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
2023-08-24 01:32:09 +00:00
|
|
|
|
|
|
|
const online_el = document.getElementById('online')
|
2023-08-24 01:33:15 +00:00
|
|
|
if (online_el) {
|
2023-08-24 01:32:09 +00:00
|
|
|
online_el.innerHTML = online
|
|
|
|
bs_trigger(online_el)
|
|
|
|
}
|
|
|
|
|
2023-01-21 10:36:21 +00:00
|
|
|
document.getElementById('online2').setAttribute("data-bs-original-title", online2);
|
|
|
|
document.getElementById('online3').innerHTML = online
|
2023-01-23 06:04:02 +00:00
|
|
|
bs_trigger(document.getElementById('online3'))
|
2023-01-21 10:36:21 +00:00
|
|
|
})
|
|
|
|
|
2023-08-03 13:50:33 +00:00
|
|
|
addEventListener('blur', function(){
|
2023-08-23 21:57:39 +00:00
|
|
|
focused = false
|
2023-01-21 10:36:21 +00:00
|
|
|
})
|
2023-08-03 13:50:33 +00:00
|
|
|
addEventListener('focus', function(){
|
2023-08-23 21:57:39 +00:00
|
|
|
focused = true
|
2023-01-21 10:36:21 +00:00
|
|
|
})
|
|
|
|
|
2023-08-08 17:23:29 +00:00
|
|
|
let timer_id;
|
|
|
|
function remove_typing() {
|
|
|
|
is_typing = false;
|
|
|
|
socket.emit('typing', false);
|
|
|
|
}
|
2023-01-21 10:36:21 +00:00
|
|
|
|
2023-03-10 03:21:02 +00:00
|
|
|
ta.addEventListener("input", function() {
|
2023-08-08 17:23:29 +00:00
|
|
|
clearTimeout(timer_id)
|
|
|
|
|
2023-03-04 23:07:05 +00:00
|
|
|
text = ta.value
|
2023-08-08 17:15:35 +00:00
|
|
|
if (!text && is_typing){
|
|
|
|
is_typing = false;
|
2023-01-21 10:36:21 +00:00
|
|
|
socket.emit('typing', false);
|
|
|
|
}
|
2023-08-08 17:15:35 +00:00
|
|
|
else if (text && !is_typing) {
|
|
|
|
is_typing = true;
|
2023-01-21 10:36:21 +00:00
|
|
|
socket.emit('typing', true);
|
2023-09-07 15:26:31 +00:00
|
|
|
timer_id = setTimeout(remove_typing, 2000);
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('typing', function (users){
|
|
|
|
if (users.length==0){
|
|
|
|
document.getElementById('typing-indicator').innerHTML = '';
|
|
|
|
document.getElementById('loading-indicator').classList.add('d-none');
|
|
|
|
}
|
|
|
|
else if (users.length==1){
|
|
|
|
document.getElementById('typing-indicator').innerHTML = '<b>'+users[0]+"</b> is typing...";
|
|
|
|
document.getElementById('loading-indicator').classList.remove('d-none');
|
|
|
|
}
|
|
|
|
else if (users.length==2){
|
|
|
|
document.getElementById('typing-indicator').innerHTML = '<b>'+users[0]+"</b> and <b>"+users[1]+"</b> are typing...";
|
|
|
|
document.getElementById('loading-indicator').classList.remove('d-none');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById('typing-indicator').innerHTML = '<b>'+users[0]+"</b>, <b>"+users[1]+"</b>, and <b>"+users[2]+"</b> are typing...";
|
|
|
|
document.getElementById('loading-indicator').classList.remove('d-none');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
function del(t) {
|
2023-02-10 13:44:47 +00:00
|
|
|
const chatline = t.parentElement.parentElement.parentElement.parentElement
|
2023-01-21 10:36:21 +00:00
|
|
|
socket.emit('delete', chatline.id);
|
|
|
|
chatline.remove()
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.on('delete', function(text) {
|
|
|
|
const text_spans = document.getElementsByClassName('text')
|
|
|
|
for(const span of text_spans) {
|
|
|
|
if (span.innerHTML == text)
|
|
|
|
{
|
|
|
|
span.parentElement.parentElement.parentElement.parentElement.parentElement.remove()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
document.addEventListener('click', function (e) {
|
2023-02-18 16:02:19 +00:00
|
|
|
if (e.target.classList.contains('delconfirm')) {
|
2023-01-21 10:36:21 +00:00
|
|
|
e.target.nextElementSibling.classList.remove('d-none');
|
|
|
|
e.target.classList.add('d-none');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (const btn of document.querySelectorAll('.delmsg:not(.d-none)')) {
|
|
|
|
btn.classList.add('d-none');
|
|
|
|
btn.previousElementSibling.classList.remove('d-none');
|
|
|
|
}
|
|
|
|
}
|
2023-02-22 17:27:33 +00:00
|
|
|
|
2023-01-21 10:36:21 +00:00
|
|
|
if (e.target.id == "cancel") {
|
2023-01-21 11:02:19 +00:00
|
|
|
document.getElementById("quotes").classList.add("d-none");
|
|
|
|
document.getElementById('quotes_id').value = null;
|
2023-01-21 10:36:21 +00:00
|
|
|
}
|
|
|
|
});
|
2023-01-21 11:23:09 +00:00
|
|
|
|
2023-03-06 18:02:12 +00:00
|
|
|
|
|
|
|
const input = document.getElementById('file')
|
2023-09-06 14:17:05 +00:00
|
|
|
function handle_files() {
|
|
|
|
if (!input.files.length) return
|
2023-09-07 08:47:06 +00:00
|
|
|
const char_limit = screen_width >= 768 ? 50 : 5;
|
|
|
|
input.previousElementSibling.textContent = input.files[0].name.substr(0, char_limit);
|
2023-09-06 14:17:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
input.onchange = handle_files
|
2023-03-06 18:02:12 +00:00
|
|
|
|
|
|
|
document.onpaste = function(event) {
|
|
|
|
input.files = structuredClone(event.clipboardData.files);
|
2023-09-06 14:17:05 +00:00
|
|
|
handle_files()
|
2023-03-06 18:02:12 +00:00
|
|
|
}
|
|
|
|
|
2023-01-22 05:17:25 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
2023-03-10 03:21:02 +00:00
|
|
|
setTimeout(function () {
|
2023-01-22 05:33:26 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 200);
|
2023-03-10 03:21:02 +00:00
|
|
|
setTimeout(function () {
|
2023-01-22 05:33:26 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 500);
|
2023-03-10 03:21:02 +00:00
|
|
|
setTimeout(function () {
|
2023-01-22 05:34:01 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 1000);
|
2023-03-10 03:21:02 +00:00
|
|
|
setTimeout(function () {
|
2023-01-22 23:17:59 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
}, 1500);
|
2023-03-10 03:21:02 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
2023-01-22 03:16:37 +00:00
|
|
|
box.scrollTo(0, box.scrollHeight)
|
|
|
|
});
|
2023-09-21 21:05:14 +00:00
|
|
|
|
2023-09-24 22:12:42 +00:00
|
|
|
const now = new Date();
|
|
|
|
const day_of_week = now.getUTCDay()
|
2023-09-21 21:05:14 +00:00
|
|
|
|
2023-09-24 22:12:42 +00:00
|
|
|
if ([4,5,7].includes(day_of_week)) {
|
|
|
|
let hour
|
|
|
|
if (day_of_week == 7) hour = 20
|
|
|
|
else hour = 0
|
2023-09-21 21:05:14 +00:00
|
|
|
|
2023-09-24 22:12:42 +00:00
|
|
|
let millis = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), hour, 0, 10) - now;
|
|
|
|
if (millis < 0)
|
|
|
|
millis += 86400000;
|
2023-09-21 21:05:14 +00:00
|
|
|
|
2023-09-24 22:12:42 +00:00
|
|
|
const minutes = Math.round(millis/1000/60*10)/10
|
|
|
|
console.log(`Refreshing page in ${minutes} minutes`)
|
|
|
|
setTimeout(() => location.reload(), millis);
|
2023-09-21 21:05:14 +00:00
|
|
|
}
|