Browse Source

Initial Firefox port (base, messaging, locales)

pull/2/head
Deathamns 10 years ago
committed by gorhill
parent
commit
efb4b98986
  1. 32
      platform/firefox/frameScript.js

32
platform/firefox/frameScript.js

@ -0,0 +1,32 @@
/* globals Services, sendAsyncMessage, addMessageListener, removeMessageListener, content */
(function() {
'use strict';
var
app_name = 'ublock',
app_baseURI = 'chrome://' + app_name + '/content/js/',
listeners = {},
_addMessageListener = function(id, fn) {
_removeMessageListener(id);
listeners[id] = function(msg) {
fn(msg.data);
};
addMessageListener(id, listeners[id]);
},
_removeMessageListener = function(id) {
if (listeners[id]) {
removeMessageListener(id, listeners[id]);
}
delete listeners[id];
};
addMessageListener('µBlock:broadcast', function(msg) {
for (var id in listeners) {
listeners[id](msg.data);
}
});
})();
Loading…
Cancel
Save