8

About

Ever forget you voted to delete something and ended up retracting your vote accidentally?

Well, so have a bunch of other people, myself included, so let's make that a bit more obvious.

This script renames the "Delete" button to "Retract Delete" if you've already voted to delete a particular post, making it more obvious that you've already voted. The same will occur with the "Undelete" button.

Image of the Retract Delete button

Image of the Retract Undelete button

It also makes the prompts when clicking this button more obvious that you're retracting a vote, rather than casting one.

Image of the prompt when attempting to retract a delete vote

For keyboard shortcut users, the simple alert modal is replaced with a Stacks showConfirmModal that's very in-your-face and defaults to "Cancel" to prevent muscle-memory from doing something you might not have wanted to do.

Image of the Stacks modal that says "Hey! You're about to retract your vote to undelete. Are you sure you want to do that?"

The same treatment is given to reopen votes, as the confirmation dialog presented to the user isn't eye-catchingly different enough when you're about to retract a reopen vote:

Retract Reopen vote button

Installation

Most script managers should be able to run this without any issues. I've only tested Tampermonkey and Violentmonkey, though.

Click to install with a script manager

Repository

If you run into a problem, feel free to let me know, I'll do my best to fix it. Otherwise, you're always free to fix it yourself with a pull request. My JavaScript/jQuery knowledge could use some serious refining, so don't expect greatness.

Source code repo

1 Answer 1

1

Update v1.2

The script now displays a Stacks confirmation dialog when performing a delete/undelete vote retraction through keyboard shortcuts:

enter image description here

I mainly use the keyboard shortcuts, and so merely relabelling the button doesn't really help (I basically never look at it, and sometimes don't even need to scroll down far enough to expose it to decide that something is delete-worthy).

Do you think you could make even more changes to the styling of the (pseudo-) dialog to make it more obvious when you are retracting a close vote?

Alternatively, perhaps change the keyboard shortcut so that md does not even invoke the button when the action is different? (It might be convenient to have a new separate shortcut mr to retract, but I'm guessing that would be significantly harder to implement.)

10
  • 1
    Digging into the keyboard shortcut nonsense, I discovered that it basically just builds a path to pseudo-clicking the delete button anyway, so overriding that behavior would prove to be annoying (and probably outside of my ability). In the meantime, I've made the pseudo-dialog more obvious that you're retracting a delete vote, but I don't know if this will help avid SO user-moderators like yourself since you're probably performing M+D+Enter in quick succession. I think I might look into replacing that pseudo-dialog with a Stacks one if I can figure that out.
    – Spevacus
    Jan 23, 2022 at 15:26
  • Thanks, that's an improvement already (... though hosting the image on a third-party site is odd and adds some noisy advertising)
    – tripleee
    Jan 23, 2022 at 15:35
  • 1
    Sorry, that's just where my snipping tool uploads things. You should be able to update the script to get that more-obvious dialog for now. I'm off to go dumpster diving in the Stacks stuff...
    – Spevacus
    Jan 23, 2022 at 15:39
  • Hey! I got around to looking into this more when Dharman brought up that Reopen vote retraction was similarly unclear/too similar to casting a Reopen vote. Here's what I've got so far: i.imgur.com/vWW8DxO.gif (may give you ads, if so, I apologize) - Essentially I'm displaying a Stacks confirmation window if and only if you've used keyboard shortcuts to attempt to retract a Delete/Undelete vote. If you just click the button it's the less in-your-face (but still somewhat in your face due to the text changes I've done) alert dialog. Does this look okay?
    – Spevacus
    Mar 12, 2022 at 2:53
  • My only concern is that this behavior relies upon the visibility of the keyboard shortcut modal. Does this ALWAYS appear when you're about to perform a delete/undelete vote on a post?
    – Spevacus
    Mar 12, 2022 at 2:54
  • If you are referring to the box with a legend of which keyboard shortcut does what, I was unable to see that at all on a question. I can bring up a help display with ? but neither g nor m display anything for me at the moment when I'm on a question. When an answer is selected, I do see the help modal. (Unable to repro on a question which doesn't have a delete button; there, I do see the guidance modal. Actually, on another question eligible for deletion, I see it too.)
    – tripleee
    Mar 14, 2022 at 5:17
  • I take that back; I'm usually able to see the box. But clearly, not always.
    – tripleee
    Mar 14, 2022 at 5:24
  • 1
    Gotcha. So it's not always consistent. In my limited testing I experienced the same (the "moderate..." modal was not always visible, there was a short period when it was not visible but still accepted a Delete command) so I'll have to tie detection to something else I think. If I dig into the keyboard shortcut javascript, there may be something more reliable I can hook into. The keyboard shortcuts still work despite the modal not always being visible, so there must be some sort of flag I can use.
    – Spevacus
    Mar 14, 2022 at 12:27
  • Ah, and furthermore there's a "Disable autohelp" action in the main keyboard menu that'll disable the modal entirely.
    – Spevacus
    Mar 14, 2022 at 12:33
  • Ugh, got it, but it was annoying. SE internally calls keyboard shortcut clicking via some jQuery foo that takes precedence over Javascript's event listeners. Thankfully, the event they create and fire is done in a way that is predictable and has differences between manual clicking, so I can reliably determine whether or not a click came from a user's mouse or their keyboard. I should have an update available soon.
    – Spevacus
    Mar 14, 2022 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .