mirror of
https://github.com/melvincarvalho/nostrefresh.git
synced 2025-12-17 08:04:19 +01:00
first
This commit is contained in:
25
index.js
Normal file
25
index.js
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
)()
|
||||
24
package.json
Normal file
24
package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "nostrefresh",
|
||||
"version": "0.0.1",
|
||||
"description": "refresh via nostr relay",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/melvincarvalho/nostrefresh.git"
|
||||
},
|
||||
"keywords": [
|
||||
"nostr",
|
||||
"nostrefresh"
|
||||
],
|
||||
"author": "Melvin Carvalho",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/melvincarvalho/nostrefresh/issues"
|
||||
},
|
||||
"homepage": "https://github.com/melvincarvalho/nostrefresh#readme"
|
||||
}
|
||||
Reference in New Issue
Block a user