Chinaunix首页 | 论坛 | 博客
  • 博客访问: 538383
  • 博文数量: 83
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1169
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-29 22:34
文章分类

全部博文(83)

文章存档

2011年(3)

2010年(29)

2009年(30)

2008年(21)

我的朋友

分类: LINUX

2009-09-02 21:11:20

参考了以上2篇教程,主要是后面一篇。
 
下面是我的心得,其实也就是拿了其中一些来翻译。
插件的层次结构,插件(xpi)其实是一个zip格式的文档,可以直接解压,解压后的文档结构如:

helloworld@janodvarko.cz/
    chrome/
        content/
            helloworld/
                helloWorld.xul
                helloWorld.js
    chrome.manifest
    install.rdf

1 文件chrome.manifest

content helloworld chrome/content/helloworld/ xpcnativewrappers=no
overlay chrome://firebug/content/firebugOverlay.xul chrome://helloworld/content/helloWorld.xul

我的理解是,content指明了插件安装的目录结构,比如这里的意思是把“chrome/content/helloworld/”安装(拷贝)到名为“hellworld”这个插件的目录中。所有插件默认的安装目录都在“C:\Documents and Settings\kennethwu\Application Data\Mozilla\Firefox\Profiles\xxx.default\extensions”里。

overlay A B语句的大概的意思是说在加载文件A的基础上再加载B

关于该文件的说明看https://developer.mozilla.org/en/Chrome_Registration

2 文件install.rdf

<?xml version="1.0"?><RDF xmlns=""
  xmlns:em="">

  <Description about="urn:mozilla:install-manifest">
    <em:id>helloworld@janodvarko.cz</em:id>
    <em:version>0.0.1</em:version>

    <!-- Firefox -->
    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>1.5</em:minVersion>
        <em:maxVersion>3.0.0.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <!-- Extension -->
    <em:name>Hello World!:
name>
    <em:description>Firebug Hello Extension</em:description>
    <em:creator>Jan Odvarko</em:creator>
    <em:homepageURL>http://www.janodvarko.cz</em:homepageURL>
  </Description>
</RDF>

是一个对象的ID,用于唯一标识一个对象,有2种写法,如

  • helloworld@janodvarko
  • {ec8030f7-c20a-464f-9b0e-13a3a9e97384}

<em:targetApplication>Firefox那一项是指定插件所依附的浏览器平台信息,如这里说明的是id为{ec8030f7-c20a-464f-9b0e-13a3a9e97384}的浏览器,版本最大为3.0.0.*,最小为1.5

关于该文件的说明看https://developer.mozilla.org/en/install.rdf,下面是简单的介绍

An Install Manifest is the file an Add-on Manager-enabled XUL application uses to determine information about an addon as it is being installed. It contains metadata identifying the addon, providing information about who created it, where more information can be found about it, which versions of what applications it is compatible with, how it should be updated, and so on.

The format of the Install Manifest is RDF/XML.

The file must be called install.rdf and live at the top level of an addon

3 文件helloWorld.xul

<?xml version="1.0"?>
<overlay xmlns="">
  <script src="chrome://helloworld/content/helloWorld.js" type="application/x-javascript"/>
</overlay>

这里信息很简单,只包含一个js文件。

4 文件helloWorld.js

FBL.ns(function() { with (FBL) {


function HelloWorldPanel() {}
HelloWorldPanel.prototype = extend(Firebug.Panel,
{
    name: "HelloWorld",
    title: "Hello World!",

    initialize: function() {
      Firebug.Panel.initialize.apply(this, arguments);
    },
});

Firebug.registerPanel(HelloWorldPanel);
}})

该js文件往firebug里注册一个面板

阅读(823) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~