1

Description

The delete button in chat removes messages with no confirmation, nor any option to return them. This is a small safety measure - adds a simple confirmation on trying to delete.

Installation

Direct install (GitHub)

See the code on GitHub

(For instructions how to install userscripts: see the tag wiki here)

Code:

// ==UserScript== // @name SE chat: Confirm message deletion // @description Adds a confirmation before deleting a message to prevent accidents // @author VLAZ // @grant none // @inject-into page // @match https://chat.stackoverflow.com/* // @match https://chat.stackexchange.com/* // @match https://chat.meta.stackexchange.com/* // @namespace https://github.com/PurpleMagick/ // @run-at document-end // @version 1.0.0 // ==/UserScript== (function(){ // keep reference to the original function const original = messageActionById; const caseInsensitiveCollator = new Intl.Collator("en", { sensitivity: "base"}); const override = function(_, action) { // only act on delete // (also, case-insensitive just in case. Don't know if chat tries to uppercase it some times) if (caseInsensitiveCollator.compare("delete", action) === 0) { const result = confirm("Are you sure you want to delete?"); //exit with no action on negative or closure if (!result) return; } // run original function to apply the deletion return original.apply(this, arguments); }; messageActionById = override; })(); 

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.