Update CopyRawMessage.plugin.js

This commit is contained in:
Mirco Wittrien 2020-05-02 20:47:15 +02:00
parent 93f3efb8ac
commit 0beb977567
1 changed files with 26 additions and 23 deletions

View File

@ -4,7 +4,7 @@ var CopyRawMessage = (_ => {
return class CopyRawMessage { return class CopyRawMessage {
getName () {return "CopyRawMessage";} getName () {return "CopyRawMessage";}
getVersion () {return "1.0.5";} getVersion () {return "1.0.6";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -60,13 +60,11 @@ var CopyRawMessage = (_ => {
// Begin of own functions // Begin of own functions
onMessageContextMenu (e) { onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.message.content) { if (e.instance.props.message) {
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target); let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedIndex = embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1; let embedIndex = embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1;
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]}); let entries = [
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, { e.instance.props.message.content && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)", label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
hint: BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null, hint: BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null,
action: _ => { action: _ => {
@ -81,13 +79,18 @@ var CopyRawMessage = (_ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.embeds[embedIndex].rawDescription}); BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.embeds[embedIndex].rawDescription});
} }
}) })
].filter(n => n) ].filter(n => n);
if (entries.length) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
children: entries
})); }));
} }
} }
}
onMessageOptionContextMenu (e) { onMessageOptionContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) { if (e.instance.props.message && e.instance.props.message.content) {
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {key: ["mark-unread"]}); let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {key: ["mark-unread"]});
children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, { children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)", label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",