# Stack Overflow Unofficial Patch

The Stack Overflow Unofficial Patch (SOUP) is a project to collect various minor client-side bugfixes, work-arounds and usability improvements for Stack Overflow and other Q&A sites on the Stack Exchange Network into a single user script.

The intent of SOUP is not to make any substantial or controversial changes to the Stack Exchange user interface, but to fix minor problems and omissions that the SE developers have overlooked or haven't got around to fixing yet. By combining these minor patches into a single user script, they become easier to install and maintain.

## Installing

The easiest way to install SOUP is to use the GreaseMonkey (for Firefox) or TamperMonkey (for Chrome) extension for managing user scripts. (Other similar extensions, like Scriptish or NinjaKit, should also work.) After installing the extension, clicking the "download / install" button below should bring up a dialog asking you if you want to install SOUP. Answer "yes".

View source / GitHub repo / StackApps post

SOUP can also be used on other browsers with compatible user script support, such as Opera or Safari. For detailed instructions on how to enable and install user scripts on different browsers, see the "script" tag wiki on StackApps.

Notes:

• When installing SOUP on Opera, please remove the ".user" part from the file name to disable GreaseMonkey compatibility mode. While SOUP can run in either native or compatibility mode, a few MathJax-related fixes require native mode.

• SOUP has not yet been tested on Safari, but in principle it should work. If you do try to use it, please let me know how / if it works.

## Included fixes

SOUP v1.22 includes fixes or workarounds for the following issues:

Notes:

## Credits

SOUP is currently maintained by Ilmari Karonen. Several of the fixes are based on suggestions or earlier user scripts made by others; see the source code and/or the meta.SO links above for details.

## Contributing

If you know a user script or stylesheet patch for SO or other SE sites that would be suitable for inclusion in SOUP, or an unfixed issue that you believe might be worth patching, please let me know (e.g. by posting a comment or an answer the SOUP page on StackApps).

To be included in SOUP, a patch should:

• address a known unfixed issue: If you find a new interface bug on SO, please report it on MSE first, and give the devs some time to fix it. There's no hard limit on this, but there's not much point in patching something via SOUP if it's going to be fixed by the devs in a few minutes / hours / days anyway.

• be simple and fast: The mean length of individual patches in SOUP (excluding shared infrastructure) is currently around three lines of code. If adding a new patch would significantly increase the length of SOUP, cause a noticeable performance impact or introduce a significant external dependency (e.g. new syntax highlighting rules), it's probably not suitable.

• be uncontroversial: SOUP is intended to be a "least common denominator" patch set for everyone. While a simple [status-declined] doesn't necessarily disqualify an issue from being included in SOUP (sometimes it just means the devs are feeling lazy ;-), if a substantial number of people say they don't want it, it doesn't go in. In particular, patches that add significant new functionality, significantly change the appearance of the site or repaint the bikeshed are not suitable for SOUP.

• be safe and unobtrusive: This goes with the above points: if any patch in SOUP turns out to cause undesirable side effects (including usability or performance issues) on some platforms, it should be either fixed or removed.

