export var ZenCustomizableUI = new (class { constructor() {} TYPE_TOOLBAR = 'toolbar'; defaultSidebarIcons = ['zen-profile-button', 'zen-workspaces-button', 'downloads-button']; startup(CustomizableUIInternal) { CustomizableUIInternal.registerArea( 'zen-sidebar-top-buttons', { type: this.TYPE_TOOLBAR, defaultPlacements: ['preferences-button', 'zen-expand-sidebar-button', 'zen-sidepanel-button'], defaultCollapsed: null, }, true ); CustomizableUIInternal.registerArea( 'zen-sidebar-icons-wrapper', { type: this.TYPE_TOOLBAR, defaultPlacements: this.defaultSidebarIcons, defaultCollapsed: null, }, true ); } // We do not have access to the window object here init(window) { this._addSidebarButtons(window); this._hideToolbarButtons(window); } _addSidebarButtons(window) { const sidebarBox = window.MozXULElement.parseXULToFragment(` `); window.document.getElementById('navigator-toolbox').prepend(sidebarBox); const newTab = window.document.getElementById('vertical-tabs-newtab-button'); newTab.classList.add('zen-sidebar-action-button'); const wrapper = window.document.createXULElement('toolbarbutton'); wrapper.id = 'zen-workspaces-button'; window.document.getElementById('zen-sidebar-icons-wrapper').prepend(wrapper); for (let id of this.defaultSidebarIcons) { const elem = window.document.getElementById(id); if (!elem) continue; elem.setAttribute('removable', 'true'); } this._moveWindowButtons(window); } _moveWindowButtons(window) { const windowControls = window.document.getElementsByClassName('titlebar-buttonbox-container'); const toolboxIcons = window.document.getElementById('zen-sidebar-top-buttons-customization-target'); if (window.AppConstants.platform === 'macosx') { for (let i = 0; i < windowControls.length; i++) { if (i === 0) { toolboxIcons.prepend(windowControls[i]); continue; } windowControls[i].remove(); } } } _hideToolbarButtons(window) { const wrapper = window.document.getElementById('zen-sidebar-icons-wrapper'); const elementsToHide = ['alltabs-button', 'new-tab-button']; for (let id of elementsToHide) { const elem = window.document.getElementById(id); if (elem) { wrapper.prepend(elem); } } } registerToolbarNodes(window) { window.CustomizableUI.registerToolbarNode(window.document.getElementById('zen-sidebar-top-buttons')); window.CustomizableUI.registerToolbarNode(window.document.getElementById('zen-sidebar-icons-wrapper')); } })();