Firefox始终显示菜单栏工具栏

时间:2015-06-04 09:33:58

标签: firefox firefox-addon xul xpi

我正在开发一个Firefox扩展程序,我在其中对browser.xul进行了各种更改以自定义Firefox的UI。默认情况下,Firefox的菜单栏已禁用/不可见。我希望它始终显示菜单栏工具栏。 仅供参考,我已禁用右键单击工具栏上的工具栏,该工具栏通常显示上下文菜单,其中一个可以使菜单栏可见或消失。

有什么方法可以进行此设置吗?

3 个答案:

答案 0 :(得分:2)

我找到了这个条目,因为我一直在寻找一个显示工具栏的解决方案,这个工具栏总是“最小化”所以我不得不点击“更多工具”然后点击工具(例如ublock)。

我的解决方案是转到about:config并将值browser.chrome.toolbar_style(即“2”)更改为“1”。重启firefox后,所有工具再次可见。将其更改回“2”并重新启动Firefox仍会显示所有工具..奇怪的行为。

答案 1 :(得分:1)

这不是一个解决方案,而是一个解决方案。

选项1

弄清楚如何设置一个比这更重要的样式表:

看起来当inactive=true属性设置在chrome://global/content/xul.css第289行时,它会得到一个重要的高度为0的css。我尝试使用自己的高度注册样式表

This is whats applied when `inactive=true` attribute is on it:

toolbar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) {
  min-height: 0 !important;
  height: 0 !important;
  -moz-appearance: none !important;
  border-style: none !important;
}

我试过这个,但我的重要性并不是重写这个,这个页面可能值得一读,它关于css顺序优先级我认为可以用这个完成:http://hungred.com/useful-information/css-priority-order-tips-tricks/

我试过这段代码,但它不会更重要:

// globals
Cu.import('resource://gre/modules/Services.jsm');
var sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService);

try {
    sss.unregisterSheet(cssUri, sss.AUTHOR_SHEET);
} catch (ignore) {}

var cssUri;
var css = 'toolbar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) { height: 50px !important; min-height: 50px !important;';
var newURIParam = {
    aURL: 'data:text/css,' + encodeURIComponent(css),
    aOriginCharset: null,
    aBaseURI: null
};
var cssUri = Services.io.newURI(newURIParam.aURL, newURIParam.aOriginCharset, newURIParam.aBaseURI);
sss.loadAndRegisterSheet(cssUri, sss.AUTHOR_SHEET);

我还试过var css = '#toolbar-menubar[type="menubar"][autohide="true"][inactive="true"]:not([customizing="true"]) { height: 50px !important; min-height: 50px !important;';并告知我如何使用#toolbar-menubar id代替标签选择器,id具有最高的重要性,但即使我保留了选择性,它也没有用。

选项2

变异观察者,无论何时发生非活动=真,都将其删除。这是肯定的火,没有想到保证。但是我认为CSS选项会更受欢迎,因为它可以提高性能。

答案 2 :(得分:1)

我试过这个并且工作正常,

我已经编辑了browser.jsgBrowserInit个函数onLoad函数,我在整个用户界面加载完成后添加了以下代码段。

let toolbar = window.document.getElementById("toolbar-menubar");
if (toolbar) {
    window.setToolbarVisibility(toolbar, true, true);
}
相关问题