如何编写Firefox扩展
生活随笔
收集整理的這篇文章主要介紹了
如何编写Firefox扩展
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如何編寫Firefox擴展(1)-技術準備
使用Firefox很長時間了,很喜歡這只"小狐貍",特別是它提供的豐富多彩的擴展功能。一直都想學習一下關于編寫Firefox的擴展的知識,現在終于可以開始了,我將邊學邊把自己所掌握的知識書寫出來,以方便大家學習.
收集了一些編寫Firefox擴展的相關資料,如果英文夠好,請直接查看這些資料,完全忽略我的文章
Extension development
Getting started with extension development
How to write Firefox extensions using BugMeNot as an example
How to create Firefox extensions
Writing an Extension for Firefox
Firefox Extension Tutorial
Building an Extension
下面是編寫Firefox擴展所需掌握的相關技術
開發Firefox擴展的過程中,將會接觸到以下技術,您不需要精通這些東西,但最好能對他們都比較熟悉.
XUL (XML User-Interface Language).基于xml的UI界面定義技術
JavaScript. 這個不用多講了,大多數擴展使用它來完成.
DOM (Document Object Model). HTML文檔結構模型.
XPCOM/XPConnect. 用來連接Mozilla 提供的XPCOM (Cross-Platform Component Object Model) 功能組件包, 可以用來訪問 preferences 配置數據庫, filesystem文件系統 以及其他Mozilla提供的功能(可以使用 JavaScript, C++, 甚至是 Python PyXPCOM來編寫這個擴展).
CSS (Cascading Style Sheets).
XBL (XML Binding Language). 用來擴展XUL, 允許創建新的風格的UI界面.
RDF (Resource Description Framework). 在擴展中,用來描述某些數據的存儲格式。.
如何編寫Firefox擴展(2)-配置開發環境
想要快速方便的開發Firefox擴展,配置一下開發環境,做些必要的準備是必須的。
設置Firefox配置
為了避免開發中的擴展平時使用的Firefox的性能,我們需要重新創建一個配置,并且將其命名為"dev",然后用以下的命令行來啟動這個配置為開發環境的Firefox
start "" "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev
想要運行默認的配置,使用 "firefox" 或 "firefox -P default".
您還可以同時運行穩定版和開發中的Firefox版本,來檢查擴展的兼容性y (Installing Firefox 3 or Minefield while keeping Firefox 2).
開發環境配置
下面的這些配置可以使開發調試擴展更加方便。查看 Editing Configuration Files 了解更多信息。 下面的這些選項,默認是不會在about:config中列出來的,所以需要手工添加它們。方法是,在你的firefox的配置目錄下找到user.js ,如果文件不存在,就手工創建一個,然后添加以下幾行
user_pref("nglayout.debug.disable_xul_cache",true);
user_pref("browser.dom.window.dump.enabled",true);
提示:firefox3.0中user.js已經被prefs.js代替了
下面是一些可用的配置選項、
javascript.options.showInConsole = true. 記錄錯誤日志到 Error Console.
nglayout.debug.disable_xul_cache = true. 禁止XUL緩存,這樣當修改界面元素時,就不需要重新啟動firefox了。此選項只有當你使用了目錄而不是jar的格式安裝擴展時有效,并且修改XUL的行為時仍然需要重新啟動。
browser.dom.window.dump.enabled = true. 允許使用dump() 命令輸出信息到標準控制臺 See window.dump for more info. You can also use nsIConsoleService from privileged script.
javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with Console2.
extensions.logging.enabled = true. This will send more detailed information about installation and update problems to the Error Console.
用來輔助進行Firefox擴展開發的一些Firefox擴展
名字有點拗口,但絕對都是好東西
DOM Inspector, an option of a custom installation.
Venkman, a JavaScript 的調試工具.
Extension Developer's Extension 擴展開發工具,可以用來生成xpi文件,設置開發選項,等等,強烈推薦。
Console2
Chrome List
Firebug javascript,http調試工具,功能強大,強烈推薦
Execute JS
XPCOMViewer, an XPCOM inspector
自定義代碼位置
為了使每次修改代碼后,不需要重復的進行擴展的安裝,你可以將你的源碼放到Firefox的配置目錄下,Firefox會自動檢測并加載你的擴展
在 install.rdf 中找到擴展編號,如 em:id="{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}"
在your_profile_directory/extensions/ 目錄下創建一個目錄,目錄名為剛剛找到的編號(eg. `your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}`) (Find your profile directory)
將你的開發文件,復制到這個目錄下
重新啟動Firefox.
使用Firefox很長時間了,很喜歡這只"小狐貍",特別是它提供的豐富多彩的擴展功能。一直都想學習一下關于編寫Firefox的擴展的知識,現在終于可以開始了,我將邊學邊把自己所掌握的知識書寫出來,以方便大家學習.
收集了一些編寫Firefox擴展的相關資料,如果英文夠好,請直接查看這些資料,完全忽略我的文章
Extension development
Getting started with extension development
How to write Firefox extensions using BugMeNot as an example
How to create Firefox extensions
Writing an Extension for Firefox
Firefox Extension Tutorial
Building an Extension
下面是編寫Firefox擴展所需掌握的相關技術
開發Firefox擴展的過程中,將會接觸到以下技術,您不需要精通這些東西,但最好能對他們都比較熟悉.
XUL (XML User-Interface Language).基于xml的UI界面定義技術
JavaScript. 這個不用多講了,大多數擴展使用它來完成.
DOM (Document Object Model). HTML文檔結構模型.
XPCOM/XPConnect. 用來連接Mozilla 提供的XPCOM (Cross-Platform Component Object Model) 功能組件包, 可以用來訪問 preferences 配置數據庫, filesystem文件系統 以及其他Mozilla提供的功能(可以使用 JavaScript, C++, 甚至是 Python PyXPCOM來編寫這個擴展).
CSS (Cascading Style Sheets).
XBL (XML Binding Language). 用來擴展XUL, 允許創建新的風格的UI界面.
RDF (Resource Description Framework). 在擴展中,用來描述某些數據的存儲格式。.
如何編寫Firefox擴展(2)-配置開發環境
想要快速方便的開發Firefox擴展,配置一下開發環境,做些必要的準備是必須的。
設置Firefox配置
為了避免開發中的擴展平時使用的Firefox的性能,我們需要重新創建一個配置,并且將其命名為"dev",然后用以下的命令行來啟動這個配置為開發環境的Firefox
start "" "%ProgramFiles%\Mozilla Firefox\firefox.exe" -no-remote -P dev
想要運行默認的配置,使用 "firefox" 或 "firefox -P default".
您還可以同時運行穩定版和開發中的Firefox版本,來檢查擴展的兼容性y (Installing Firefox 3 or Minefield while keeping Firefox 2).
開發環境配置
下面的這些配置可以使開發調試擴展更加方便。查看 Editing Configuration Files 了解更多信息。 下面的這些選項,默認是不會在about:config中列出來的,所以需要手工添加它們。方法是,在你的firefox的配置目錄下找到user.js ,如果文件不存在,就手工創建一個,然后添加以下幾行
user_pref("nglayout.debug.disable_xul_cache",true);
user_pref("browser.dom.window.dump.enabled",true);
提示:firefox3.0中user.js已經被prefs.js代替了
下面是一些可用的配置選項、
javascript.options.showInConsole = true. 記錄錯誤日志到 Error Console.
nglayout.debug.disable_xul_cache = true. 禁止XUL緩存,這樣當修改界面元素時,就不需要重新啟動firefox了。此選項只有當你使用了目錄而不是jar的格式安裝擴展時有效,并且修改XUL的行為時仍然需要重新啟動。
browser.dom.window.dump.enabled = true. 允許使用dump() 命令輸出信息到標準控制臺 See window.dump for more info. You can also use nsIConsoleService from privileged script.
javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console. Note that since many people have this setting turned off when developing, you will see lots of warnings for problems with their code in addition to warnings for your own extension. You can filter those with Console2.
extensions.logging.enabled = true. This will send more detailed information about installation and update problems to the Error Console.
用來輔助進行Firefox擴展開發的一些Firefox擴展
名字有點拗口,但絕對都是好東西
DOM Inspector, an option of a custom installation.
Venkman, a JavaScript 的調試工具.
Extension Developer's Extension 擴展開發工具,可以用來生成xpi文件,設置開發選項,等等,強烈推薦。
Console2
Chrome List
Firebug javascript,http調試工具,功能強大,強烈推薦
Execute JS
XPCOMViewer, an XPCOM inspector
自定義代碼位置
為了使每次修改代碼后,不需要重復的進行擴展的安裝,你可以將你的源碼放到Firefox的配置目錄下,Firefox會自動檢測并加載你的擴展
在 install.rdf 中找到擴展編號,如 em:id="{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}"
在your_profile_directory/extensions/ 目錄下創建一個目錄,目錄名為剛剛找到的編號(eg. `your_profile_directory/extensions/{46D1B3C0-DB7A-4b1a-863A-6EE6F77ECB58}`) (Find your profile directory)
將你的開發文件,復制到這個目錄下
重新啟動Firefox.
轉載于:https://www.cnblogs.com/jannock/archive/2008/09/22/1295774.html
總結
以上是生活随笔為你收集整理的如何编写Firefox扩展的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 配置gpgpu-sim——基于ubunt
- 下一篇: matlab画根轨迹的渐近线,根轨迹的渐