If you notice that any fix included in SOUP is not working for you, causes undesirable side effects or has become obsolete (e.g. because the bug it's working around was fixed), please let me know!

-

# Feature requests

Know a fix that should be included in SOUP (or an issue that could be fixed)? List it here.

### Scheduled for next release

These fixes have been or will soon be added to the development branch, and will be included in the next stable release:

These issues might be fixed in a future release, but need some work first:

### Declined:

These issues are out of scope for SOUP, or cannot be easily fixed:

### Proposed:

Feel free to add new proposals here.

-
@DavideCervone: Thanks! Has the "disable noerrors extension while editing" thing even been feature-requested on meta? And if not, would you mind doing that so I'll have a request to link to? –  Ilmari Karonen Jan 19 at 20:06
@IlmariKaronen, OK, I've posted this question concerning the noErrors extension. –  Davide Cervone Jan 19 at 21:58
@IlmariKaronen, you may also want to call your MathJax reset function (I forget the exact name) in the Begin Process message handler, so that the definitions will be reset for each typeset pass (i.e., the definitions from the previous typeset will not be in effect for the next typeset). –  Davide Cervone Jan 19 at 22:06
@DavideCervone: I already do that. However, I just realized that my earlier code had a race condition bug: it would break if the begingroup extension didn't get loaded before the initial typeset pass began. This never seemed to happen on Chrome, but it happens very often in Firefox. I've fixed it now, though. –  Ilmari Karonen Jan 20 at 8:59
@DavideCervone: Also, I got your fixes working in the devel branch, but I have something slightly more ambitious yet in mind: making \labels in separate posts completely independent of each other. I think I know how to do this (it involves changing the formatID function), but the race condition bug mentioned above messed up my testing of it yesterday. –  Ilmari Karonen Jan 20 at 9:03
@IlmariKaronen, nice solution to the begingroup issue. I'll be interested in your solution to the label problem. –  Davide Cervone Jan 20 at 13:13
@DavideCervone: Just FYI, I've been a bit slow with getting the improved \label fix done, so decided to just release SOUP v1.4 with your original fixes. I'm planning to get the improved fix done for v1.6. –  Ilmari Karonen Jan 24 at 21:22
I had this idea for the new Android app but it applies to the browser version of SE, too. Is it possible to disable the preemptive compilation MathJax does and instead compile only when the user clicks on a piece of math? (On my Mini PC with an Atom Dxxx, long math-heady posts load a long time.) I guess that won't be exactly "consensus" for this here fix, but it may be an option for the proposed turning-off feature (with GUI?). –  Raphael Jan 29 at 18:55
@Raphael: That is doable, yes. (The trick is to use @run-at document-start to inject a custom MathJax config script before MathJax loads, just like SOUP does for the \newcommand fix.) It not something I'd consider suitable for SOUP, but I'll add it to my list of possible ideas for new user scripts. Thanks! –  Ilmari Karonen Jan 29 at 20:47
I'm not sure if that's feasible, but moving discussions to chat would be great. The script would have to a) create a new chatroom, b) copy (selected) comments there and c) delete comments. –  Raphael Jul 3 at 11:01
@Raphael: Unless there's some way to hook into the existing comment migration feature (and I kind of doubt it, since it seems like it'd be a security hole), step c would have to be mod-only. And I'm not a mod on any SE site, so I can't really develop and test it myself. (There was one mod-only fix in SOUP once, but it was mostly developed by Manishearth, who is a mod.) That said, if somebody does come up with a nice and working user script to do that, I'd be glad to steal it for SOUP. –  Ilmari Karonen Jul 3 at 11:12
@AstroCB: Thanks! A fix for mse266852: Bar between “add a comment” and “show more comments” is inconsistent, loosely based on your script, is now included in the just released SOUP v1.20. –  Ilmari Karonen Jul 28 at 14:07
@IlmariKaronen Great: thanks. It doesn't appear to be getting much traction over at MSO, so I don't see it happening officially anytime soon. –  AstroCB Jul 28 at 14:09
Regarding comment management: bulk operations might be doable by userscript? –  Raphael Aug 14 at 20:00
@Raphael: Probably, but you'll need to find a mod with userscript skills to code and test it. I know there are a bunch, so it's doable, and I'd probably be happy to, ahem, borrow the code for SOUP if someone does write it (and it doesn't break the existing interface or have any other obvious issues, of course). –  Ilmari Karonen Aug 17 at 19:30

# Known bugs

• Markdown editor hooks (e.g. mse224533, math11392, boardgames1152, french347) sometimes fail to run on Opera, apparently due to a race condition where the editor gets initialized before SOUP has a chance to add the hook. Reloading the edit page usually fixes the problem.

• The over-wide comments fix reserves a fixed amount of horizontal space for the comment vote counts and vote / flag buttons. For comments with high vote counts, especially on sites with wide vote / flag icons, this can cause the vote count to overflow to the left. While this has no practical effect on usability, it can look a bit funny, especially when the comment is hovered over.

• The kluge used to monitor WebSocket messages on SE chat doesn't seem to work on Opera, so SOUP falls back to polling for changes at ½ second intervals. This works, but is less efficient.

• SOUP does not work (at all) on Scriptish 0.1.11, because document.documentElement is not available at document-start. Apparently, this is a bug in Scriptish that has been fixed in Scriptish 0.1.12, but that version was never properly approved for distribution on addons.mozilla.org.

# Bug reports

This includes any unwanted side effects or regressions due to changes in the SE codebase.

-

# Change log

This is a list of new fixes and other changes made to SOUP during its continued development.

SOUP version numbering generally follows the major.minor.patch scheme. Odd minor versions (1.1.x, 1.3.x, 1.5.x, etc.) are reserved for unstable development versions ("devel" branch on GitHub), while even ones denote stable releases ("master" branch on GitHub). The change log below thus only includes even version numbers, as changes between development versions are too numerous to list.

# 1.22 (15 Sep 2014)

This is just an incremental release to push out a few updates that missed v1.20 and were stuck in the devel branch. More active development may or may not resume later in the year. As always, contributions are welcome.

New fixes in 1.22.0:

Other changes:

