Firefox JavaScript – Modify Hardcoded Ctrl-Tab Panel Behavior

firefoxjavascript

In the source code for the Firefox Ctrl+Tab behavior there's a hardcoded limit of 6 tabs:

/**
 * Ctrl-Tab panel
 */
var ctrlTab = {
  maxTabPreviews: 6,
  //...
    for (let i = 0; i < this.maxTabPreviews; i++) {
      previewsContainer.appendChild(this.makePreview(false));
    }
  //...

That’s not a lot. Is there any way apart from doing a complete build from source to alter this behavior?

I'm not looking for a workaround or add-on which can present an alternative list of tabs for instance, I really want to find out if there s a way which essentially has the same effect as putting maxTabPreviews = 10 but without having to compile a custom version of Firefox. Like userchrom.css which can override certain style elements, but then something which allows overridinng this piece of code.

Best Answer

Warning solution presented below works for me without flaws as far as I can tell, but YMMV so try at own risk.

Thanks harrymc for putting me on the way. Your comment saying the string is nowhere in Firefox made me think it's indeed not possible that all .js files from the source are in firefox.exe because it's way to small for that. So I went looking in the application directory for where they are instead and found they are compressed in a single omni.ja file. Unzipping the file using

unzip omni.ja -d omni

gives a directory structure with all JavaScript/HTML/CSS etc amongst which there's omni/chrome/browser/content/browser/browser-ctrlTab.js. Yay! So I edited the file to use 8 instead of 6, then zipped again as instructed using

cd omni
zip -qr9XD omni.ja *

The resulting file is however about 2.5 times smaller than the original so I assume firefox doesn't use 9 as compression level these days but 0. Indeed

zip -qr0XD omni.ja *

produces a file almost the exact same size as the original. Testing the original omni.ja with 7zip does say 'Warnings: There are some data after the end of the payload data' so that might be the culprit.

Anwyay replacing the original omni.ja with the new one, using firefox -p to launch with a new profile just to be safe, I'm delighted to see there are now indeed 8 tabs. Repeated the same again using 12 tabs, screenshot:

enter image description here

Drawback is obvious: this process likely needs to be repeated after each update. But unless add-ons have access to all internals (which is the next thing to investiagte) it it likely the only way. Improvement would be to render multiple rows instead of one.

Related Question