From cc27cbafc8bdd1ef390a1d541f72865dafcdb50d Mon Sep 17 00:00:00 2001 From: Alexander Ploner Date: Mon, 27 Feb 2017 20:20:06 +0100 Subject: [PATCH] #5 hide pinned tabs in Firefox 51+ --- index.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 40624bb..6db30b4 100644 --- a/index.js +++ b/index.js @@ -1,17 +1,34 @@ 'use strict'; -let { viewFor } = require('sdk/view/core'), +let {viewFor} = require('sdk/view/core'), windows = require('sdk/windows').browserWindows; +const HIDE_PINNED_TABS_STYLE = '.tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab[pinned] ' + + '{ position: relative !important; }'; + // listener function function addListener(lWindow) { let window = viewFor(lWindow); + let document = window.document; + let toolbox = document.getElementById('navigator-toolbox'); + + let styleElem = document.createElementNS('http://www.w3.org/1999/xhtml', 'style'); + toolbox.insertBefore(styleElem, toolbox.childNodes.item(0)); + let styleSheet = styleElem.sheet; + + window.addEventListener('fullscreen', () => { + let active = window.fullScreen; + + toolbox.style.height = active ? '0px' : 'auto'; + toolbox.style.overflow = active ? 'hidden' : 'auto'; - window.addEventListener('fullscreen', function () { - let toolbox = window.document.getElementById('navigator-toolbox'); - toolbox.style.height = window.fullScreen ? '0px' : 'auto'; - toolbox.style.overflow = window.fullScreen ? 'hidden' : 'auto'; + // hide pinned tabs, required since Firefox 51 + if (active) { + styleSheet.insertRule(HIDE_PINNED_TABS_STYLE, 0); + } else { + styleSheet.deleteRule(0); + } }, false); }