aboutsummaryrefslogtreecommitdiff
path: root/js/firefox/content-script-proxy.js
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2015-09-18 15:42:21 +0000
committerEinar Egilsson <einar@einaregilsson.com>2015-09-18 15:42:21 +0000
commitb2ba3216ea5dbe6a74fdfa75611fce95c1481316 (patch)
tree0ed80d05edc5497d64455197a04fabec7aa8d69d /js/firefox/content-script-proxy.js
parent862d738c79dc6f8188d3f9fefd46c01179041710 (diff)
Halfway to making Firefox compatible
Diffstat (limited to 'js/firefox/content-script-proxy.js')
-rw-r--r--js/firefox/content-script-proxy.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/js/firefox/content-script-proxy.js b/js/firefox/content-script-proxy.js
new file mode 100644
index 0000000..58a6bc0
--- /dev/null
+++ b/js/firefox/content-script-proxy.js
@@ -0,0 +1,16 @@
+// This file listens to messages
+
+window.addEventListener('message', function(message) {
+ if (message.data.sender !== 'page') {
+ return;
+ }
+ console.info('proxy got page message: ' + JSON.stringify(message.data));
+
+ //Forward the message to the background script
+ self.port.emit('message', message.data);
+})
+
+self.port.on('message', function(message) {
+ console.info('proxy got chrome message: ' + JSON.stringify(message));
+ window.postMessage(message, '*');
+}); \ No newline at end of file