[HowTo] Enable tab switching in Firefox using mouse wheel

firefox
mousewheel
tabs

#1

Prior to Firefox 57, I was using an addon which allowed open tabs to be switched using mouse wheel. With 57, Firefox API was changed and addons were no longer allowed to interact with certain parts of browser XUL. This downgraded the user experience, since on pretty much all popular UI toolkits on Linux switching tabs using your mouse wheel is common.

Changing active tab in this demonstration was performed using only mouse wheel:

To enable this functionality in your firefox, you will create two files within your Firefox’s user profile using your text editor. Here’s a step by step guide:

  1. Open your Firefox
  2. Enter about:support in the address bar
  3. Click on the Open Directory button
    Screenshot_20180207_162141
  4. You will be presented with your file manager and several folders. Folder named similar to “xxxxxxxx.default” is the one we need. “xxxxxxxx” will be a random string of numbers and letters. Enter that folder.
  5. If it doesn’t exist already, create a new folder inside it called chrome
    Screenshot_20180207_162647
  6. Enter chrome folder
  7. Create bindings.xml and userChrome.css files inside chrome folder. It is important that they are named exactly like that (e.g. with Capital C in userChrome.css)
    Screenshot_20180207_163119
  8. Using your favorite text editor open bindings.xml and paste the following code in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bindings>
<bindings xmlns="http://www.mozilla.org/xbl">
    <binding id="tabs-scroll" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox">
        <handlers>
            <handler event="wheel"><![CDATA[
                // Preserve original behaviour if meta (Windows) key is held
                if (event.metaKey) return;
                                
                if (event.deltaY < 0) {
                    gBrowser.tabContainer.advanceSelectedTab(-1, true);
                }
                else {
                    gBrowser.tabContainer.advanceSelectedTab(1, true);
                }    
                event.stopPropagation();
                event.preventDefault();
            ]]></handler>
        </handlers>
    </binding>
</bindings>
  1. Using your favorite text editor open userChrome.css and paste the following code in it:
.tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox {
    /* Place bindings.xml in the same folder as userChrome.css */
    -moz-binding: url("bindings.xml#tabs-scroll") !important;
}
  1. Restart your Firefox!
  2. You’re done! If you’ve done everything correctly, you can now hover your mouse over tabs area and mouse wheel will flip through them. Congratulations!

Notes:

  • More perceptive amongst you noticed a hidden functionality: if meta key (or Windows key, if you please) is held pressed while you’re using mouse wheel over tabs, Firefox would do what it usually does without this tweak. Useful if you’ve got other bindings for your mousewheel.

  • This guide is intended for users that don’t open their terminals. If you are a power user and know your way around your ~ and userChrome.css, more power to you, feel free to do things the linux way. :wink: