Why Nostr? What is Njump?
2023-12-21 15:28:20

npub1n0…7dwhk on Nostr: #ipfs #embed fix for #coracle and #iris browser script ```js window.update_embeds = ...

#ipfs #embed fix for #coracle and #iris
browser script

```js
window.update_embeds = function(){
document.querySelectorAll("video,img").forEach(v => {
if(v.src.match(/ipfs:\/\/([^ \/]+)(\S*)/)){
console.log("ipfs video replace coracle")
v.src = v.src.replace(/ipfs:\/\/([^ \/]+)(\S*)/, "http://$1.ipfs.localhost:8080/$2";)
}
})
document.querySelectorAll(".text-frag").forEach(t => {
if(t.innerHTML.match(/ipfs:\/\/([^ \/]+)(\S*)/)){
console.log("ipfs img replace coracle")
t.innerHTML = t.innerHTML.replace(/ipfs:\/\/([^ \/]+)(\S*)\.(jpg|jpeg|png|webp)/, "<img src=\"http://$1.ipfs.localhost:8080$2\.$3\"\/>";)
}
})
document.querySelectorAll(".text-frag").forEach(t => {let m = t.innerText.match(/ipfs:\/\/([^ \/]+)(\S*)\.(webm|mp4)/);
if(m){
console.log("ipfs video replace iris");
t.innerHTML = t.innerHTML.replace(m[0], '<video class="max-h-[80vh]" loop controls src="http://'; + decodeURI(m[1]+".ipfs.localhost:8080"+m[2]+"."+m[3]) + '"/>')
}})
}

addEventListener("load", () => {
let to = null
const observer = new MutationObserver(() => {
if(to != null){
return
}

to = setTimeout(() => {
to = null
}, 50)

console.log("update ipfs embeds")
update_embeds()
})

observer.observe(document.body, { childList: true, subtree: true });
})
```
Author Public Key
npub1n0k5tmnuxfq7aga6wjfp52uz93elz3r7t93rzss9myd83nyevghq67dwhk