add previews, MAR v2.0.6

This commit is contained in:
_Lighty_ 2020-02-08 13:35:04 +01:00
parent 5800444b08
commit a65b9cd64c
8 changed files with 96 additions and 63 deletions

View File

@ -6,3 +6,5 @@ This plugin simply fixes that, so the server stays in the sidebar and you can mo
BetterDiscord and BetterDiscord2 servers are precached for convenience sake. BetterDiscord and BetterDiscord2 servers are precached for convenience sake.
### Settings ### Settings
N/A N/A
### Preview
![preview](https://i.imgur.com/C2z5Bj5.png)

View File

@ -8,3 +8,10 @@ If your Discord crashes out of random (maybe you clicked something?) it'll attem
In the event that recovery fails, you still have some info on what plugin may have been responsible for the initial crash, and have a button alongside the reload button, to try to recover again, maybe after removing a plugin from your plugins folder. In the event that recovery fails, you still have some info on what plugin may have been responsible for the initial crash, and have a button alongside the reload button, to try to recover again, maybe after removing a plugin from your plugins folder.
### Settings ### Settings
N/A N/A
### Preview
Plugin start crash
![crash](https://i.imgur.com/Sb5BSX9.png)
Unknown crash that may happen at random
![crash2](https://i.imgur.com/oICzvKB.png)
Startup crash + reenable auto disabled plugins due to crash
![startcrash](https://i.imgur.com/ZtkJG5N.png)

View File

@ -1,4 +1,8 @@
# [MentionAliasesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux "MentionAliasesRedux") Changelog # [MentionAliasesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux "MentionAliasesRedux") Changelog
### 2.0.6
- Fixed menu button not showing
- Fixed misc error spam
### 2.0.5 ### 2.0.5
- Fixed crash if XenoLib or ZeresPluginLib were missing - Fixed crash if XenoLib or ZeresPluginLib were missing

View File

@ -41,16 +41,16 @@ var MentionAliasesRedux = (() => {
twitter_username: '' twitter_username: ''
} }
], ],
version: '2.0.5', version: '2.0.6',
description: 'Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.', description: 'Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.',
github: 'https://github.com/1Lighty', github: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/MentionAliasesRedux/MentionAliasesRedux.plugin.js' github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/MentionAliasesRedux/MentionAliasesRedux.plugin.js'
}, },
changelog: [ changelog: [
{ {
title: 'sad', title: "bug b' gone",
type: 'fixed', type: 'fixed',
items: ['Fixed crash if XenoLib or ZeresPluginLib were missing'] items: ['Fixed menu button not showing', 'Fixed misc error spam']
} }
], ],
defaultConfig: [ defaultConfig: [
@ -184,7 +184,7 @@ var MentionAliasesRedux = (() => {
const PopoutTagClassname = XenoLib.joinClassNames('mentionAlias', XenoLib.getClass('botTagRegular'), XenoLib.getClass('nameTag bot')); const PopoutTagClassname = XenoLib.joinClassNames('mentionAlias', XenoLib.getClass('botTagRegular'), XenoLib.getClass('nameTag bot'));
const roughlyMatches = WebpackModules.getByRegex(/{var \w=\w\.length,\w=\w\.length;if\(\w>\w\)return!1;if\(\w===\w\)return \w===\w;\w:/); const roughlyMatches = WebpackModules.getByRegex(/{var \w=\w\.length,\w=\w\.length;if\(\w>\w\)return!1;if\(\w===\w\)return \w===\w;\w:/);
const AnimatedAvatar = WebpackModules.getByProps('AnimatedAvatar').AnimatedAvatar; const AnimatedAvatar = (WebpackModules.getByProps('AnimatedAvatar') || {}).AnimatedAvatar;
const renderAvatar = user => React.createElement(AnimatedAvatar, { size: 'SIZE_32', src: user.getAvatarURL(), status: UserStatusStore.getStatus(user.id), isMobile: UserStatusStore.isMobileOnline(user.id), isTyping: false, statusTooltip: true }); const renderAvatar = user => React.createElement(AnimatedAvatar, { size: 'SIZE_32', src: user.getAvatarURL(), status: UserStatusStore.getStatus(user.id), isMobile: UserStatusStore.isMobileOnline(user.id), isTyping: false, statusTooltip: true });
const renderAlias = (name, description, color, noAt) => React.createElement(FlexChild, { align: FlexChild.Align.CENTER, className: AutocompleteContentClassname }, React.createElement(FlexChild.Child, { grow: 1 }, React.createElement(TextElement.default, { style: { color } }, noAt ? undefined : '@', name)), React.createElement(TextElement.default, { className: AutocompleteDescriptionClassname }, description)); const renderAlias = (name, description, color, noAt) => React.createElement(FlexChild, { align: FlexChild.Align.CENTER, className: AutocompleteContentClassname }, React.createElement(FlexChild.Child, { grow: 1 }, React.createElement(TextElement.default, { style: { color } }, noAt ? undefined : '@', name)), React.createElement(TextElement.default, { className: AutocompleteDescriptionClassname }, description));
@ -262,7 +262,7 @@ var MentionAliasesRedux = (() => {
} }
} }
class SetAliasModal extends WebpackModules.getByDisplayName('ChangeNickname') { class SetAliasModal extends (WebpackModules.getByDisplayName('ChangeNickname') || class fuck {}) {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleSubmit = this.handleSubmitPatch.bind(this); this.handleSubmit = this.handleSubmitPatch.bind(this);
@ -290,7 +290,7 @@ var MentionAliasesRedux = (() => {
} }
render() { render() {
const m = {}; const m = {};
m[WebpackModules.getByProps('autocomplete', 'selector').selectorSelected] = this.state.hovered; m[XenoLib.getClass('autocomplete selector')] = this.state.hovered;
m[XenoLib.getClass('avatar layout')] = this.props.isUser; m[XenoLib.getClass('avatar layout')] = this.props.isUser;
return React.createElement('div', { className: XenoLib.joinClassNames(WebpackModules.getByProps('autocomplete', 'selector').selector, WebpackModules.getByProps('autocomplete', 'selector').selectable, m), onMouseEnter: () => this.setState({ hovered: true }), onMouseLeave: () => this.setState({ hovered: false }), onContextMenu: this.props.onContextMenu, onClick: this.props.onClick }, this.props.children); return React.createElement('div', { className: XenoLib.joinClassNames(WebpackModules.getByProps('autocomplete', 'selector').selector, WebpackModules.getByProps('autocomplete', 'selector').selectable, m), onMouseEnter: () => this.setState({ hovered: true }), onMouseLeave: () => this.setState({ hovered: false }), onContextMenu: this.props.onContextMenu, onClick: this.props.onClick }, this.props.children);
} }
@ -396,10 +396,11 @@ var MentionAliasesRedux = (() => {
return class MentionAliasesRedux extends Plugin { return class MentionAliasesRedux extends Plugin {
constructor() { constructor() {
super(); super();
XenoLib.DiscordUtils.bindAll(this, ['openAliasesPopout', 'queryAliases', 'setAlias', 'setGroup', 'handleSetAliasDispatch', 'handleSetGroupDispatch', 'getUserAlias', 'forceUpdateAll', 'handleContextMenu']); XenoLib._.bindAll(this, ['openAliasesPopout', 'queryAliases', 'setAlias', 'setGroup', 'handleSetAliasDispatch', 'handleSetGroupDispatch', 'getUserAlias', 'forceUpdateAll', 'handleContextMenu']);
XenoLib.changeName(__filename, 'MentionAliasesRedux'); XenoLib.changeName(__filename, 'MentionAliasesRedux');
} }
onStart() { onStart() {
this.__menuBroken = false;
this.patchedModules = []; this.patchedModules = [];
/* migrate settings */ /* migrate settings */
if (typeof this.settings.aliases !== 'undefined') { if (typeof this.settings.aliases !== 'undefined') {
@ -710,7 +711,7 @@ var MentionAliasesRedux = (() => {
}; };
}); });
/* reason for div:not is so it doesn't match anything that is not an actual message, like pins */ /* reason for div:not is so it doesn't match anything that is not an actual message, like pins */
const Message = new ReactComponents.ReactComponent('Message', MessageModule.Message, `.${XenoLib.getSingleClass('messageEditorCompact container')} > div:not(.${XenoLib.getSingleClass('marginCompactIndent content')})`); const Message = new ReactComponents.ReactComponent('Message', MessageModule.Message, `.${XenoLib.getSingleClass('messageEditorCompact container', true)} > div:not(.${XenoLib.getSingleClass('marginCompactIndent content', true)})`);
this.patchedModules.push(Message); this.patchedModules.push(Message);
Message.forceUpdateAll(); Message.forceUpdateAll();
} else { } else {
@ -759,7 +760,7 @@ var MentionAliasesRedux = (() => {
} }
async patchMemberListItem(promiseState) { async patchMemberListItem(promiseState) {
const MemberListItem = await ReactComponents.getComponentByName('MemberListItem', `.${XenoLib.getSingleClass('offline member')}`); const MemberListItem = await ReactComponents.getComponentByName('MemberListItem', `.${XenoLib.getSingleClass('offline member', true)}`);
if (promiseState.cancelled) return; if (promiseState.cancelled) return;
Patcher.after(MemberListItem.component.prototype, 'render', (_this, _, ret) => { Patcher.after(MemberListItem.component.prototype, 'render', (_this, _, ret) => {
if (!_this.props.user || !this.settings.display.displayMemberTags) return; if (!_this.props.user || !this.settings.display.displayMemberTags) return;
@ -772,7 +773,7 @@ var MentionAliasesRedux = (() => {
} }
async patchPrivateChannel(promiseState) { async patchPrivateChannel(promiseState) {
const PrivateChannel = await ReactComponents.getComponentByName('PrivateChannel', `.${XenoLib.getSingleClass('closeButton channel')}`); const PrivateChannel = await ReactComponents.getComponentByName('PrivateChannel', `.${XenoLib.getSingleClass('closeButton channel', true)}`);
if (promiseState.cancelled) return; if (promiseState.cancelled) return;
const TypePatch = function(e) { const TypePatch = function(e) {
const ret = e.__oldTypeMA(e); const ret = e.__oldTypeMA(e);
@ -794,7 +795,7 @@ var MentionAliasesRedux = (() => {
} }
/* friends list */ /* friends list */
async patchPeopleListItem(promiseState) { async patchPeopleListItem(promiseState) {
const PeopleListItem = await ReactComponents.getComponentByName('PeopleListItem', `.${XenoLib.getSingleClass('noBorder peopleListItem')}`); const PeopleListItem = await ReactComponents.getComponentByName('PeopleListItem', `.${XenoLib.getSingleClass('peopleListItem', true)}`);
if (promiseState.cancelled) return; if (promiseState.cancelled) return;
const TypePatch3 = function(e) { const TypePatch3 = function(e) {
try { try {
@ -865,7 +866,7 @@ var MentionAliasesRedux = (() => {
} }
/* mutual friends */ /* mutual friends */
async patchMutualFriends(promiseState) { async patchMutualFriends(promiseState) {
const MutualFriends = await ReactComponents.getComponentByName('MutualFriends', `.${XenoLib.getSingleClass('scroller themeGhostHairline')}`); const MutualFriends = await ReactComponents.getComponentByName('MutualFriends', `.${XenoLib.getSingleClass('scroller themeGhostHairline', true)}`);
if (promiseState.cancelled) return; if (promiseState.cancelled) return;
const TypePatch3 = function(e) { const TypePatch3 = function(e) {
try { try {
@ -937,11 +938,9 @@ var MentionAliasesRedux = (() => {
} }
/* add mentions popout button */ /* add mentions popout button */
async patchChannelTextArea(promiseState) { async patchChannelTextArea(promiseState) {
const ChannelTextArea = await ReactComponents.getComponentByName('ChannelTextAreaForm', `.${XenoLib.getSingleClass('channelTextArea')}`); const ChannelTextAreaContainer = WebpackModules.find(m => m.type && m.type.render && m.type.render.displayName === 'ChannelTextAreaContainer');
if (promiseState.cancelled) return; Patcher.after(ChannelTextAreaContainer.type, 'render', (_this, _, ret) => {
const ChannelTextAreaContainer = WebpackModules.find(m => m.render && m.render.displayName === 'ChannelTextAreaContainer'); if (this.__menuBroken) return;
const original = ChannelTextAreaContainer.render;
Patcher.after(ChannelTextAreaContainer, 'render', (_this, _, ret) => {
const ChannelEditorContainer = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.1'); const ChannelEditorContainer = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.1');
if (!ChannelEditorContainer || ChannelEditorContainer.props.disabled || !this.settings.display.displayButton) return; if (!ChannelEditorContainer || ChannelEditorContainer.props.disabled || !this.settings.display.displayButton) return;
const buttons = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children'); const buttons = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children');
@ -952,14 +951,10 @@ var MentionAliasesRedux = (() => {
iconName: 'Nova_At', iconName: 'Nova_At',
label: 'Open Aliases', label: 'Open Aliases',
className: ChannelTextAreaButtonClassname, className: ChannelTextAreaButtonClassname,
onClick: e => this.openAliasesPopout(e, { _editorRef }) onClick: e => !this.__menuBroken && this.openAliasesPopout(e, { _editorRef })
}) })
); );
}); });
/* transfer displayName and such, to be friendly to other plugins */
Object.keys(original).forEach(name => (ChannelTextAreaContainer.render[name] = original[name]));
this.patchedModules.push(ChannelTextArea);
ChannelTextArea.forceUpdateAll();
} }
openAliasesPopout({ target }, ref) { openAliasesPopout({ target }, ref) {
@ -969,33 +964,49 @@ var MentionAliasesRedux = (() => {
showArrow: true, showArrow: true,
position: 'top', position: 'top',
zIndexBoost: 1, zIndexBoost: 1,
render: () => { render: _ => {
return React.createElement( try {
'div', return React.createElement(
{ XenoLib.ReactComponents.ErrorBoundary,
className: ZLibrary.WebpackModules.getByProps('header', 'messagesPopoutWrap').messagesPopoutWrap + ' ' + ZLibrary.WebpackModules.getByProps('themedPopout').themedPopout,
style: { maxHeight: Structs.Screen.height - 43 - 25 - 40 }
},
WebpackModules.getByProps('Header', 'EmptyStateBottom').Header({
title: 'Defined User Aliases'
}),
React.createElement(
WebpackModules.getByDisplayName('VerticalScroller'),
{ {
className: XenoLib.getClass('messagesPopoutWrap messagesPopout') label: 'Popout',
onError: () => _.onClose()
}, },
React.createElement(AliasesPopout, { React.createElement(
getUserAlias: this.getUserAlias, 'div',
getGroup: id => this.groups.find(m => m.id === id), {
getMentions: this.queryAliases, className: WebpackModules.getByProps('header', 'messagesPopoutWrap').messagesPopoutWrap,
getGroupUsers: this.getGroupUsers, style: { maxHeight: Structs.Screen.height - 43 - 25 - 40 }
setAlias: this.setAlias, },
setGroup: this.setGroup, WebpackModules.getByProps('Header', 'EmptyStateBottom').Header({
channelTextAreaRef: ref title: 'Defined User Aliases'
}) }),
), React.createElement(
false WebpackModules.getByDisplayName('VerticalScroller'),
); {
className: XenoLib.getClass('messagesPopoutWrap messagesPopout')
},
React.createElement(AliasesPopout, {
getUserAlias: this.getUserAlias,
getGroup: id => this.groups.find(m => m.id === id),
getMentions: this.queryAliases,
getGroupUsers: this.getGroupUsers,
setAlias: this.setAlias,
setGroup: this.setGroup,
channelTextAreaRef: ref
})
),
false
)
);
} catch (e) {
Logger.stacktrace('There has been an issue loading the menu', e);
XenoLib.Notifications.error('There has been an issue loading the menu. Open up the console using CTRL + SHIFT + I, click console, and show any errors to Lighty in the support server. Menu button has been disabled.', { timeout: 0 });
this.__menuBroken = true;
this.forceUpdateAll();
_.onClose();
return null;
}
} }
}, },
'MentionAliasesRedux' 'MentionAliasesRedux'

View File

@ -1,23 +1,25 @@
# MentionAliasesRedux [![download](https://i.imgur.com/OAHgjZu.png)](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux&dl=1 "MentionAliasesRedux") # MentionAliasesRedux [![download](https://i.imgur.com/OAHgjZu.png)](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux&dl=1 "MentionAliasesRedux")
Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once. Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.
### Features ### Features
Right click on a user or DM to set an alias, or create a group or add them to a group. Right click on a user or DM to set an alias, or create a group or add them to a group.
This alias will show next to their name, like a BOT tag, but only you see it. This alias will show next to their name, like a BOT tag, but only you see it.
You can tag them with this alias, just as if they had that very alias as their name. You can tag them with this alias, just as if they had that very alias as their name.
### Settings ### Settings
#### Display Settings #### Display Settings
##### Display * ##### Display *
tags menu button - Show an @ button to open a menu, showing all the aliases and groups you can tag in current channel tags menu button - Show an @ button to open a menu, showing all the aliases and groups you can tag in current channel
owner tags - The Owner tag will show. Note: owner always shows in menu owner tags - The Owner tag will show. Note: owner always shows in menu
tag in user popups - Show tag next to their name when you click on a user tag in user popups - Show tag next to their name when you click on a user
tags in members list - Show tag in members list in servers tags in members list - Show tag in members list in servers
tags in messages tags in messages
tag on the right side of the name in compact mode - If you use compact mode, you can set where the tag appears tag on the right side of the name in compact mode - If you use compact mode, you can set where the tag appears
alias in AKA in DMs alias in AKA in DMs
tag in DMs list tag in DMs list
tag in Mutual Friends tab in user modals tag in Mutual Friends tab in user modals
tag in friends list tag in friends list
##### Tag Text Color ##### Tag Text Color
Custom text color if your theme doesn't do it, or don't want to use custom CSS Custom text color if your theme doesn't do it, or don't want to use custom CSS
##### Tag Background Color ##### Tag Background Color
Set the background color of the tag next to their name Set the background color of the tag next to their name
### Preview
![preview](https://i.imgur.com/fCEhgQN.png)

View File

@ -22,3 +22,6 @@ Append random
#### Misc #### Misc
##### Context menu option at the bottom instead of top ##### Context menu option at the bottom instead of top
Force the Save * To option to stay at the bottom at all times Force the Save * To option to stay at the bottom at all times
### Preview
Right click on nearly any image, video or file
![preview](https://i.imgur.com/htOuqtw.png)

View File

@ -107,8 +107,8 @@ var SaveToRedux = (() => {
const ContextMenuSubMenuItem = WebpackModules.getByDisplayName('FluxContainer(SubMenuItem)'); const ContextMenuSubMenuItem = WebpackModules.getByDisplayName('FluxContainer(SubMenuItem)');
const TextComponent = WebpackModules.getByDisplayName('Text'); const TextComponent = WebpackModules.getByDisplayName('Text');
const getEmojiURL = WebpackModules.getByProps('getEmojiURL').getEmojiURL; const getEmojiURL = (WebpackModules.getByProps('getEmojiURL') || {}).getEmojiURL;
const showAlertModal = WebpackModules.find(m => m.show && m.show.toString().search(/\w\.minorText,\w=\w\.onConfirmSecondary/)).show; const showAlertModal = (WebpackModules.find(m => m.show && m.show.toString().search(/\w\.minorText,\w=\w\.onConfirmSecondary/)) || {}).show;
const dialog = require('electron').remote.dialog; const dialog = require('electron').remote.dialog;
const openSaveDialog = dialog.showSaveDialogSync || dialog.showSaveDialog; const openSaveDialog = dialog.showSaveDialogSync || dialog.showSaveDialog;
@ -119,7 +119,7 @@ var SaveToRedux = (() => {
const PathModule = require('path'); const PathModule = require('path');
const MimeTypesModule = require('mime-types'); const MimeTypesModule = require('mime-types');
const FormItem = WebpackModules.getByDisplayName('FormItem'); const FormItem = WebpackModules.getByDisplayName('FormItem');
const Messages = WebpackModules.getByProps('Messages').Messages; const Messages = (WebpackModules.getByProps('Messages') || {}).Messages;
const TextInput = WebpackModules.getByDisplayName('TextInput'); const TextInput = WebpackModules.getByDisplayName('TextInput');
const AvatarModule = WebpackModules.getByProps('getChannelIconURL'); const AvatarModule = WebpackModules.getByProps('getChannelIconURL');

View File

@ -17,4 +17,8 @@ Shows an unread badge on folders, server icons and channels, all toggleable with
Note: If you use BetterNsfwTags, it will always display to the right of it sadly. This option only changes if you want the badge to the left or the right of the settings and invite buttons (if you have them even) Note: If you use BetterNsfwTags, it will always display to the right of it sadly. This option only changes if you want the badge to the left or the right of the settings and invite buttons (if you have them even)
##### Background color ##### Background color
##### Text color ##### Text color
##### Muted channel badge darkness ##### Muted channel badge darkness
### Preview
![folders](https://i.imgur.com/v4kHabL.png)
![servers](https://i.imgur.com/MJHKjuT.png)
![channels](https://i.imgur.com/dhFgSrL.png)