From 1ae15f1a618938db11a25751174383d3b66ff31a Mon Sep 17 00:00:00 2001 From: Deathamns Date: Tue, 16 Dec 2014 22:31:03 +0100 Subject: [PATCH] Firefox: implement vAPI.tabs.injectScript --- platform/firefox/vapi-client.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index 0ecb655..79f6ef9 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -44,7 +44,7 @@ var messagingConnector = function(response) { var channels = vAPI.messaging.channels; var channel, listener; - if ( response.broadcast === true ) { + if ( response.broadcast === true && !response.portName ) { for ( channel in channels ) { if ( channels.hasOwnProperty(channel) === false ) { continue; @@ -92,6 +92,19 @@ vAPI.messaging = { messagingConnector(JSON.parse(msg)); }; addMessageListener(this.connectorId, this.connector); + + this.channels['vAPI'] = {}; + this.channels['vAPI'].listener = function(msg) { + if (msg.cmd === 'injectScript') { + var details = msg.details; + + if (!details.allFrames && window !== window.top) { + return; + } + + self.injectScript(details.file || details.code, !details.file); + } + }; }, close: function() {