Firefox 扩展开发 install.rdf和chrome.manifest

现在我们以一个hello world扩展为例来说明Firefox 扩展的基本运行方式。先下载 Hello World extension,解压缩,下面假定路径是c:\helloworld.
设置firefox扩展代理文件

Firefox 扩展包实际上就是一个zip压缩文件,显然开发时每做一点改动都重新打包安装会很麻烦。firefox提供了一种代理机制,可以把文件夹作为一个扩展。编辑扩展包中的文件helloworld@mozilla.doslash.org,把内容改为c:\helloworld,复制到配置dev\extensions,运行firefox,会出现提示,安装了新扩展的,但不兼容新版本(如果你用的是2.0以后版本)。

install.rdf
现在我们来看install.rdf文件:

<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>helloworld@mozilla.doslash.org</em:id>
<em:name>Hello World (Firefox 1.5 edition)</em:name>
<em:version>1.0</em:version>
<em:description>Classic first extension from MozillaZine KB</em:description>
<em:creator>Nickolay Ponomarev</em:creator>
<!-- optional items -->
<em:contributor>A person who helped you</em:contributor>
<em:contributor>Another one</em:contributor>
<em:homepageURL>http://kb.mozillazine.org/Getting_started_with_extension_development</em:homepageURL>
<!--em: optionsURL>chrome://sampleext/content/settings.xul</em: optionsURL>
<em:aboutURL>chrome://sampleext/content/about.xul</em:aboutURL>
<em:iconURL>chrome://sampleext/skin/mainicon.png</em:iconURL>
<em:updateURL>http://sampleextension.mozdev.org/update.rdf</em:updateURL-->
<!-- Firefox -->
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>1.5</em:minVersion>
<em:maxVersion>3.5.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

  • helloworld@mozilla.doslash.org,扩展的ID,email格式,但不应该是你实际的email,扩展代理文件用作文件名。
  • em:minVersion,em:maxVersion,兼容的firefox最小和最大版本。

修改em:maxVersion为合适值,重新安装扩展,菜单->工具项会多出了一项红色“Hello World!",点击会弹出一个新窗口。

chrome.manifest

Chrome 指的是应用程序窗口的内容区域之外的用户界面元素的集合,这些用户界面元素包括工具条,菜单,进度条和窗口的标题栏等。Chrome 提供者能为特定的窗口类型(如浏览器窗口)提供 chrome。有三种基本的 chrome 提供者:

* 内容(Content):通常是 XUL 文件。
* 区域(Locale) :存放本地化信息。
* 皮肤(Skin):描述 chrome 的外观。通常包含 CSS 和图像文件。
firefox通过Chrome URIs来存取这些文件,比如chrome://browser/content/browser.xul是浏览器的主界面,在地址栏输入这个URL试试。

文件chrome.manifest用来注册Chrome包和物理地址的对应关系,简单的说明:

content helloworld content/

这句定义了helloworld包的content的实际位置为content/目录,最后的斜线是必须的

overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul

覆盖(overlay):这句把overlay.xul合并到browser.xul上。

locale helloworld en-US locale/en-US/

英语

skin helloworld classic/1.0 skin/

皮肤

style chrome://global/content/customizeToolbar.xul chrome://helloworld/skin/


转载于:https://www.cnblogs.com/memaxiaofeng/archive/2013/04/02/3275502.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值