no_name on Nostr: #nip95 in 19 lines of html + js: ```js <html> <body> <img/> <script> let socket = new ...
#nip95 in 19 lines of html + js:
```js
<html>
<body>
<img/>
<script>
let socket = new WebSocket("wss://relay.nostr.band")
socket.onopen = function(){
this.send(JSON.stringify(["REQ", "q", {"ids": [location.hash.substring(1)]}]))
}
socket.onmessage = function(msg){
socket.close()
const evt = JSON.parse(msg.data)[2]
const mime = (evt.tags.find(t => t[0] == "type")[1])
document.querySelector("img").src = "data:" + mime + ";base64," + evt.content
}
</script>
</body>
</html>
```
Published at
2023-12-31 12:07:59Event JSON
{
"id": "cdfa98d7ad798a930a3736b3f287f37da1a4fa27735221b2d91918a378166db7",
"pubkey": "ae8942b6dd585d633e7881791ab2fbde9edcb76dff5f0388872394a08132adf8",
"created_at": 1704024479,
"kind": 1,
"tags": [
[
"t",
"nip95"
]
],
"content": "#nip95 in 19 lines of html + js:\n\n```js\n\u003chtml\u003e\n \u003cbody\u003e\n \u003cimg/\u003e\n \u003cscript\u003e\n let socket = new WebSocket(\"wss://relay.nostr.band\")\n \n socket.onopen = function(){\n this.send(JSON.stringify([\"REQ\", \"q\", {\"ids\": [location.hash.substring(1)]}]))\n }\n\n socket.onmessage = function(msg){\n socket.close()\n const evt = JSON.parse(msg.data)[2]\n const mime = (evt.tags.find(t =\u003e t[0] == \"type\")[1])\n document.querySelector(\"img\").src = \"data:\" + mime + \";base64,\" + evt.content\n }\n \u003c/script\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n```",
"sig": "7db7dbe118d7cf17845301d9b2cc19d41d4677ac6b20becf4b91db295a2cf90fa39b0a94757cd1ac3a4694838fd0d70b34dd38365862725392221afa7558b3ad"
}