mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-05 02:29:38 +02:00
Firefox: revert previous change
Initializing the extension with AddonManager takes too long (at least for this extension). When starting the browser, tabs loaded before the extension could, and because of that, blocking didn't work. It works better, if it's initialized when the window's DOM is ready.
This commit is contained in:
parent
e61514b9b1
commit
782f8d441d
32
platform/firefox/bootstrap.js
vendored
32
platform/firefox/bootstrap.js
vendored
@ -19,7 +19,7 @@
|
|||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global APP_SHUTDOWN */
|
/* global APP_SHUTDOWN, APP_STARTUP */
|
||||||
/* exported startup, shutdown, install, uninstall */
|
/* exported startup, shutdown, install, uninstall */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -30,13 +30,12 @@ let bgProcess;
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
function startup(data) {
|
function startup(data, reason) {
|
||||||
let {AddonManager} = Components.utils['import'](
|
bgProcess = function(e) {
|
||||||
'resource://gre/modules/AddonManager.jsm',
|
if (e) {
|
||||||
null
|
this.removeEventListener('DOMContentLoaded', bgProcess);
|
||||||
);
|
}
|
||||||
|
|
||||||
AddonManager.getAddonByID(data.id, addon => {
|
|
||||||
let hDoc = Components.classes['@mozilla.org/appshell/appShellService;1']
|
let hDoc = Components.classes['@mozilla.org/appshell/appShellService;1']
|
||||||
.getService(Components.interfaces.nsIAppShellService)
|
.getService(Components.interfaces.nsIAppShellService)
|
||||||
.hiddenDOMWindow.document;
|
.hiddenDOMWindow.document;
|
||||||
@ -44,12 +43,23 @@ function startup(data) {
|
|||||||
bgProcess = hDoc.documentElement.appendChild(
|
bgProcess = hDoc.documentElement.appendChild(
|
||||||
hDoc.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
|
hDoc.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
|
||||||
);
|
);
|
||||||
|
bgProcess.setAttribute('src', 'chrome://ublock/content/background.html');
|
||||||
|
};
|
||||||
|
|
||||||
let bgURI = 'chrome://ublock/content/background.html';
|
if (reason === APP_STARTUP) {
|
||||||
|
let ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
|
||||||
|
.getService(Components.interfaces.nsIWindowWatcher);
|
||||||
|
|
||||||
// send addon data synchronously to the background script
|
ww.registerNotification({
|
||||||
bgProcess.src = bgURI + '#' + [addon.name, addon.version];
|
observe: function(win) {
|
||||||
});
|
ww.unregisterNotification(this);
|
||||||
|
win.addEventListener('DOMContentLoaded', bgProcess);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bgProcess();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -43,10 +43,10 @@ vAPI.firefox = true;
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.app = location.hash.slice(1).split(',');
|
// TODO: read these data from somewhere...
|
||||||
vAPI.app = {
|
vAPI.app = {
|
||||||
name: vAPI.app[0],
|
name: 'µBlock',
|
||||||
version: vAPI.app[1]
|
version: '0.8.2.0'
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user