Windows 10 will reach EOS (end of support) on October 14, 2025. For more information, see this article.

Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Ulteriori informazioni

Is there an API that allows extensions to change vertical tab related settings?

  • 3 risposte
  • 0 hanno questo problema
  • 40 visualizzazioni
  • Ultima risposta di regunakyle

more options

Hi, I want to make a simple extension for Firefox that auto toggles vertical tab based on the aspect ratio of the Firefox window. I found `sidebar.verticalTabs` in about:config that toggles vertical tabs, but a simple googling tells me that it is not possible for web extension to modify about:config values. Is there any other API that toggle vertical tabs? Thanks!

Hi, I want to make a simple extension for Firefox that auto toggles vertical tab based on the aspect ratio of the Firefox window. I found `sidebar.verticalTabs` in about:config that toggles vertical tabs, but a simple googling tells me that it is not possible for web extension to modify about:config values. Is there any other API that toggle vertical tabs? Thanks!

Soluzione scelta

Turns out there is a browserSettings API for vertical tabs after all, but it is on Firefox 142.0 and later.

Kudos to u/Random3838 on r/firefox. Related bugzillas: https://bugzilla.mozilla.org/show_bug.cgi?id=1946600 https://bugzilla.mozilla.org/show_bug.cgi?id=1762975

Leggere questa risposta nel contesto 👍 0

Tutte le risposte (3)

more options

Well, seems like there is no web extension API that can change vertical tab behavior. Instead I created a hack: autoconfig.js

autoconfig.js ```javascript // This file should be in <Firefox binary dir>/defaults/pref pref("general.config.filename", "auto-toggle-vertical-tabs.js"); pref("general.config.obscure_value", 0); pref("general.config.sandbox_enabled", false); ```

auto-toggle-vertical-tabs.js ```javascript // DO NOT DELETE THIS LINE // This file should go to <Firefox binary dir> // support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig

"use strict";

function shouldUseVerticalTabs(width, height) {

 return width <= 1080;

}

try {

 let { classes: Cc, interfaces: Ci, manager: Cm, utils: Cu } = Components;
 var Services =
   globalThis.Services ||
   ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
 function ConfigJS() {
   Services.obs.addObserver(this, "chrome-document-global-created", false);
 }
 ConfigJS.prototype = {
   observe: function (aSubject) {
     aSubject.addEventListener("DOMContentLoaded", this, { once: true });
   },
   handleEvent: function (aEvent) {
     let document = aEvent.originalTarget;
     let window = document.defaultView;
     let location = window.location;
     window.addEventListener("resize", () => {
       if (shouldUseVerticalTabs(window.innerWidth, window.innerHeight)) {
         pref("sidebar.verticalTabs", true);
       } else {
         pref("sidebar.verticalTabs", false);
       }
     });
   },
 };
 if (!Services.appinfo.inSafeMode) {
   new ConfigJS();
 }

} catch (e) {

 Cu.reportError(e);

} ```

The only problem with this script is that vertical tab is a global setting. If you have two windows, one width <= 1080, another width > 1080, then there will be an infinite loop and you will have to forcefully kill one of the window.

There is already a feature request of making vertical tab a per-window setting. You can upvote it here: https://connect.mozilla.org/t5/ideas/vertical-tabs-per-window/idi-p/94064

Modificato da regunakyle il

È stato utile?

more options

Hi

I recommend that you ask about this in the dedicated Add-ons development forum at:

https://discourse.mozilla.org/c/add-ons/35

È stato utile?

more options

Soluzione scelta

Turns out there is a browserSettings API for vertical tabs after all, but it is on Firefox 142.0 and later.

Kudos to u/Random3838 on r/firefox. Related bugzillas: https://bugzilla.mozilla.org/show_bug.cgi?id=1946600 https://bugzilla.mozilla.org/show_bug.cgi?id=1762975

È stato utile?

Richiedi supporto

Bisogna accedere al proprio account per rispondere nelle discussioni. Se non si possiede ancora un account, inserire una nuova richiesta.