Skip to content

Instantly share code, notes, and snippets.

@phit
Last active January 31, 2022 01:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phit/030d8185bcc95d28203e801e5b9f9be6 to your computer and use it in GitHub Desktop.
Save phit/030d8185bcc95d28203e801e5b9f9be6 to your computer and use it in GitHub Desktop.
better discord double click edit plugin
//META{"name":"dblClickEdit"}*//
var dblClickEdit = function () {};
dblClickEdit.prototype.start = function () {
document.addEventListener("dblclick", dblClickEventListener);
};
dblClickEdit.prototype.load = function () {};
dblClickEdit.prototype.unload = function () {
document.removeEventListener("dblclick", dblClickEventListener);
};
dblClickEdit.prototype.stop = function () {
document.removeEventListener("dblclick", dblClickEventListener);
};
dblClickEdit.prototype.getName = function () {
return "Double click edit";
};
dblClickEdit.prototype.getDescription = function () {
return "Double click messages to edit them";
};
dblClickEdit.prototype.getVersion = function () {
return "1.0.0";
};
dblClickEdit.prototype.getAuthor = function () {
return "phit";
};
function dblClickEventListener(e) {
var parents = getParents(e.target, "message-2CShn3")
if (parents.length > 0) {
var msg = parents[parents.length - 1];
var opt = msg.querySelectorAll(".button-3bklZh");
for (i = 0; i < opt.length; i++) {
if (opt[i].getAttribute('aria-label') == 'Edit') {
opt[i].click();
break;
}
}
}
}
function getParents(el, untilClass) {
var parents = [];
var p = el.parentNode;
var iter = 0;
while (iter < 5 && p !== undefined && p.classList !== undefined && !p.classList.contains(untilClass)) {
var o = p;
if (p.classList.contains(untilClass)) {
parents.push(o);
}
p = o.parentNode;
iter++;
}
if (p.classList.contains(untilClass)) {
var o = p;
parents.push(o);
}
return parents;
}
@luciedu
Copy link

luciedu commented Jul 13, 2021

how i install it ?

@phit
Copy link
Author

phit commented Jul 13, 2021

save to file and throw into the betterdiscord plugins folder

@Arjun-Anubis
Copy link

I actually came accross this, lookinng for a double click to reply plugin, but looking at the code, just replacing 'Edit' with 'Reply' would get what I want. Tried it and it worked, doesn't let you reply to your own messages though.

@phit
Copy link
Author

phit commented Jul 29, 2021

@Arjun-Anubis hold shift when doubleclicking and it will actually work with replying to yourself

@ArchWand
Copy link

For clarification to those looking for a Double Click to Reply plugin, it worked for me to just change the 'Edit' on line 36 to 'Reply'.

Tbh I'd love if this plugin had a settings menu and you could choose whether double-clicking edits or replies, but I don't know enough code to do that.

@Arjun-Anubis
Copy link

Getting this notification like 5 months later, but yes shift while double clicking works! Thanks!

@Vexadros
Copy link

Seems like it broke

@phit
Copy link
Author

phit commented Jan 30, 2022

@Vexadros I just updated it for the latest discord changes!

@Vexadros
Copy link

@phit Wow that was fast, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment