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: '' 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.', 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: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js' github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js'
@ -50,7 +50,7 @@ module.exports = (() => {
{ {
title: 'Boring changes', title: 'Boring changes',
type: 'fixed', 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: [ 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 { 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; 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; let CancelledAsync = false;
const DefaultLibrarySettings = {}; const DefaultLibrarySettings = {};
@ -133,7 +148,7 @@ module.exports = (() => {
if (global.XenoLib) { if (global.XenoLib) {
try { try {
global.XenoLib.shutdown(); global.XenoLib.shutdown();
} catch (e) {} } catch (e) { }
} }
const XenoLib = {}; const XenoLib = {};
XenoLib.shutdown = () => { XenoLib.shutdown = () => {
@ -642,7 +657,6 @@ module.exports = (() => {
const ErrorClassname = XenoLib.getClass('input error'); const ErrorClassname = XenoLib.getClass('input error');
try { try {
const dialog = require('electron').remote.dialog;
const DelayedCall = WebpackModules.getByProps('DelayedCall').DelayedCall; const DelayedCall = WebpackModules.getByProps('DelayedCall').DelayedCall;
const FsModule = require('fs'); const FsModule = require('fs');
/** /**
@ -677,7 +691,7 @@ module.exports = (() => {
}); });
} }
handleOnBrowse() { 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); if (path) this.handleChange(path);
}); });
} }
@ -732,10 +746,33 @@ module.exports = (() => {
*/ */
const FormItem = WebpackModules.getByDisplayName('FormItem'); const FormItem = WebpackModules.getByDisplayName('FormItem');
const DeprecatedModal = WebpackModules.getByDisplayName('DeprecatedModal'); 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 { class ColorPickerModal extends React.PureComponent {
constructor(props) { constructor(props) {
@ -750,13 +787,13 @@ module.exports = (() => {
render() { render() {
return React.createElement( return React.createElement(
DeprecatedModal, DeprecatedModal,
{ className: ModalContainerClassname, tag: 'form', onSubmit: this.handleSubmit, size: '' }, { tag: 'form', onSubmit: this.handleSubmit, size: '' },
React.createElement( React.createElement(
DeprecatedModal.Content, DeprecatedModal.Content,
{ className: ModalContentClassname }, {},
React.createElement( React.createElement(
FormItem, FormItem,
{ className: DiscordClasses.Margins.marginTop20 }, { className: XenoLib.joinClassNames(DiscordClasses.Margins.marginTop20.value, DiscordClasses.Margins.marginBottom20.value) },
React.createElement(ColorPickerComponent, { React.createElement(ColorPickerComponent, {
defaultColor: this.props.defaultColor, 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], 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],
@ -871,7 +908,7 @@ module.exports = (() => {
XenoLib.Settings = {}; XenoLib.Settings = {};
XenoLib.Settings.FilePicker = class FilePickerSettingField extends Settings.SettingField { XenoLib.Settings.FilePicker = class FilePickerSettingField extends Settings.SettingField {
constructor(name, note, value, onChange, options = { properties: ['openDirectory', 'createDirectory'], placeholder: 'Path to folder', defaultPath: '' }) { constructor(name, note, value, onChange, options = { properties: ['openDirectory', 'createDirectory'], placeholder: 'Path to folder', defaultPath: '' }) {
super(name, note, onChange, XenoLib.ReactComponents.FilePicker || class b {}, { super(name, note, onChange, XenoLib.ReactComponents.FilePicker || class b { }, {
onChange: reactElement => path => { onChange: reactElement => path => {
this.onChange(path ? path : options.defaultPath); this.onChange(path ? path : options.defaultPath);
}, },
@ -1064,7 +1101,7 @@ module.exports = (() => {
const getSubscriber = (listener, selector, equalityFn) => { const getSubscriber = (listener, selector, equalityFn) => {
if (selector === void 0) selector = getState; if (selector === void 0) selector = getState;
if (equalityFn === void 0) equalityFn = Object.is; if (equalityFn === void 0) equalityFn = Object.is;
return { currentSlice: selector(state), equalityFn: equalityFn, errored: false, listener: listener, selector: selector, unsubscribe: function unsubscribe() {} }; return { currentSlice: selector(state), equalityFn: equalityFn, errored: false, listener: listener, selector: selector, unsubscribe: function unsubscribe() { } };
}; };
var subscribe = function subscribe(subscriber) { var subscribe = function subscribe(subscriber) {
function listener() { function listener() {
@ -1520,6 +1557,8 @@ module.exports = (() => {
this.closeNow(); this.closeNow();
}, },
onContextMenu: e => { onContextMenu: e => {
e.preventDefault();
e.stopPropagation();
const state = api.getState(); const state = api.getState();
state.data.forEach(notif => utils.remove(notif.id)); state.data.forEach(notif => utils.remove(notif.id));
}, },
@ -1550,14 +1589,14 @@ module.exports = (() => {
} catch (e) { } catch (e) {
Logger.stacktrace('There has been an error loading the Notifications system, fallback object has been put in place to prevent errors', e); Logger.stacktrace('There has been an error loading the Notifications system, fallback object has been put in place to prevent errors', e);
XenoLib.Notifications = { XenoLib.Notifications = {
success(content, options = {}) {}, success(content, options = {}) { },
info(content, options = {}) {}, info(content, options = {}) { },
warning(content, options = {}) {}, warning(content, options = {}) { },
danger(content, options = {}) {}, danger(content, options = {}) { },
error(content, options = {}) {}, error(content, options = {}) { },
show(content, options = {}) {}, show(content, options = {}) { },
remove(id) {}, remove(id) { },
update(id, options) {} update(id, options) { }
}; };
} }
/* NOTIFICATIONS END */ /* NOTIFICATIONS END */
@ -1659,7 +1698,7 @@ module.exports = (() => {
XenoLib.changeName(__filename, '1XenoLib'); /* prevent user from changing libs filename */ XenoLib.changeName(__filename, '1XenoLib'); /* prevent user from changing libs filename */
try { try {
WebpackModules.getByProps('openModal', 'hasModalOpen').closeModal(`${this.name}_DEP_MODAL`); WebpackModules.getByProps('openModal', 'hasModalOpen').closeModal(`${this.name}_DEP_MODAL`);
} catch (e) {} } catch (e) { }
} }
load() { load() {
super.load(); super.load();
@ -1720,7 +1759,6 @@ module.exports = (() => {
} }
} }
showChangelog(footer) { showChangelog(footer) {
return;
XenoLib.showChangelog(`${this.name} has been updated!`, this.version, this._config.changelog); XenoLib.showChangelog(`${this.name} has been updated!`, this.version, this._config.changelog);
} }
get name() { get name() {
@ -1755,7 +1793,7 @@ module.exports = (() => {
if (global.BdApi && 'function' == typeof BdApi.getPlugin) { 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]), 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 = 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) { } catch (e) {
console.error('Error checking if ZeresPluginLibrary is out of date', e); console.error('Error checking if ZeresPluginLibrary is out of date', e);
@ -1779,8 +1817,8 @@ module.exports = (() => {
getDescription() { getDescription() {
return this.description + ' You are missing ZeresPluginLibrary for this plugin, please enable the plugin and click Download Now.'; return this.description + ' You are missing ZeresPluginLibrary for this plugin, please enable the plugin and click Download Now.';
} }
start() {} start() { }
stop() {} stop() { }
handleMissingLib() { handleMissingLib() {
const a = BdApi.findModuleByProps('openModal', 'hasModalOpen'); const a = BdApi.findModuleByProps('openModal', 'hasModalOpen');
if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return; if (a && a.hasModalOpen(`${this.name}_DEP_MODAL`)) return;
@ -1835,7 +1873,7 @@ module.exports = (() => {
b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, e, f) => { b('https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js', (b, e, f) => {
try { try {
if (b || 200 !== e.statusCode) return a.closeModal(k), g(); if (b || 200 !== e.statusCode) return a.closeModal(k), g();
c.writeFile(d.join(BdApi.Plugins && BdApi.Plugins.folder ? BdApi.Plugins.folder : window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), f, () => {}); c.writeFile(d.join(BdApi.Plugins && BdApi.Plugins.folder ? BdApi.Plugins.folder : window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), f, () => { });
} catch (b) { } catch (b) {
console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(k), g(); console.error('Fatal error downloading ZeresPluginLibrary', b), a.closeModal(k), g();
} }
@ -1843,7 +1881,7 @@ module.exports = (() => {
} }
}, },
b, b,
{ onClose: () => {} } { onClose: () => { } }
) )
) )
); );