| Index: lib/ui.js |
| =================================================================== |
| --- a/lib/ui.js |
| +++ b/lib/ui.js |
| @@ -32,16 +32,7 @@ |
| let {Notification} = require("notification"); |
| let {initAntiAdblockNotification} = require("antiadblockInit"); |
| -let CustomizableUI; |
| -try |
| -{ |
| - ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null); |
| -} |
| -catch (e) |
| -{ |
| - // No built-in CustomizableUI API, use our own implementation. |
| - ({CustomizableUI}) = require("customizableUI"); |
| -} |
| +let CustomizableUI = null; |
| /** |
| * Filter corresponding with "disable on site" menu item (set in fillIconMent()). |
| @@ -412,6 +403,16 @@ |
| let {defaultToolbarPosition} = require("appSupport"); |
| if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition) |
| { |
| + try |
| + { |
| + ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", null); |
| + } |
| + catch (e) |
| + { |
| + // No built-in CustomizableUI API, use our own implementation. |
| + ({CustomizableUI}) = require("customizableUI"); |
| + } |
| + |
| CustomizableUI.createWidget({ |
| id: "abp-toolbarbutton", |
| type: "custom", |
| @@ -1034,6 +1035,8 @@ |
| */ |
| toggleToolbarIcon: function() |
| { |
| + if (!CustomizableUI) |
| + return; |
| if (this.isToolbarIconVisible()) |
| CustomizableUI.removeWidgetFromArea("abp-toolbarbutton"); |
| else |
| @@ -1708,6 +1711,8 @@ |
| */ |
| isToolbarIconVisible: function() /**Boolean*/ |
| { |
| + if (!CustomizableUI) |
| + return false; |
| let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| return !!placement; |
| }, |