content restartfirefox chrome/content/ skin restartfirefox classic/1.0 chrome/skin/ locale restartfirefox en-US chrome/locale/en-US/ locale restartfirefox zh-CN chrome/locale/zh-CN/ overlay chrome://browser/content/browser.xul chrome://restartfirefox/content/restartOverlay.xul
<?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"> </Description> </RDF>在description之间定义所需要的属性。必须要有的包括:id、version、type、targetApplication。必须属性写成这样:
<em:id>[email protected]</em:id> <em:version>0.1 </em:version> <em:type>2</em:type> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>4.0</em:minVersion> <em:maxVersion>13.0</em:maxVersion> </Description> </em:targetApplication>targetApplication包含三个内容,id表示目标应用程序的UUID,上面这个id就是Firefox的UUID。minVersion和maxVersion表示支持的目标应用程序的最小最大版本号,上面表示可以安装到Firefox 4.0到Firefox 13.0这些版本,当然现在Firefox已经自动默认支持扩展了,因此maxVersion的意义不大,除非你指定:<em:strictCompatibility>true</em:strictCompatibility>,但这是gecko 10之后才有的一个属性。
<?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>[email protected]</em:id> <em:version>0.1 </em:version> <em:type>2</em:type> <em:targetApplication> <Description> <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> <em:minVersion>4.0</em:minVersion> <em:maxVersion>13.0</em:maxVersion> </Description> </em:targetApplication> <em:iconURL>chrome://restartfirefox/skin/icon.png</em:iconURL> <em:name>FireRestart(simplified)</em:name> <em:description>Restart Firefox quickly, for extension developers。 Added a toolbarbutton to the customize ToolbarPalette, you can drag it to anywhere you like in the toolbar or addon bar。there is also a full version which had added a menuitem to the file menu。</em:description> <em:creator>JumuFENG</em:creator> <em:homepageURL>http://blog.csdn.net/z6482</em:homepageURL> <em:localized> <Description> <em:locale>zh-CN</em:locale> <em:name>FireRestart(精简版)</em:name> <em:description>快速重启firefox,定制工具栏中添加了一个按钮,可手动移动到任何地方。完整版在文件菜单中增加了重新启动菜单项。</em:description> <em:creator>JumuFENG</em:creator> <em:homepageURL>http://blog.csdn.net/z6482</em:homepageURL> </Description> </em:localized> </Description> </RDF>
文件名 |
保存路径 |
chrome URL |
restartOverlay.xul |
chrome\content\ |
chrome://restartfirefox/content/restartOverlay.xul |
restart.js |
chrome\content\ |
chrome://restartfirefox/content/restart.js |
restart.dtd |
chrome\locale\en-US\ |
chrome://restartfirefox/locale/restart.dtd |
chrome\locale\zh-CN\ |
||
restartfirefox.css |
chrome\skin\ |
chrome://restartfirefox/skin/restartfirefox.css |
<?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <overlay id="restartOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> </overlay>根据需要,overlay标签也可以是其他如window、page等等。我们使用了dtd文件,因此在overlay标签前面添加:
<!DOCTYPE overlay SYSTEM "chrome://restartfirefox/locale/restart.dtd">接着引入我们的css文件(之后创建),在global css的引用之后添加:
<?xml-stylesheet href="chrome://restartfirefox/skin/restartfirefox.css" type="text/css"?>要实现重启Firefox,需要使用一个js文件,在添加其他元素之前加上对脚本的引用:
<script type="application/x-javascript" src="chrome://restartfirefox/content/restart.js" />下面添加一个按钮到Firefox的定制工具栏中,这样用户就可以自己选择将这个图标放到工具栏或者附加组件栏中的任何位置。
<toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="restartfirefox-button" class="toolbarbutton-1" oncommand="restartFirefox.ourRestart();" tooltiptext="&Restart;" label="&Restart;" /> </toolbarpalette>
<toolbar id="addon-bar"> <toolbarbutton id="restartfirefox-button" class="toolbarbutton-1" oncommand="restartFirefox.ourRestart();" tooltiptext="&Restart;" label="&Restart;" /> </toolbar>
<?xml version="1.0"?> <?xml-stylesheet href="chrome://restartfirefox/skin/restartfirefox.css" type="text/css"?> <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> <!DOCTYPE overlay SYSTEM "chrome://restartfirefox/locale/restart.dtd"> <overlay id="restartOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <script type="application/x-javascript" src="chrome://restartfirefox/content/restart.js" /> <!-- Firefox Toolbar Overlay --> <toolbarpalette id="BrowserToolbarPalette"> <toolbarbutton id="restartfirefox-button" class="toolbarbutton-1" oncommand="restartFirefox.ourRestart();" tooltiptext="&Restart;" label="&Restart;" /> </toolbarpalette> </overlay>
var restartFirefox = { // main restart logic ourRestart : function() { nsIAppStartup = Components.interfaces.nsIAppStartup; Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(nsIAppStartup) .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); } };
#restartfirefox-button { list-style-image: url("chrome://restartfirefox/skin/icon.png"); } toolbar[iconsize="small"] #restartfirefox-button { list-style-image: url("chrome://restartfirefox/skin/iconsmall.png"); }
var restartFirefox = { ourRestart : function() { window.open(“chrome://restartfirefox/content/test.xul”); } };