Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firefox扩展,向导航工具栏添加按钮(类似于LiveHeaders和FireBug)_Firefox_Firefox Addon_Xul_Firefox Addon Sdk - Fatal编程技术网

Firefox扩展,向导航工具栏添加按钮(类似于LiveHeaders和FireBug)

Firefox扩展,向导航工具栏添加按钮(类似于LiveHeaders和FireBug),firefox,firefox-addon,xul,firefox-addon-sdk,Firefox,Firefox Addon,Xul,Firefox Addon Sdk,我试图在Firefox上的“自定义工具栏”列表中显示一个按钮(基于此) (来源:) 从理论上讲,您可以自定义浏览器的此部分 (来源:) 这是我的button.xul文件 <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="chrome://helloworld/content/button.css" ?> <!DOCTYPE overlay> <

我试图在Firefox上的“自定义工具栏”列表中显示一个按钮(基于此)


(来源:)

从理论上讲,您可以自定义浏览器的此部分


(来源:)

这是我的button.xul文件

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css"
  href="chrome://helloworld/content/button.css" ?>
<!DOCTYPE overlay>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="helloworld-overlay">
    <script type="application/javascript" src="chrome://helloworld/content/button.js" />
    <!-- Firefox -->
    <toolbarpalette id="BrowserToolbarPalette">
        <toolbarbutton id="custom-button-1" />
    </toolbarpalette>
    <!-- button details -->
    <toolbarbutton id="custom-button-1" label="Custom" tooltiptext="My custom toolbar button" oncommand="CustomButton[1]()" class="toolbarbutton-1 chromeclass-toolbar-additional custombutton" />
</overlay>
我已经在xul资源管理器上测试了我的button.xul,结果很好(编译很好)


(来源:)


由于某些原因,我无法将此按钮添加到我希望用于Firefox的位置。

对于其他希望使用bootstrap的用户,您必须添加到浏览器托盘

请参阅此处的要点并阅读注释:

好了,现在你根本不用思考了。只需复制代码,粘贴到scratchbad,当然是浏览器环境,然后点击run

它添加了一个带有orrange立方体作为其图像的按钮,一旦运行代码转到customize,您就会看到它,您现在可以将它拖动到addon栏、工具栏或australis菜单面板

复制粘贴要点,以防github崩溃(lol)


编辑:我根据要点更新了代码,因此在创建按钮后,它会将其移动到最后位置的导航栏。

我找到了如何通过创建期间添加必要的
按钮
(扩展名由命令
cfx xps
生成)


此外,我在mozilla IRC上的
#developer
中与一位开发人员交谈,他说以编程方式将添加到导航栏将很快变得多余,因为下一版本的Firefox()将提供功能,使用
xul

导航工具栏中添加信息。更新后,可以说是它的引导方法。尝试使用该方法,因为我知道它是有效的。尝试复制粘贴它会添加一个按钮vfor meOk我会按照该要点给这家伙喂食,这样他就可以不用思考就复制粘贴所有内容g到scratchpad。现在他必须复制粘贴部分并考虑一下。我已经想到了如何做,使用Mozilla插件SDK和由
cfx init
生成的main.js脚本。但是感谢Noitidart(我本来打算删除它,但因为您已经投入了精力,+1 rep:)。谢谢。欢迎我个人喜欢ppl自己给我复制粘贴的东西。它现在在我的要点库中,供其他人学习。
content helloworld chrome/
style chrome://global/content/customizeToolbar.xul chrome://helloworld/content/button.css

# Firefox
overlay chrome://browser/content/browser.xul chrome://helloworld/content/button.xul
var doc = document;
var win = doc.defaultView;

var toolbox = doc.querySelector('#navigator-toolbox');

var button = doc.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'toolbarbutton');
button.setAttribute('id', 'bpMyBtn');
button.setAttribute('label', 'My Button');
button.setAttribute('tooltiptext', 'My buttons tool tip if you want one');
button.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
button.style.listStyleImage = 'url("https://gist.githubusercontent.com/Noitidart/9266173/raw/06464af2965cb5968248b764b4669da1287730f3/my-urlbar-icon-image.png")';
button.addEventListener('command', function() {
    alert('you clicked my button')
}, false);

toolbox.palette.appendChild(button);