#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)/, "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], '

}})

}

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 });

})

```

Reply to this note

Please Login to reply.

Discussion

No replies yet.