This commit is contained in:
Mirco Wittrien 2023-02-03 21:18:05 +01:00
parent 5952085af8
commit fb4ec367fb
4 changed files with 148 additions and 145 deletions

View File

@ -2,7 +2,7 @@
* @name CopyRawMessage
* @author DevilBro
* @authorId 278543574059057154
* @version 1.1.4
* @version 1.1.5
* @description Allows you to copy the raw Contents of a Message
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -71,61 +71,60 @@ module.exports = (_ => {
onStop () {}
onMessageContextMenu (e) {
if (e.instance.props.message) {
let content = e.instance.props.message.content;
let messageString = [e.instance.props.message.content, BDFDB.ArrayUtils.is(e.instance.props.message.attachments) && e.instance.props.message.attachments.map(n => n.url)].flat(10).filter(n => n).join("\n");
let selectedText = document.getSelection().toString().trim();
if (selectedText) messageString = BDFDB.StringUtils.extractSelection(messageString, selectedText);
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedData = e.instance.props.message.embeds[embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1];
let embedString = embedData && [embedData.rawTitle, embedData.rawDescription, BDFDB.ArrayUtils.is(embedData.fields) && embedData.fields.map(n => [n.rawName, n.rawValue]), BDFDB.ObjectUtils.is(embedData.image) && embedData.image.url, BDFDB.ObjectUtils.is(embedData.footer) && embedData.footer.text].flat(10).filter(n => n).join("\n");
if (selectedText) embedString = BDFDB.StringUtils.extractSelection(embedString, selectedText);
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null;
let entries = [
messageString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-message"),
type: "Message",
hint: hint && (_ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
})),
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(messageString)
if (!e.instance.props.message) return;
let content = e.instance.props.message.content;
let messageString = [e.instance.props.message.content, BDFDB.ArrayUtils.is(e.instance.props.message.attachments) && e.instance.props.message.attachments.map(n => n.url)].flat(10).filter(n => n).join("\n");
let selectedText = document.getSelection().toString().trim();
if (selectedText) messageString = BDFDB.StringUtils.extractSelection(messageString, selectedText);
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedData = e.instance.props.message.embeds[embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1];
let embedString = embedData && [embedData.rawTitle, embedData.rawDescription, BDFDB.ArrayUtils.is(embedData.fields) && embedData.fields.map(n => [n.rawName, n.rawValue]), BDFDB.ObjectUtils.is(embedData.image) && embedData.image.url, BDFDB.ObjectUtils.is(embedData.footer) && embedData.footer.text].flat(10).filter(n => n).join("\n");
if (selectedText) embedString = BDFDB.StringUtils.extractSelection(embedString, selectedText);
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null;
let entries = [
messageString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-message"),
type: "Message",
hint: hint && (_ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
})),
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
embedString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw Embed)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed"),
type: "Embed",
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(embedString)
action: _ => BDFDB.LibraryModules.WindowUtils.copy(messageString)
}),
embedString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw Embed)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed"),
type: "Embed",
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
embedData && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Embed JSON)",
type: "Embed JSON",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed-json"),
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(JSON.stringify(embedData))
action: _ => BDFDB.LibraryModules.WindowUtils.copy(embedString)
}),
embedData && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Embed JSON)",
type: "Embed JSON",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed-json"),
icon: _ => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuIcon, {
icon: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
}),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(JSON.stringify(embedData))
})
].filter(n => n);
if (entries.length) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "copy-link"});
children.splice(index > -1 ? index + 1 : children.length, 0, entries.length > 1 ? BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-raw-submenu"),
children: entries.map(n => {
n.props.label = n.props.type;
delete n.props.type;
delete n.props.icon;
return n;
})
].filter(n => n);
if (entries.length) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "copy-link"});
children.splice(index > -1 ? index + 1 : children.length, 0, entries.length > 1 ? BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-raw-submenu"),
children: entries.map(n => {
n.props.label = n.props.type;
delete n.props.type;
delete n.props.icon;
return n;
})
}) : entries);
}
}) : entries);
}
}
@ -144,22 +143,23 @@ module.exports = (_ => {
}
processMessageToolbar (e) {
if (e.instance.props.expanded && e.instance.props.message && e.instance.props.channel) {
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "copy-message-raw",
text: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
BDFDB.LibraryModules.WindowUtils.copy(e.instance.props.message.content);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
})
if (!e.instance.props.message || !e.instance.props.channel) return;
let expanded = !BDFDB.LibraryStores.AccessibilityStore.keyboardModeEnabled && !e.instance.props.showEmojiPicker && !e.instance.props.showEmojiBurstPicker && !e.instance.props.showMoreUtilities && BDFDB.ListenerUtils.isPressed(16);
if (!expanded) return;
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "copy-message-raw",
text: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
BDFDB.LibraryModules.WindowUtils.copy(e.instance.props.message.content);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
})
}));
}
})
}));
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));

View File

