Skip to content

Instantly share code, notes, and snippets.

@dvingerh
Last active February 4, 2020 21:14
Show Gist options
  • Save dvingerh/85646ac8e276ade5f9f601b58118d19e to your computer and use it in GitHub Desktop.
Save dvingerh/85646ac8e276ade5f9f601b58118d19e to your computer and use it in GitHub Desktop.
Discord Userscript: Adds functionality to delete messages faster by ctrl+right-clicking them. (Discord Quick Delete Messages)
// ==UserScript==
// @name Discord Quick Delete Messages
// @description Adds functionality to delete messages faster by ctrl+right-clicking them.
// @namespace Violentmonkey Scripts
// @grant GM_addStyle
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require https://raw.githubusercontent.com/MichaelZelensky/jsLibraries/master/macKeys.js
// @match *://discordapp.com/*
// ==/UserScript==
var showPopup = false; //If set to true, it won't instantly delete the message but open the confirmation dialog instead
$('body').on('contextmenu', 'div[class*="cozyMessage-"]', function(e) {
if (e.ctrlKey || macKeys.ctrlKey) {
var dropdown;
if ( $(this).html().indexOf("embed") != -1) {
dropdown = $(this).find("div[aria-label^='More']");
}
else {
dropdown = $(this).find("div[aria-label^='More']");
}
e.stopPropagation(); // Prevent buggy behavior where it would delete all messages in the same time 'batch'
e.preventDefault(); // Prevent showing up of context menu caused by above hotfix
dropdown.trigger( "click" );
$.each($("div[class^='contextMenu-']").find("div[class^='item-']"), (index, value) => {
var option = $(value);
console.log(option.html());
if(option.html().indexOf("Delete") != -1) {
option.trigger("click");
if (!showPopup)
{
$("div[class^='backdrop']").css("display", "none");
$("form[class^='modal-']").css("display", "none").find("button[class*='colorRed-']").trigger("click");
}
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment