11// ==UserScript==
22// @name Navbar Toolbar Button Slider
3- // @version 2.8.1
3+ // @version 2.8.2
44// @author aminomancer
55// @homepage https://github.com/aminomancer
66// @description Wrap all toolbar buttons in a scrollable container. It can
@@ -122,8 +122,17 @@ class NavbarToolbarSlider {
122122 ) ;
123123 }
124124 constructor ( ) {
125- this . outer = document . createElement ( "toolbaritem" ) ;
126- this . inner = this . outer . appendChild ( document . createElement ( "hbox" ) ) ;
125+ this . outer = document . createXULElement ( "toolbaritem" ) ;
126+ Object . defineProperty ( this . outer , "hidden" , {
127+ get ( ) {
128+ return this . getAttribute ( "hidden" ) === "true" ;
129+ } ,
130+ set ( val ) {
131+ if ( val ) this . setAttribute ( "hidden" , "true" ) ;
132+ else this . removeAttribute ( "hidden" ) ;
133+ } ,
134+ } ) ;
135+ this . inner = this . outer . appendChild ( document . createXULElement ( "hbox" ) ) ;
127136 this . kids = this . inner . children ;
128137 this . navbar = document . getElementById ( "nav-bar" ) ;
129138 this . cTarget = document . getElementById ( this . navbar . getAttribute ( "customizationtarget" ) ) ;
@@ -316,7 +325,7 @@ class NavbarToolbarSlider {
316325 await this . navbar . overflowable . _moveItemsBackToTheirOrigin ( true ) ;
317326 this . unwrapAll ( ) ;
318327 this . wrapAll ( [ ...this . widgets ] . filter ( this . filterFn , this ) , this . inner ) ;
319- this . outer . style . display = "-moz-box" ;
328+ this . outer . hidden = false ;
320329 }
321330 onCustomizeStart ( ) {
322331 let overflown = this . isOverflowing ;
@@ -327,7 +336,7 @@ class NavbarToolbarSlider {
327336 // or else we get a tiny bug where dragging a widget ahead of the empty
328337 // slider causes the widget to teleport to the end.
329338 this . bin . appendChild ( this . outer ) ;
330- this . outer . style . display = overflown ? "none" : "-moz-box" ;
339+ this . outer . hidden = overflown ;
331340 }
332341 onCustomizeEnd ( ) {
333342 let overflown = this . isOverflowing ;
@@ -336,14 +345,14 @@ class NavbarToolbarSlider {
336345 this . wrapAll ( array , this . cOverflow ) ;
337346 this . cOverflow . insertBefore ( this . outer , this . cOverflow . firstElementChild ) ;
338347 } else this . wrapAll ( array , this . inner ) ;
339- this . outer . style . display = overflown ? "none" : "-moz-box" ;
348+ this . outer . hidden = overflown ;
340349 this . setMaxWidth ( ) ;
341350 }
342351 onWidgetOverflow ( aNode , aContainer ) {
343352 if ( aNode . ownerGlobal !== window ) return ;
344353 if ( aNode === this . outer && aContainer === this . cTarget ) {
345354 NavbarToolbarSlider . appendLoop ( this . kids , this . cOverflow ) ;
346- this . outer . style . display = "none" ;
355+ this . outer . hidden = true ;
347356 this . reOrder ( ) ;
348357 }
349358 }
@@ -352,7 +361,7 @@ class NavbarToolbarSlider {
352361 if ( aNode === this . outer && aContainer === this . cTarget ) {
353362 this . unwrapAll ( ) ;
354363 this . wrapAll ( [ ...this . widgets ] . filter ( this . filterFn , this ) , this . inner ) ;
355- this . outer . style . display = "-moz-box" ;
364+ this . outer . hidden = false ;
356365 this . reOrder ( ) ;
357366 }
358367 }
@@ -615,15 +624,15 @@ class NavbarToolbarSlider {
615624 clicktoscroll : true ,
616625 orient : "horizontal" ,
617626 style :
618- "display: -moz-box; -moz-box-align: center; -moz-box-orient: vertical; scrollbar-width: none; box-sizing: border-box; scroll-behavior: smooth; overflow: hidden; transition: max-width 0.2s ease-out;" ,
627+ "-moz-box-align: center; -moz-box-orient: vertical; scrollbar-width: none; box-sizing: border-box; scroll-behavior: smooth; overflow: hidden; transition: max-width 0.2s ease-out;" ,
619628 } ) ) {
620629 outer . setAttribute ( key , val ) ;
621630 }
622631 if ( ! this . collapse ) outer . setAttribute ( "overflows" , false ) ;
623632 for ( const [ key , val ] of Object . entries ( {
624633 class : "slider-inner-container" ,
625634 id : "nav-bar-toolbarbutton-slider" ,
626- style : "display: -moz-box; -moz-box-flex: 1;" ,
635+ style : "-moz-box-flex: 1;" ,
627636 } ) ) {
628637 inner . setAttribute ( key , val ) ;
629638 }
0 commit comments