export var ZenCustomizableUI = new class { constructor() {} TYPE_TOOLBAR = 'toolbar'; defaultSidebarIcons = [ 'zen-sidepanel-button', 'zen-workspaces-button', 'new-tab-button' ]; startup(CustomizableUIInternal) { CustomizableUIInternal.registerArea( "zen-sidebar-top-buttons", { type: this.TYPE_TOOLBAR, defaultPlacements: [ "PanelUI-menu-button", "zen-expand-sidebar-button", "zen-profile-button" ], defaultCollapsed: null, } ); CustomizableUIInternal.registerArea( "zen-sidebar-icons-wrapper", { type: this.TYPE_TOOLBAR, defaultPlacements: this.defaultSidebarIcons, defaultCollapsed: null, } ); } // 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 sideBarTopButtons = window.document.getElementById('zen-sidebar-top-buttons') .querySelector('#zen-sidebar-top-buttons-customization-target'); 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); window.CustomizableUI.registerToolbarNode( window.document.getElementById('zen-sidebar-top-buttons') ); const panelMenu = window.document.getElementById('PanelUI-menu-button'); panelMenu.classList.add('zen-sidebar-action-button'); panelMenu.setAttribute('cui-areatype', 'toolbar'); sideBarTopButtons.prepend(panelMenu); for (let id of this.defaultSidebarIcons) { const elem = window.document.getElementById(id); if (!elem) continue; elem.setAttribute('removable', 'true'); } window.CustomizableUI.registerToolbarNode( window.document.getElementById('zen-sidebar-icons-wrapper') ); 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 elementsToHide = [ 'alltabs-button', ]; for (let id of elementsToHide) { const elem = window.document.getElementById(id); if (elem) { elem.setAttribute('hidden', 'true'); } } } };