1.37k likes | 1.47k Views
Chapter 3 Building your own Extensions. Development Environment. Must Haves ・Text Editor (UTF-8 compatible) ・File Archiver (ZIP compatible). Nice to Have ・ JavaScript debugger (Venkman) ・ Hidden preferences for development. Text Editor. Hidemaru Editor http://hide.maruo.co.jp/
E N D
Chapter 3 Building your own Extensions
Must Haves ・Text Editor (UTF-8 compatible) ・File Archiver (ZIP compatible)
Nice to Have ・JavaScript debugger (Venkman) ・Hidden preferences for development
Hidemaru Editor http://hide.maruo.co.jp/ TeraPad http://www5f.biglobe.ne.jp/~t-susumu/
7-Zip http://www.7-zip.org/
Venkman JavaScript debugger https://addons.mozilla.org/firefox/216 Japanese language package http://piro.sakura.ne.jp/latest/blosxom.cgi/mozilla/extension/2005-09-30_venkman-ja.htm
・browser.dom.window.dump.enabled Enables dump output to console →true ・javascript.options.showInConsole Enables errors to be reported to console →true
Create a new profile for development work
・firefox.exe -p Start profile manager ・firefox.exe -p "foobar" Start up using specific profile ・firefox.exe -p "foobar" -no-remote Start multiple Firefox instances using different profiles
Now, on to actually building an Extension
Try modifying the Firefox code first
C:\Program Files \Mozilla Firefox \chrome\browser.jar
Implementation steps for the Firefox browser
Step1. Extract browser.jar Step2. Modify browser.xul Step3. Compress browser.jar Step4. Double check * It's a good idea to back up a copy of browser.jar
Displaying a “Hello, world!!” message
content\browser\browser.xul <menuitem observes="blockedPopupAllowSite"/> <menuitem observes="blockedPopupEditSettings"/> <menuitem observes="blockedPopupDontShowMessage"/> <menuseparator observes="blockedPopupsSeparator"/> </menupopup> </statusbarpanel> </statusbar> <label value="Hello, world!!"/> </window> Add this to the end of the file
Display “Hello, world!!” in the “Tools” menu
content\browser\browser.xul <menu id="tools-menu" label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;"> <menupopup id="menu_ToolsPopup"> <menuitem label="&search.label;" accesskey="&search.accesskey;" key="key_search" command="Tools:Search"/> (snipped) <menuitem accesskey="&pageInfoCmd.accesskey;" label="&page...l;" command="View:PageInfo"/> <menuitem id="hellloworldMenuitem" label="Hello, world!"/> <menuseparator id="sanitizeSeparator"/> <menuitem id="sanitizeItem" accesskey="&clearPrivateDataCmd.accesskey;" label="&clearPrivateDataCmd.label;" key="key_sanitize" command="Tools:Sanitize"/> (snipped) </menupopup> </menu> Add this to the file
Upload your work to ftp://sfc-ftp.ai3.net/ ~incoming/mozilla24-ws/
http://piro.sakura.ne.jp/ xul/doc/20070726keio/XUL3-1.zip
Step1. Prepare files and folders Step2. Create manifest file Step3. Create XPI package
helloworld chrome content overlay.xul install.rdf chrome.manifest
Isolate the XUL modifications for the overlay file
(snipped) <menu id="tools-menu" label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;"> <menupopup id="menu_ToolsPopup"> (snipped) <menuitem id="hellloworldMenuitem" label="Hello, world!"/> (snipped) </menupopup> </menu> (snipped) overlay.xul <?xml version="1.0" encoding="UTF-8"?> <overlay id="helloworldOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <menupopup id="menu_ToolsPopup"> <menuitem id="helloworldMenuitem" label="Hello, world!" insertbefore="sanitizeSeparator"/> </menupopup> </overlay>
overlay.xul <?xml version="1.0" encoding="UTF-8"?> <overlay id="helloworldOverlay" xmlns="http://www.mozilla.org/ keymaster/gatekeeper/there.is.only.xul"> <menupopup id="menu_ToolsPopup"> <menuitem id="helloworldMenuitem" label="Hello, world!" insertbefore="sanitizeSeparator"/> </menupopup> </overlay>
Creating a manifest file
1 install.rdf extension metadata
install.rdf <?xml version="1.0" encoding="UTF-8"?> <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@piro.sakura.ne.jp</em:id> <em:type>2</em:type> <em:name>Hellow, world!</em:name> <em:version>0.1</em:version> <em:description>My first extension.</em:description> <em:creator>SHIMODA Hiroshi</em:creator> <em:homepageURL>http://piro.sakura.ne.jp/xul/</em:homepageURL> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>2.0</em:minVersion> <em:maxVersion>2.0.0.*</em:maxVersion> </em:targetApplication> </Description> </RDF>
install.rdf (1) <?xml version="1.0" encoding="UTF-8"?> <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@piro.sakura.ne.jp</em:id> <em:type>2</em:type> <em:name>Hellow, world!</em:name> <em:version>0.1</em:version> <em:description>My first extension.</em:description> <em:creator>SHIMODA Hiroshi</em:creator> <em:homepageURL>http://piro.sakura.ne.jp/xul/</em:homepageURL>
install.rdf (2) <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>2.0</em:minVersion> <em:maxVersion>2.0.0.*</em:maxVersion> </em:targetApplication> </Description> </RDF> IDs that can be assigned to targetApplication Firefox :{ec8030f7-c20a-464f-9b0e-13a3a9e97384} Thunderbird :{3550f703-e582-4d05-9a08-453d09bdfdc6}
2 chrome.manifest file path and designating overlay
chrome.manifest content helloworld chrome/content/ overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul
chrome.manifest(1) content helloworld chrome/content/ chrome://helloworld/content/ Chrome URL
chrome.manifest(2) overlay chrome://browser/content/browser.xul chrome://helloworld/content/overlay.xul browser.xul
chrome.manifest(2) overlay chrome://browser/content/browser.xulchrome://helloworld/content/overlay.xul overlay.xul browser.xul