Firefox: load content-scripts on extension start

pull/2/head
Deathamns 10 years ago committed by gorhill
parent 9aaee014d4
commit 8c9382d4db

@ -19,13 +19,43 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
/******************************************************************************/
(function() {
'use strict'; 'use strict';
/******************************************************************************/ /******************************************************************************/
Components.utils.import( let {contentObserver} = Components.utils.import(
Components.stack.filename.replace('Script', 'Module'), Components.stack.filename.replace('Script', 'Module'),
null null
); );
let injectContentScripts = function(win) {
if ( !win || !win.document ) {
return;
}
contentObserver.observe(win.document);
if ( win.frames && win.frames.length ) {
let i = win.frames.length;
while ( i-- ) {
injectContentScripts(win.frames[i]);
}
}
};
let onLoadCompleted = function() {
removeMessageListener('ublock-load-completed', onLoadCompleted);
injectContentScripts(content);
};
addMessageListener('ublock-load-completed', onLoadCompleted);
/******************************************************************************/
})();
/******************************************************************************/ /******************************************************************************/

Loading…
Cancel
Save