uBlock/platform/firefox/bootstrap.js
2015-01-13 07:29:07 +01:00

45 lines
1.2 KiB
JavaScript

/* global Services, APP_STARTUP, APP_SHUTDOWN */
/* exported startup, shutdown, install, uninstall */
'use strict';
Components.utils['import']('resource://gre/modules/Services.jsm');
var bgProcess;
function startup(data, reason) {
bgProcess = function(ev) {
if (ev) {
this.removeEventListener(ev.type, bgProcess);
}
bgProcess = Services.appShell.hiddenDOMWindow.document;
bgProcess = bgProcess.documentElement.appendChild(
bgProcess.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
);
bgProcess.setAttribute('src', 'chrome://ublock/content/background.html');
};
if (reason === APP_STARTUP) {
Services.ww.registerNotification({
observe: function(win) {
Services.ww.unregisterNotification(this);
win.addEventListener('DOMContentLoaded', bgProcess);
}
});
}
else {
bgProcess();
}
}
function shutdown(data, reason) {
if (reason !== APP_SHUTDOWN) {
bgProcess.parentNode.removeChild(bgProcess);
}
}
// https://bugzil.la/719376
function install() Services.strings.flushBundles();
function uninstall() {}