@ -2,7 +2,7 @@
* @name CustomQuoter
* @author DevilBro
* @authorId 278543574059057154
* @version 1.3.1
* @version 1.3.2
* @description Brings back the Quote Feature and allows you to set your own Quote Formats
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -338,25 +338,26 @@ module.exports = (_ => {
}
processMessageToolbar (e) {
if ((e.instance.props.expanded || !this.settings.general.holdShiftToolbar) && e.instance.props.message && e.instance.props.channel) {
let quoteButton = BDFDB.ReactUtils.findChild(e.returnvalue, {key: "quote"});
if (!quoteButton) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {key: ["reply", "mark-unread"]});
children.splice(index > -1 ? index : (!e.instance.props.expanded ? 1 : 0), 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "quote",
text: BDFDB.LanguageUtils.LanguageStrings.QUOTE,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
this.quote(e.instance.props.channel, e.instance.props.message);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
name: BDFDB.LibraryComponents.SvgIcon.Names.QUOTE
})
if (!e.instance.props.message || !e.instance.props.channel) return;
let expanded = !BDFDB.LibraryStores.AccessibilityStore.keyboardModeEnabled && !e.instance.props.showEmojiPicker && !e.instance.props.showEmojiBurstPicker && !e.instance.props.showMoreUtilities && BDFDB.ListenerUtils.isPressed(16);
if (!expanded && this.settings.general.holdShiftToolbar) return;
let quoteButton = BDFDB.ReactUtils.findChild(e.returnvalue, {key: "quote"});
if (!quoteButton) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {key: ["reply", "mark-unread"]});
children.splice(index > -1 ? index : (!e.instance.props.expanded ? 1 : 0), 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "quote",
text: BDFDB.LanguageUtils.LanguageStrings.QUOTE,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
this.quote(e.instance.props.channel, e.instance.props.message);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
name: BDFDB.LibraryComponents.SvgIcon.Names.QUOTE
})
}));
}
})
}));
}
}

View File

@ -2,7 +2,7 @@
* @name PersonalPins
* @author DevilBro
* @authorId 278543574059057154
* @version 2.1.6
* @version 2.1.7
* @description Allows you to locally pin Messages
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -516,41 +516,42 @@ module.exports = (_ => {
}
processMessageToolbar (e) {
if (e.instance.props.expanded && e.instance.props.message && e.instance.props.channel) {
let note = this.getNoteData(e.instance.props.message, e.instance.props.channel);
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(class extends BdApi.React.Component {
render() {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: note ? "unpin-note" : "pin-note",
text: _ => note ? _this.labels.context_unpinoption : _this.labels.context_pinoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
_this.addMessageToNotes(e.instance.props.message, e.instance.props.channel);
note = _this.getNoteData(e.instance.props.message, e.instance.props.channel);
BDFDB.ReactUtils.forceUpdate(this);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: note ? pinIconDelete : pinIcon
})
if (!e.instance.props.message || !e.instance.props.channel) return;
let expanded = !BDFDB.LibraryStores.AccessibilityStore.keyboardModeEnabled && !e.instance.props.showEmojiPicker && !e.instance.props.showEmojiBurstPicker && !e.instance.props.showMoreUtilities && BDFDB.ListenerUtils.isPressed(16);
if (!expanded) return;
let note = this.getNoteData(e.instance.props.message, e.instance.props.channel);
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(class extends BdApi.React.Component {
render() {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: note ? "unpin-note" : "pin-note",
text: _ => note ? _this.labels.context_unpinoption : _this.labels.context_pinoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
_this.addMessageToNotes(e.instance.props.message, e.instance.props.channel);
note = _this.getNoteData(e.instance.props.message, e.instance.props.channel);
BDFDB.ReactUtils.forceUpdate(this);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: note ? pinIconDelete : pinIcon
})
})
}
}));
if (this.isNoteOutdated(note, e.instance.props.message)) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "update-note",
text: this.labels.context_updateoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => this.updateNoteData(note, e.instance.props.message),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: pinIconUpdate
})
})
}));
}
}
}));
if (this.isNoteOutdated(note, e.instance.props.message)) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "update-note",
text: this.labels.context_updateoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => this.updateNoteData(note, e.instance.props.message),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: pinIconUpdate
})
})
}));
}
processHeaderBar (e) {

View File

@ -2,7 +2,7 @@
* @name Translator
* @author DevilBro
* @authorId 278543574059057154
* @version 2.4.9
* @version 2.5.0
* @description Allows you to translate Messages and your outgoing Messages within Discord
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -632,31 +632,32 @@ module.exports = (_ => {
}
processMessageToolbar (e) {
if (e.instance.props.expanded && e.instance.props.message && e.instance.props.channel) {
let translated = !!translatedMessages[e.instance.props.message.id];
e.returnvalue.props.children.unshift();
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(class extends BdApi.React.Component {
render() {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: translated ? "untranslate-message" : "translate-message",
text: _ => translated ? _this.labels.context_messageuntranslateoption : _this.labels.context_messagetranslateoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
if (!isTranslating) _this.translateMessage(e.instance.props.message, e.instance.props.channel).then(_ => {
translated = !!translatedMessages[e.instance.props.message.id];
BDFDB.ReactUtils.forceUpdate(this);
});
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: translated ? translateIconUntranslate : translateIcon
})
if (!e.instance.props.message || !e.instance.props.channel) return;
let expanded = !BDFDB.LibraryStores.AccessibilityStore.keyboardModeEnabled && !e.instance.props.showEmojiPicker && !e.instance.props.showEmojiBurstPicker && !e.instance.props.showMoreUtilities && BDFDB.ListenerUtils.isPressed(16);
if (!expanded) return;
let translated = !!translatedMessages[e.instance.props.message.id];
e.returnvalue.props.children.unshift();
e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(class extends BdApi.React.Component {
render() {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: translated ? "untranslate-message" : "translate-message",
text: _ => translated ? _this.labels.context_messageuntranslateoption : _this.labels.context_messagetranslateoption,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
if (!isTranslating) _this.translateMessage(e.instance.props.message, e.instance.props.channel).then(_ => {
translated = !!translatedMessages[e.instance.props.message.id];
BDFDB.ReactUtils.forceUpdate(this);
});
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.messagetoolbaricon,
iconSVG: translated ? translateIconUntranslate : translateIcon
})
});
}
}));
}
})
});
}
}));
}
processChannelTextAreaContainer (e) {