Phoshi's answer using an AutoHotkey script is a nice workaround. I recommend replacing his AutoHotkey script with this modification:
#IfWinActive Mozilla Firefox
What improvement does this make? Phoshi's script (i.e., using
MButton::IfWinActive, Mozilla Firefox and so forth) will make it so the middle mouse button (outside of Firefox and other windows with "Mozilla Firefox" in the title) can only send a middle mouse click—middle-drag or middle-button-hold gestures will be impossible while the script is active. (Also, all middle-mouse-button gestures are disabled in "Mozilla Firefox"-titled windows.)
SetTitleMatchMode, 2 allows the script to match Firefox even if "Mozilla Firefox" is later in the window title (otherwise it will only match if "Mozilla Firefox" is at the beginning of the window title).