翻译http://kb.mozillazine.org/index.php?title=Extension_development

扩展开发 Extension development

From MozillaZine Knowledge Base

This page is part of the extension development documentation project .

Ask your questions in MozillaZine Forums . Also try browsing example code .

Note: development documentation is in process of being moved to Mozilla Development Center (MDC).

目录  Contents

<script type="text/javascript"> </script>

介绍  Introduction

Extensions allow programmers to add new features to Mozilla applications or allow existing features to be modified. Typically, extensions modify the “chrome” of their target application—the user interface and the scripts that add functionalty to that interface. However, it is also possible for extensions to include compiled code in the form of XPCOM components.

扩展技术  Extension technologies

You will almost certainly need to use the following technologies, although it is not necessary to be an expert in them. You may be able to pick up much of what you need just by examining the source code for other extensions.

  • XUL (XML User-Interface Language) . Used to define the onscreen layout of the UI and to attach scripts and style to the interface.
  • JavaScript . The primary scripting language in Mozilla and the language in which most extensions are written.
  • DOM (Document Object Model) . Used to manipulate XUL in real-time as well as any HTML documents loaded.
  • XPCOM/XPConnect . Mozilla packages together useful functions into XPCOM (Cross-Platform Component Object Model) components, which may then be accessed from external code, including JavaScript via XPConnect. This allows the extension developers access to the preferences database, the filesystem , and many other pieces of Mozilla technology (Extensions can be written in JavaScript, C++, or even Python with PyXPCOM ).
  • CSS (Cascading Style Sheets) . Used to style the interface and to attach XBL bindings to XUL documents.

More advanced extensions may require the following technologies.

开始  Getting started

Setting up your environment

  • Please see Setting up extension development environment for development preferences you can set and extensions you can install. It also contains information about running a separate instance of Firefox using a development profile.
  • Getting started with extension development contains tips on easily setting up extensions development environment in Firefox/Thunderbird 1.5 (so that you no longer have to recreate the JAR and/or XPI files each time you make a change in your extension). It is also a quickstart guide containing useful links for beginners and the obligatory helloworld extension, which can be used as a basis of your extensions.

Tutorials

There is a variety of third-party tutorials available which will help with general extension development or with learning specific technologies.

On this Knowledge Base and Mozilla's website:

其他网站  On other websites:

博客  Weblogs:

书籍  Books

As well as web resources, there are a couple of books available describing Mozilla technologies and their usage. Both books cover a comprehensive range of Mozilla technologies. They are available both online and in a more user-friendly dead-tree format.

完成  Getting finished

To make your extension available to others, you need to package it as XPI and release it (make sure you thoroughly test it first!).

改进  Making it better

  • Be sure to make your extensions localizable: Use DTDs for XUL and properties for scripts.
  • Themes apply CSS using various selectors, particularly based on id and class attributes on your elements. Include these to make theme development easier.
  • Try to follow the set of Extension guidelines . This can help to make all extensions act predictably, which increases usability.

更多信息  Further Information

Local resources

Example code
  • Example Code . Common development tasks and techniques.
  • Example Extensions . Extensions that provide a clear demonstration of a particular technique or function.

Coding style

Development fundamentals
  • General advice for extension development, including how to avoid rebuilding JAR files and how to correctly register overlays.

Troubleshooting

文件位置  File locations
  • Chrome URLs . 各个chrome的位置,找到它,重载它。
  • Chrome URLs . Discover the location within the installation folder of the chrome you wish to overlay.

其他资源  Other resources

获得帮助  Getting help

  • MozillaZine provides a Development forum which is the place for technical questions and an Extensions forum which occasionally has technical discussion but is more useful for releasing extensions to get testing and feedback.
  • The mozilla.dev.* newsgroups are the official location for code-related queries. They are particularly useful if you're implementing an XPCOM component or have a question that MozillaZine posters can't answer. See the developer forums page for a description of each newsgroup.
  • IRC (see also this ). Live Developers! Get satisfaction online from red hot developers! (Note: this is not a dating service.), #extdev is the place to be!

参与  Get involved

  • Take a look at Dev : Project ideas to see the list of requested extensions.
  • Help maintaining the Extension development knowledge base. Post your tips and code snippets for others to use. (You may use the MozillaZine forums (preferably Development or Extensions ) to discuss the tips.) Also consider helping the Devmo project .
  • Contribute to existing extensions.
  • List ideas at (or borrow ideas from) AllYourIdeas extension category
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值