• Improved and simplified the stats1987 fix by using max-width instead of table-layout: fixed. This fixes a minor layout issue with large vote counts and adds scroll bars to over-wide comments.
• Added release dates to change log. Trying out short release notes as well.
• Added @homepageURL, @copyright and @license metadata lines.

# 1.20 (28 Jul 2014)

New fixes in 1.20.0:

Removed fixes:

Other changes:

• SOUP now hooks the WebSocket interface to detect chat events instead of polling for them.
• mse229363: Hot question titles from the Aviation and Puzzling sites are now eligible for MathJax parsing.

# 1.18 (5 Jul 2014)

New fixes in 1.18.0:

Other changes:

• The sidebar question score wrap fix (mse229751) is split into a global part and a site-specific part.
• The mobile link cursor fix (mse108046) is applied to all links without name attributes.
• The HTTPS link rewrite fix (mse221304) is now applied also to chat and area51 links.
• Content filters now work properly on chat (using brute-force 0.5s interval polling, since there's no proper hook for chat updates).
• SOUP.isChat() and SOUP.isMeta() are now set already during early setup.
• Devel branch versions should now auto-update properly (and not just when a new master release is made).
• Update checking is optimized by duplicating the script metadata in SOUP.meta.js and pointing @updateURL to it instead of the main script.

# 1.16 (26 Jun 2014)

Changes in 1.16.1:

• The mse229759 fix has been made redundant, only a few hours after v1.16.0 was released.

New fixes in 1.16.0:

Other changes:

• The mse230607 fix is no longer needed, and has been removed.
• The mse224628 fix is no longer relevant, since the 10k flag review page no longer exists; the code has been adapted for mse115702 instead.
• mse229363: MathJax is now also parsed in hot question titles from earthscience.SE.
• The math12803 fix is now split into two parts, of which one is math.SE specific and the other is applied on all sites.
• The mse215473 styles are no longer incorrectly applied to links in popups created from the post menu.
• Fixes can now run scripts early, before the document loads, by specifying them with the early property. Note that jQuery is typically not yet available at that stage.
• New SOUP.addContentFilter() utility method to simplify fixes that manipulate post content.
• Fancy new icon.

# 1.14 (11 May 2014)

Changes in 1.14.1:

• The mse230607 fix is now applied on academia.SE too.

New fixes in 1.14.0:

Other changes:

# 1.12 (15 Apr 2014)

New fixes in 1.12.0:

Other changes:

# 1.10 (10 Mar 2014)

Changes in 1.10.2:

• Removed workplace2437 CSS fix, no longer needed.
• The fix for mse223866 caused a formatting regression for moderators, rewrote the code to be more careful. (Thanks, Monica Cellio!)

Changes in 1.10.1:

• Fixed minor issue with stats1987 causing vote counts on self-posted comments to be misaligned. (Thanks, Jonathan Hobbs!)

New fixes in 1.10.0:

Other changes:

• JS fixes are now isolated from each other, one fix failing will no longer break others.
• New utility function SOUP.forEachTextNode() for easier page text manipulation.
• New SOUP.userRep, SOUP.isBeta and SOUP.isMeta properties for user privilege checking.
• Bugfix: SOUP no longer leaks variable or runs outside the SE network on Opera.

# 1.8 (24 Feb 2014)

Changes in 1.8.3:

• The fix for mse160338 is no longer needed, and has been removed. (Thanks, Manish!)

Changes in 1.8.2:

• The fix for mse150069 is no longer needed, and has been removed.

Changes in 1.8.1:

• The fix for mse212372 is no longer needed, and has been removed.
• The fix for mse104184 is no longer applied in the mobile view; see this feature request for details.
• The README Markdown has been simplified for better compatibility between GitHub, StackApps and UserScripts.org.

New fixes in 1.8.0:

Other changes:

• The code has been reorganized into self-contained modules, each corresponding to one bugfix / workaround. Currently, this has little effect on functionality, but it could be used e.g. to allow toggling individual fixes on/off.
• Utility functions like hookAjax() are now contained in a page-global SOUP object.
• A new SOUP.hookEditPreview() utility function has been added to allow easier editing fixes.
• CSS fixes are now injected before the document is loaded, reducing the risk of "flickering". As a side effect, a few selectors had to be adjusted to increase their specificity over conflicting SE default styles.
• Added a change log, with retroactive logging for earlier releases.

# 1.6 (10 Feb 2014)

Changes in 1.6.1:

New fixes in 1.6.0:

# 1.4 (24 Jan 2014)

New fixes in 1.4.0:

# 1.2 (17 Jan 2014)

New fixes in 1.2.0:

# 1.0 (12 Jan 2014)

Fixes included in the 1.0.x branch:

-