1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-14 16:25:03 +12:00

Initial Firefox port (base, messaging, locales)

This commit is contained in:
Deathamns 2014-11-24 20:00:27 +01:00 committed by gorhill
parent beb70b8343
commit efb4b98986

View file

@ -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);
}
});
})();