skeleton.

This commit is contained in:
fiatjaf
2022-01-09 21:30:15 -03:00
commit 853a2b304b
13 changed files with 1316 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
// inject the script that will provide window.nostr
let script = document.createElement('script')
script.src = 'nostr-provider.js'
document.head.appendChild(script)
// listen for messages from that script
window.addEventListener('message', async ev => {
if (ev.source !== window) return
if (!ev.data || ev.data.ext !== 'nostr') {
// pass on to background
var reply
try {
reply = browser.runtime.sendMessage({
...ev.data,
host: window.location.host
})
} catch (error) {
reply = {error}
}
// return response
window.postMessage({id: ev.data.id, reply})
}
})