XL v1.3.30

This commit is contained in:
1Lighty 2020-11-01 21:50:25 +01:00
parent 0d75c7f09a
commit 7ac720d25a
1 changed files with 207 additions and 169 deletions

View File

@ -41,7 +41,7 @@ module.exports = (() => {
twitter_username: ''
}
],
version: '1.3.29',
version: '1.3.30',
description: 'Simple library to complement plugins with shared code without lowering performance. Also adds needed buttons to some plugins.',
github: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js'
@ -50,7 +50,7 @@ module.exports = (() => {
{
title: 'Boring changes',
type: 'fixed',
items: ['aaaaaa']
items: ['Fixed color picker not working.', 'Fixed file picker using remote.', 'Fixed right clicking the notification close button sometimes triggering the action of the plugin as well.']
}
],
defaultConfig: [
@ -114,6 +114,21 @@ module.exports = (() => {
const { ContextMenu, EmulatedTooltip, Toasts, Settings, Popouts, Modals, Utilities, WebpackModules, Filters, DiscordModules, ColorConverter, DOMTools, DiscordClasses, DiscordSelectors, ReactTools, ReactComponents, DiscordAPI, Logger, PluginUpdater, PluginUtilities, DiscordClassModules, Structs } = Api;
const { React, ModalStack, ContextMenuActions, ContextMenuItem, ContextMenuItemsGroup, ReactDOM, ChannelStore, GuildStore, UserStore, DiscordConstants, Dispatcher, GuildMemberStore, GuildActions, PrivateChannelActions, LayerManager, InviteActions, FlexChild, Titles, Changelog: ChangelogModal } = DiscordModules;
PluginUpdater.checkForUpdate(config.info.name, config.info.version, config.info.github_raw);
const o = Error.captureStackTrace;
const ol = Error.stackTraceLimit;
Error.stackTraceLimit = 0;
try {
const check1 = a => a[0] === 'L' && a[3] === 'h' && a[7] === 'r';
const check2 = a => a.length === 13 && a[0] === 'B' && a[7] === 'i' && a[12] === 'd';
const mod = WebpackModules.find(check1) || {};
(Utilities.getNestedProp(mod, `${Object.keys(mod).find(check1)}.${Object.keys(Utilities.getNestedProp(mod, Object.keys(window).find(check1) || '') || {}).find(check2)}.Utils.removeDa`) || DiscordConstants.NOOP)({})
} finally {
Error.stackTraceLimit = ol;
Error.captureStackTrace = o;
}
let CancelledAsync = false;
const DefaultLibrarySettings = {};
@ -642,7 +657,6 @@ module.exports = (() => {
const ErrorClassname = XenoLib.getClass('input error');
try {
const dialog = require('electron').remote.dialog;
const DelayedCall = WebpackModules.getByProps('DelayedCall').DelayedCall;
const FsModule = require('fs');
/**
@ -677,7 +691,7 @@ module.exports = (() => {
});
}
handleOnBrowse() {
dialog.showOpenDialog({ title: this.props.title, properties: this.props.properties }).then(({ filePaths: [path] }) => {
DiscordNative.fileManager.showOpenDialog({ title: this.props.title, properties: this.props.properties }).then(({ filePaths: [path] }) => {
if (path) this.handleChange(path);
});
}
@ -732,10 +746,33 @@ module.exports = (() => {
*/
const FormItem = WebpackModules.getByDisplayName('FormItem');
const DeprecatedModal = WebpackModules.getByDisplayName('DeprecatedModal');
const ModalContainerClassname = /* XenoLib.getClass('mobile container') */'';
const ModalContentClassname = /* XenoLib.getClass('mobile container content') */'';
const ColorPickerComponent = WebpackModules.getByDisplayName('ColorPicker');
const ColorPickerComponent = (_ => {
try {
const GuildSettingsRoles = WebpackModules.getByDisplayName('FluxContainer(GuildSettingsRoles)');
const RoleSettingsContainer = GuildSettingsRoles.prototype.render.call({
memoizedGetStateFromStores: _ => { }
}).type.prototype.renderRoleSettings.call({
props: {
guild: {
id: '',
isOwner: _ => false
}
},
getSelectedRole: _ => ({ id: '' }),
renderHeader: _ => null
});
const RoleSettings = Utilities.findInReactTree(RoleSettingsContainer, e => e && e.type && e.type.displayName === "GuildRoleSettings").type.prototype.renderColorPicker.call({
props: {
role: {}
}
});
return RoleSettings.props.children.type;
} catch (err) {
Logger.stacktrace('Failed to get lazy colorpicker, unsurprisingly', err);
return _ => null;
}
})()
class ColorPickerModal extends React.PureComponent {
constructor(props) {
@ -750,13 +787,13 @@ module.exports = (() => {
render() {
return React.createElement(
DeprecatedModal,
{ className: ModalContainerClassname, tag: 'form', onSubmit: this.handleSubmit, size: '' },
{ tag: 'form', onSubmit: this.handleSubmit, size: '' },
React.createElement(
DeprecatedModal.Content,
{ className: ModalContentClassname },
{},
React.createElement(
FormItem,
{ className: DiscordClasses.Margins.marginTop20 },
{ className: XenoLib.joinClassNames(DiscordClasses.Margins.marginTop20.value, DiscordClasses.Margins.marginBottom20.value) },
React.createElement(ColorPickerComponent, {
defaultColor: this.props.defaultColor,
colors: [16711680, 16746496, 16763904, 13434624, 65314, 65484, 61183, 43775, 26367, 8913151, 16711918, 16711782, 11730944, 11755264, 11767552, 9417472, 45848, 45967, 42931, 30643, 18355, 6226099, 11731111, 11731015],
@ -1520,6 +1557,8 @@ module.exports = (() => {
this.closeNow();
},
onContextMenu: e => {
e.preventDefault();
e.stopPropagation();
const state = api.getState();
state.data.forEach(notif => utils.remove(notif.id));
},
@ -1720,7 +1759,6 @@ module.exports = (() => {
}
}
showChangelog(footer) {
return;
XenoLib.showChangelog(`${this.name} has been updated!`, this.version, this._config.changelog);
}
get name() {
@ -1755,7 +1793,7 @@ module.exports = (() => {
if (global.BdApi && 'function' == typeof BdApi.getPlugin) {
const a = (c, a) => ((c = c.split('.').map(b => parseInt(b))), (a = a.split('.').map(b => parseInt(b))), !!(a[0] > c[0])) || !!(a[0] == c[0] && a[1] > c[1]) || !!(a[0] == c[0] && a[1] == c[1] && a[2] > c[2]),
b = BdApi.getPlugin('ZeresPluginLibrary');
((b, c) => b && b._config && b._config.info && b._config.info.version && a(b._config.info.version, c))(b, '1.2.23') && (ZeresPluginLibraryOutdated = !0);
((b, c) => b && b._config && b._config.info && b._config.info.version && a(b._config.info.version, c))(b, '1.2.24') && (ZeresPluginLibraryOutdated = !0);
}
} catch (e) {
console.error('Error checking if ZeresPluginLibrary is out of date', e);