Last active
July 6, 2024 19:54
-
-
Save phit/030d8185bcc95d28203e801e5b9f9be6 to your computer and use it in GitHub Desktop.
better discord double click edit plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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.1.0"; | |
}; | |
dblClickEdit.prototype.getAuthor = function () { | |
return "phit"; | |
}; | |
function dblClickEventListener(e) { | |
var parents = getParents(e.target, "message_d5deea") | |
if (parents.length > 0) { | |
var msg = parents[parents.length - 1]; | |
var opt = msg.querySelectorAll(".button_ef319f"); | |
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; | |
} |
Getting this notification like 5 months later, but yes shift while double clicking works! Thanks!
Seems like it broke
@Vexadros I just updated it for the latest discord changes!
@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
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.