diff options
Diffstat (limited to 'app/vendor/trezor/content-script.js')
-rw-r--r-- | app/vendor/trezor/content-script.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/vendor/trezor/content-script.js b/app/vendor/trezor/content-script.js new file mode 100644 index 000000000..a21332f46 --- /dev/null +++ b/app/vendor/trezor/content-script.js @@ -0,0 +1,21 @@ +/* +Passing messages from background script to popup +*/ + +let port = chrome.runtime.connect({ name: 'trezor-connect' }); +port.onMessage.addListener(message => { + window.postMessage(message, window.location.origin); +}); +port.onDisconnect.addListener(d => { + port = null; +}); + +/* +Passing messages from popup to background script +*/ + +window.addEventListener('message', event => { + if (port && event.source === window && event.data) { + port.postMessage(event.data); + } +}); |