Sort MetaFilter Comments

Adds a Sort by Favorites button. Also keeps the anchor tags in the right place, and allows restoring the original sort order.

These are versions of this script where the code was updated. Show all versions.

  • v18 2024-09-25

    Adding better logging of sorting vs restoring in JS console. Nothing end users will notice.

  • v17 2024-09-04

    Removing button height to fix sizing issue.

  • v16 2022-04-29

    Cleaned up code and comments, and switched back to an event-loop-blocking method of adding comments because waiting for animation frames or setTimeout were both an order of magnitude slower.

  • v15 2020-08-07 Now works even if there is no sidebar, which happens if the mods delete or archive a thread.
  • v14 2020-03-15 Removing @run-at as it's not guaranteed to work, and @locale because Greasemonkey's editor thinks it's erroneous.
  • v13 2020-02-07 Fixing an error in reGetAllDivsAndReSort().
  • v12 2020-02-06 Re-gathering the comment Divs and re-sorting the anchors every time the button is pushed so any changes are respected.
  • v11 2020-02-01 Switching to setTimeout( , 0) which keeps the page responsive but is faster than animation frame or setTimeout with a delay.
  • v10 2020-01-30 Switching from RequestAnimationFrame to recursive SetTimeout so the script runs a bit faster and doesn't stop if you navigate away from the tab.
  • v9 2020-01-30 Do fewer DOM manipulations per frame to maintain responsiveness, and set a static heights for the wrapper span during DOM work to prevent flickering.
  • v8 2020-01-29 Adding 5 divs per animation frame instead of 10 to reduce flickering on mobile devices.
  • v7 2020-01-29 Switching from "do all the DOM manipulations at once" to "add the Divs 10 at a time, then wait for the next animation frame" to keep the page responsive.
  • v6 2020-01-29 Replacing waitOneFrame() with waitUntilButtonDisabled(), which checks the button each AnimationFrame and only runs the sort once the button has been animated.
  • v5 2020-01-28 Adding requestAnimationFrame() to ensure the button says "Working..." before the sort operation starts and blocks painting.
  • v4 2020-01-28 Removed setTimeout(), which didn't keep the page responsive but added a 20% performance hit. It also tended to trigger script warnings on Android.
  • v3 2020-01-28 Added code to disable the button when clicked, and some comments and cleanup.
  • v2 2020-01-26 Speeding up the delete phase of each sort by wrapping the area to be modified in a span. String manipulation slightly slows down initial setup after page load.
  • v1 2020-01-17