在Firefox中,如何禁用URL栏中的“切换到标签”?


13

在Firefox 4中,URL栏自动完成弹出窗口现在具有一个名为“切换到标签”的条目,用于已在其他标签中打开的URL。

我从不想要这个,并且总是最终被误击中。有没有办法禁用它?

FF的大多数新功能似乎都about:config可以关闭它们,但是我没有看到任何明显的变化。


1
+1。我讨厌1000个太阳的狂怒。
RJFalconer

Answers:


3

在Google上进行的快速搜索显示,mozillazine.org上堆积如山。(http://forums.mozillazine.org/viewtopic.php?f=23&t=1977593

lithopsian的代码(最初位于http://forums.mozillazine.org/viewtopic.php?f=23&t=1977593&start=30

显然,这在现有扩展中,但是可以将代码放置在您喜欢的任何位置。

这样的CSS:

#urlbar
{
    -moz-binding: url("chrome://NoTabs/content/NoTabs.xml#NoTabsUrlbar");
}

.autocomplete-richlistitem
{
    -moz-binding: url("chrome://NoTabs/content/NoTabs.xml#NoTabsRichlistitem");
}

像这样的绑定替换了两个关键方法:

<?xml version="1.0" encoding="UTF-8"?>
<bindings id="NoTabs-urlbarBindings"
      xmlns="http://www.mozilla.org/xbl"
      xmlns:html="http://www.w3.org/1999/xhtml"
      xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
      xmlns:xbl="http://www.mozilla.org/xbl">

  <binding id="NoTabsUrlbar" extends="chrome://browser/content/urlbarBindings.xml#urlbar">
    <implementation implements="nsIObserver, nsIDOMEventListener">

      <!--
        onBeforeValueSet is called by the base-binding's .value setter.
        It should return the value that the setter should use.
      -->
      <method name="onBeforeValueSet">
        <parameter name="aValue"/>
        <body><![CDATA[
          this.removeAttribute("actiontype");
          this._value = aValue;
          var returnValue = aValue;
          var action = this._parseActionUrl(aValue);
          if (action) returnValue = action.param;
          return returnValue;
        ]]></body>
      </method>

    </implementation>
  </binding>

  <binding id="NoTabsRichlistitem" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-richlistitem">
    <implementation implements="nsIDOMXULSelectControlItemElement">

      <method name="_adjustAcItem">
        <body>
          <![CDATA[
          var url = this.getAttribute("url");
          var title = this.getAttribute("title");
          var type = this.getAttribute("type");

          this.removeAttribute("actiontype");

          var setupUrl = true;

          // If the type includes an action, set up the item appropriately.
          var types = type.split(/\s+/);
          var actionIndex = types.indexOf("action");
          if (actionIndex >= 0) {
            let [,action, param] = url.match(/^moz-action:([^,]+),(.*)$/);
            url = param;

            // Remove the "action" substring so that the correct style, if any,
            // is applied below.
            types.splice(actionIndex, 1);
            type = types.join(" ");
          }

          // If we have a tag match, show the tags and icon
          if (type == "tag") {
            // Configure the extra box for tags display
            this._extraBox.hidden = false;
            this._extraBox.childNodes[0].hidden = false;
            this._extraBox.childNodes[1].hidden = true;
            this._extraBox.pack = "end";
            this._titleBox.flex = 1;

            // The title is separated from the tags by an endash
            let tags;
            [, title, tags] = title.match(/^(.+) \u2013 (.+)$/);

            // Each tag is split by a comma in an undefined order, so sort it
            let sortedTags = tags.split(",").sort().join(", ");

            // Emphasize the matching text in the tags
            this._setUpDescription(this._extra, sortedTags);

            // Treat tagged matches as bookmarks for the star
            type = "bookmark";
          } else if (type == "keyword") {
            // Configure the extra box for keyword display
            this._extraBox.hidden = false;
            this._extraBox.childNodes[0].hidden = true;
            this._extraBox.childNodes[1].hidden = false;
            this._extraBox.pack = "start";
            this._titleBox.flex = 0;

            // Put the parameters next to the title if we have any
            let search = this.getAttribute("text");
            let params = "";
            let paramsIndex = search.indexOf(' ');
            if (paramsIndex != -1)
              params = search.substr(paramsIndex + 1);

            // Emphasize the keyword parameters
            this._setUpDescription(this._extra, params);

            // Don't emphasize keyword searches in the title or url
            this.setAttribute("text", "");
          } else {
            // Hide the title's extra box if we don't need extra stuff
            this._extraBox.hidden = true;
            this._titleBox.flex = 1;
          }

          // Give the image the icon style and a special one for the type
          this._typeImage.className = "ac-type-icon" +
            (type ? " ac-result-type-" + type : "");

          // Show the url as the title if we don't have a title
          if (title == "")
            title = url;

          // Emphasize the matching search terms for the description
          this._setUpDescription(this._title, title);
          if (setupUrl)
            this._setUpDescription(this._url, url);

          // Set up overflow on a timeout because the contents of the box
          // might not have a width yet even though we just changed them
          setTimeout(this._setUpOverflow, 0, this._titleBox, this._titleOverflowEllipsis);
          setTimeout(this._setUpOverflow, 0, this._urlBox, this._urlOverflowEllipsis);
          ]]>
        </body>
      </method>
    </implementation>
  </binding>
</bindings>

1
哇,真吓人。我希望有一天可以将其扩展。

@Ken:有人将此扩展了,但是自Beta 12起似乎不起作用,作者还没有更新。
2011年

拒绝投票,因为此解决方案已过期。Our_Benefactors的解决方案适用于现代版本的Firefox。
Our_Benefactors

2

这是为Firefox Quantum禁用它的方法(测试版68)

  1. 汉堡菜单
  2. 选项(在Mac / Linux上为首选项)(about:preferences
  3. 隐私权和安全性(about:preferences#privacy
  4. 地址栏
  5. 取消选中打开标签

而已!


2
这是所有答案中仅有的一个实际上可以解决当前Firefox的问题。
FUZxxl
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.