1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-01 16:49:39 +02:00

code review

This commit is contained in:
gorhill 2015-12-11 19:18:14 -05:00
parent 84d85d080c
commit 08085f7383

View File

@ -3432,27 +3432,22 @@ var optionsObserver = (function() {
// Older versions of Firefox can throw here when looking up `currentURI`. // Older versions of Firefox can throw here when looking up `currentURI`.
var canInit = function() { var canInit = function() {
var ok;
try { try {
var tabBrowser = tabWatcher.currentBrowser(); var tabBrowser = tabWatcher.currentBrowser();
ok = tabBrowser && return tabBrowser &&
tabBrowser.currentURI && tabBrowser.currentURI &&
tabBrowser.contentDocument && tabBrowser.currentURI.spec === 'about:addons' &&
tabBrowser.contentDocument.readyState === 'complete'; tabBrowser.contentDocument &&
tabBrowser.contentDocument.readyState === 'complete';
} catch (ex) { } catch (ex) {
} }
return ok;
}; };
// Manually add the buttons if the `about:addons` page is already // Manually add the buttons if the `about:addons` page is already opened.
// opened.
var init = function() { var init = function() {
if ( canInit() ) { if ( canInit() ) {
var tabBrowser = tabWatcher.currentBrowser(); setupOptionsButtons(tabWatcher.currentBrowser().contentDocument);
if ( tabBrowser.currentURI.spec === 'about:addons' ) {
setupOptionsButtons(tabBrowser.contentDocument);
}
} }
}; };
@ -3463,7 +3458,7 @@ var optionsObserver = (function() {
var register = function() { var register = function() {
Services.obs.addObserver(observer, 'addon-options-displayed', false); Services.obs.addObserver(observer, 'addon-options-displayed', false);
cleanupTasks.push(unregister); cleanupTasks.push(unregister);
deferUntil(canInit, init); deferUntil(canInit, init, { next: 463 });
}; };
return { return {