Firefox:如何使用附加SDK(Jetpack)添加/修改工具栏 [英] Firefox: How can I add/modify toolbars using the Add-on SDK (Jetpack)
本文介绍了Firefox:如何使用附加SDK(Jetpack)添加/修改工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我现在已经多次浏览了附加SDK的文档,没有哪里可以看到如何创建工具栏或修改现有工具栏的方法.他们有一个有关创建附加栏图标的教程,但是那不是我想要的.附加SDK是否支持此功能?如果可以,有人可以将我链接到示例/教程.
So I've looked over the documentation for the Add-on SDK several times now and no where can I see how to create toolbars or modify existing ones. They have a tutorial on creating add-on bar icons but thats not what I want. Does the Add-on SDK support this yet? If it does, can someone link me to an example/tutorial.
推荐答案
这对我有用:
var data = require("self").data;
var {Cc, Ci} = require("chrome");
var mediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);
exports.main = function(options, callbacks) {
addToolbarButton();
// other stuff
};
function addToolbarButton() {
var document = mediator.getMostRecentWindow("navigator:browser").document;
var navBar = document.getElementById("nav-bar");
if (!navBar) {
return;
}
var btn = document.createElement("toolbarbutton");
btn.setAttribute('type', 'button');
btn.setAttribute('class', 'toolbarbutton-1');
btn.setAttribute('image', data.url('img/icon16.png')); // path is relative to data folder
btn.setAttribute('orient', 'horizontal');
btn.setAttribute('label', 'My App');
btn.addEventListener('click', function() {
// use tabs.activeTab.attach() to execute scripts in the context of the browser tab
console.log('clicked');
}, false)
navBar.appendChild(btn);
}
这篇关于Firefox:如何使用附加SDK(Jetpack)添加/修改工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文