Fix betterUploadButton

This commit is contained in:
Vendicated 2022-10-26 15:10:11 +02:00
parent b87f0bf3f9
commit c65f757bc4
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3

View file

@ -21,15 +21,17 @@ import definePlugin from "../utils/types";
export default definePlugin({ export default definePlugin({
name: "BetterUploadButton", name: "BetterUploadButton",
authors: [Devs.obscurity], authors: [Devs.obscurity, Devs.Ven],
description: "Upload with a single click, open menu with right click", description: "Upload with a single click, open menu with right click",
patches: [ patches: [
{ {
find: "Messages.CHAT_ATTACH_UPLOAD_OR_INVITE", find: "Messages.CHAT_ATTACH_UPLOAD_OR_INVITE",
replacement: { replacement: {
match: /CHAT_ATTACH_UPLOAD_OR_INVITE,onDoubleClick:([^,]+),onClick:([^,]+)}}/, // Discord merges multiple props here with Object.assign()
replace: // This patch passes a third object to it with which we override onClick and onContextMenu
"CHAT_ATTACH_UPLOAD_OR_INVITE,onClick:$1,onContextMenu:$2}}", match: /CHAT_ATTACH_UPLOAD_OR_INVITE,onDoubleClick:(.+?:void 0)\},(.{1,3})\)/,
replace: (m, onDblClick, otherProps) =>
`${m.slice(0, -1)},{onClick:${onDblClick},onContextMenu:${otherProps}.onClick})`,
}, },
}, },
], ],