11 May 2009

Firefox - 自己打造双击关闭标签栏

不知道为什么,firefox一直没有双击关闭标签栏这个功能,非常不方便
为了它安装一个tab mix plus,又不想.毕竟插件安装多了,firefox会非常臃肿.

Do It Yourself - Using double-click to close tab in firefox without add any plug-ins.

修改方法如下:



1,打开firefox目录,再进入chrome目录,打开browser.manifest,修改

1,Enter the directory of firefox,cd to chrome,open the file named browser.manifest,change the following:
content browser jar:browser.jar!/content/browser/ xpcnativewrappers=yes contentaccessible=yes

to:
content browser file:browser/content/browser/ xpcnativewrappers=yes contentaccessible=yes


2,解压缩browser.jar到browser文件夹,然后进入..\firefox\chrome\browser\content\browser\,修改tabbrowser.xml,找到onTabBarDblClick方法:

2,upzip browser.jar to browser directory,then cd ..\firefox\chrome\browser\content\browser\,change the file named tabbrowser.xml,find the method named onTabBarDblClick(see picture shown below):

<method name="onTabBarDblClick">
        <parameter name="aEvent"/>
        <body>
          <![CDATA[
            // See hack note in the tabbrowser-close-button binding
            if (!this._blockDblClick && aEvent.button == 0 &&
                aEvent.originalTarget.localName == "box") {
              // xxx this needs to check that we're in the empty area of the tabstrip
              var e = document.createEvent("Events");
              e.initEvent("NewTab", true, true);
              this.dispatchEvent(e);
            }
          ]]>
        </body>
      </method>

给if后面增加else语句,变为

add Else condition after if statement like:
<method name="onTabBarDblClick">
        <parameter name="aEvent"/>
        <body>
          <![CDATA[
            // See hack note in the tabbrowser-close-button binding
            if (!this._blockDblClick && aEvent.button == 0 &&
                aEvent.originalTarget.localName == "box") {
              // xxx this needs to check that we're in the empty area of the tabstrip
              var e = document.createEvent("Events");
              e.initEvent("NewTab", true, true);
              this.dispatchEvent(e);
            } else { this.removeTab(this.mCurrentTab);
            }
          ]]>
        </body>
      </method>


3,保存tabbrowser.xml,重新打开Firefox浏览器即可.

3,save tabbrowser.xml,restart your Firefox and Enjoy.

No comments :

Post a Comment