This commit is contained in:
Melvin Carvalho
2022-02-17 18:41:27 +01:00
parent 08932fadfa
commit bfedf86866
2 changed files with 49 additions and 0 deletions

25
index.js Normal file
View File

@@ -0,0 +1,25 @@
; (() => {
globalThis.qs = Object.fromEntries(new URLSearchParams(document.location.search))
var t = qs.t || 5
if (qs.relay) {
var socket = new WebSocket(qs.relay)
socket.onopen = function (event) {
console.log('wss open', qs.relay)
let now = new Date().getTime()
now = Math.floor(now / 1000.0)
let subscribe = `["REQ", "tail", {"since": ${now} }]`
console.log(subscribe)
socket.send(subscribe)
}
socket.onmessage = function (event) {
console.log('refreshing in', t)
setTimeout(() => {
document.location.reload()
}, t * 1000)
}
}
}
)()