一個FireFox 附加元件副檔名為xpi,由zip 變形(也就是把副檔名xpi 改成zip 就可以解壓縮),其內包含install.rdf、chrome.manifest,

 

其中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#"> //這些檔頭都不會變,照抄就好。

] //這裡要嵌入主要資訊。

]</RDF>

 

標籤RDF 中間要嵌入主要資訊。每一項資訊(也就是一個屬性) 都用一個標籤包住,「<em:屬性名稱>屬性值</em:屬性名稱>」。其屬性有id,為GuidGen ID,從網路上隨便取一組就行了,且編號要用{} 包起來;name,描述附加元件名稱;version,描述版本,構成方式為「0.0.0」(兩個小數點);description,描述附加元件用途;developer、homepageURL、iconURL,其中iconURL 可以用以install.rdf 為中心的相對路徑載入;unpack,描述內部元件是否沒有包裝成jar 檔案,如果有則為false,如果沒有則為true;targetApplication 是描述該附加元件適用於哪一個軟體(因為這些附加元件適用於Mozilla 旗下多項產品),其包含三個子屬性: id 是該軟體的GuidGen ID,minVersion 與maxVersion 描述此附加元件適用於該軟體的何種版本。

]<em:id>{bf716f23-e4b0-46ec-9269-b9a389fa5bf6}</em:id> //GuidGen 編號從「www.guidgen.com」就可以得到。

]<em:name>testAddon</em:name>

]<em:version>10.2.33</em:version>

]<em:description>這是對testAddon 的描述,可以打中文</em:description>

]<em:developer>testAuthor</em:developer>

]<em:homepageURL>http://www.google.com.tw/</em:homepage>

]<em:iconURL>chrome/testIcon.png</em:iconURL>

]<em:unpack>true</em:unpack>

]<em:targetApplication>

]<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> //這是FireFox 版本3.5 到8.0a2 的GuidGen ID,不同版本可能會有不同的GuidGen ID。

]<em:minVersion>3.5</em:minVersion>

]<em:maxVersion>8.0a2</em:maxVersion>

]</em:targetApplication>

 

chrome.manifest 則是用來設定路徑的。一般來說,有三個路徑可以設定,content、overlay、locale,三者有不同的設定方法。

 

content 的設定語法為: content 附加元件名稱 相對路徑。其中,若資料被封裝成jar 檔案,則可使用「jar:相對路徑(jar 對於chrome.manifest)!/」,把jar 檔當作一個路徑,content、overlay、locale 三者的相對路徑都可以使用這種方式把jar 當成路徑。

]content testA chrome/content/

]content testB jar:chorme/testContent.jar!/content/ //表示content 路徑被宣告在封裝成testContent.jar 裡的content 資料夾。

 

overlay 設定語法為: overlay 路徑,從 路徑,到。其中路經皆為「chrome 中心路徑」,也就是以「chrome://」開頭,以附加元件中的chrome 目錄為中心的相對路徑。

]overlay chrome://browser/content/browser.xul chrome://content/overlay.xul //對不起,「chrome://browser/content/browser.xul」代表什麼本人也不知道。

 

locale 設定語法為: locale 附加元件名稱 語言 相對路徑。

]locale testA zh-tw chrome/locale/zh-tw/

]locale testB en-US jar:chrome/testLocale.jar/locale/zh-tw/

文章標籤
全站熱搜
創作者介紹
創作者 GPhettoH 的頭像
GPhettoH

歇息,等待明日的天空

GPhettoH 發表在 痞客邦 留言(0) 人氣(99)