Windows 10 reached EOS (end of support) on October 14, 2025. If you are on Windows 10, see this article.

Rechercher dans l’assistance

Évitez les escroqueries à l’assistance. Nous ne vous demanderons jamais d’appeler ou d’envoyer un SMS à un numéro de téléphone ou de partager des informations personnelles. Veuillez signaler toute activité suspecte en utilisant l’option « Signaler un abus ».

En savoir plus

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

  • 3 réponses
  • 0 a ce problème
  • 97 vues
  • Dernière réponse par regunakyle

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!

Solution choisie

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

Lire cette réponse dans son contexte 👍 0

Toutes les réponses (3)

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

Modifié le par regunakyle

Hi

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

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

Solution choisie

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