Base64Decoder: Move MessagePopoverButton

This commit is contained in:
thororen1234 2025-10-10 21:44:14 -04:00
parent 8e62e59d5a
commit 60b373576b
No known key found for this signature in database

View file

@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
import { definePluginSettings } from "@api/Settings";
import { CodeBlock } from "@components/CodeBlock";
import ErrorBoundary from "@components/ErrorBoundary";
@ -112,49 +111,42 @@ export default definePlugin({
authors: [EquicordDevs.ThePirateStoner],
dependencies: ["MessagePopoverAPI"],
settings,
renderMessagePopoverButton(msg) {
const handleClick = () => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Right") {
decodedContent.forEach(content => copyWithToast(content));
} else {
openDecodedBase64Modal(decodedContent);
}
};
start() {
addMessagePopoverButton("DecodeBase64", msg => {
const handleClick = () => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Right") {
decodedContent.forEach(content => copyWithToast(content));
} else {
openDecodedBase64Modal(decodedContent);
}
};
const handleContextMenu = e => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Left") {
e.preventDefault();
e.stopPropagation();
decodedContent.forEach(content => copyWithToast(content));
} else {
e.preventDefault();
e.stopPropagation();
openDecodedBase64Modal(decodedContent);
}
};
const handleContextMenu = e => {
const base64Strings = findBase64Strings(msg.content);
const decodedContent = decodeBase64Strings(base64Strings);
if (settings.store.clickMethod === "Left") {
e.preventDefault();
e.stopPropagation();
decodedContent.forEach(content => copyWithToast(content));
} else {
e.preventDefault();
e.stopPropagation();
openDecodedBase64Modal(decodedContent);
}
};
const label = settings.store.clickMethod === "Right"
? "Copy Decoded (Left Click) / Decode Base64 (Right Click)"
: "Decode Base64 (Left Click) / Copy Decoded (Right Click)";
const label = settings.store.clickMethod === "Right"
? "Copy Decoded (Left Click) / Decode Base64 (Right Click)"
: "Decode Base64 (Left Click) / Copy Decoded (Right Click)";
return {
label,
icon: DecodeIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: handleClick,
onContextMenu: handleContextMenu
};
});
},
stop() {
removeMessagePopoverButton("DecodeBase64");
return {
label,
icon: DecodeIcon,
message: msg,
channel: ChannelStore.getChannel(msg.channel_id),
onClick: handleClick,
onContextMenu: handleContextMenu
};
}
});