Firefox 扩展开发 install.rdf和chrome.manifest
2013-04-02 16:11
375 查看
现在我们以一个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文件:
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/
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/
相关文章推荐
- Mozilla Firefox Extension扩展 内幕 教程 源代码分析 安装过程分析(XPInstall,xpcom,rdf,xpi,chrome,manifest)
- Mozilla Firefox Extension扩展 内幕 教程 源代码分析 安装过程分析(XPInstall,xpcom,rdf,xpi,chrome,manifest)
- 常见浏览器扩展开发笔记(chrome firefox 360 baidu qq sougou liebao uc opera)
- 【分享】Firefox和Chrome扩展开发
- Firefox 自动化插件开发 (安装包出现 Warning: Ignoring unrecognized chrome manifest instruction. )
- 【分享】Firefox和Chrome扩展开发
- 【转发】NPAPI学习(Firefox和Chrome扩展开发 )
- 【分享】Firefox和Chrome扩展开发
- 分享Chrome Extension(扩展程序/插件)开发的一些小经验
- Chrome扩展开发指南(7)——Themes(主题制作)
- Chrome扩展及应用开发 入门笔记(一)
- 基于Chrome的扩展开发(二)
- Firefox 3.6 Web应用开发人员的扩展
- [Firefox][扩展系列][01]开发环境准备
- Firefox扩展开发: Hello World!
- 手把手教你开发chrome扩展一:开发Chrome Extenstion其实很简单
- 黄聪:Firefox火狐插件扩展开发教程
- Chrome 56 扩展开发入门:Hello
- 初次尝试Chrome扩展开发——以幻灯片方式显示网页内的图片