UBR v1.0.3
This commit is contained in:
parent
e4fb92d49b
commit
2284acb4f1
|
@ -1,4 +1,7 @@
|
|||
# [UnreadBadgesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=UnreadBadgesRedux "UnreadBadgesRedux") Changelog
|
||||
### 1.0.3
|
||||
- Temp fixed a bug caused by ZLib, making the badges not show
|
||||
|
||||
### 1.0.2
|
||||
- Heavily optimized the plugin, expect better performance if you have lots of servers
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//META{"name":"UnreadBadgesRedux","source":"https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/UnreadBadgesRedux/","website":"https://1lighty.github.io/BetterDiscordStuff/?plugin=UnreadBadgesRedux"}*//
|
||||
//META{"name":"UnreadBadgesRedux","source":"https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/UnreadBadgesRedux/","website":"https://1lighty.github.io/BetterDiscordStuff/?plugin=UnreadBadgesRedux","authorId":"239513071272329217","invite":"NYvWdN5","donate":"https://paypal.me/lighty13"}*//
|
||||
/*@cc_on
|
||||
@if (@_jscript)
|
||||
|
||||
|
@ -41,16 +41,16 @@ var UnreadBadgesRedux = (() => {
|
|||
twitter_username: ''
|
||||
}
|
||||
],
|
||||
version: '1.0.2',
|
||||
version: '1.0.3',
|
||||
description: 'Adds a number badge to server icons and channels.',
|
||||
github: 'https://github.com/1Lighty',
|
||||
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/UnreadBadgesRedux/UnreadBadgesRedux.plugin.js'
|
||||
},
|
||||
changelog: [
|
||||
{
|
||||
title: 'wohoo!',
|
||||
title: 'darn',
|
||||
type: 'fixed',
|
||||
items: ['Heavily optimized the plugin, expect better performance if you have lots of servers']
|
||||
items: ['Temp fixed a bug caused by ZLib, making the badges not show']
|
||||
}
|
||||
],
|
||||
defaultConfig: [
|
||||
|
@ -235,6 +235,9 @@ var UnreadBadgesRedux = (() => {
|
|||
constructor() {
|
||||
super();
|
||||
XenoLib.changeName(__filename, 'UnreadBadgesRedux');
|
||||
try {
|
||||
ModalStack.popWithKey(`${this.name}_DEP_MODAL`);
|
||||
} catch (e) {}
|
||||
}
|
||||
onStart() {
|
||||
this.promises = { state: { cancelled: false } };
|
||||
|
@ -299,7 +302,9 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
|
||||
async patchChannelItem(promiseState) {
|
||||
const ChannelItem = await ReactComponents.getComponentByName('ChannelItem', `.${XenoLib.getSingleClass('modeUnread wrapper')}`);
|
||||
const selector = `.${XenoLib.getSingleClass('modeUnread wrapper', true)}`;
|
||||
const ChannelItem = await ReactComponents.getComponentByName('ChannelItem', selector);
|
||||
if (!ChannelItem.selector) ChannelItem.selector = selector;
|
||||
if (promiseState.cancelled) return;
|
||||
const settings = this.settings;
|
||||
const MentionsBadgeClassname = XenoLib.getClass('iconVisibility mentionsBadge');
|
||||
|
@ -345,7 +350,9 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
|
||||
async patchGuildFolder(promiseState) {
|
||||
const GuildFolder = await ReactComponents.getComponentByName('GuildFolder', `.${XenoLib.getSingleClass('folder wrapper')}`);
|
||||
const selector = `.${XenoLib.getSingleClass('folder wrapper', true)}`;
|
||||
const GuildFolder = await ReactComponents.getComponentByName('GuildFolder', selector);
|
||||
if (!GuildFolder.selector) GuildFolder.selector = selector;
|
||||
if (promiseState.cancelled) return;
|
||||
const settings = this.settings;
|
||||
function BlobMaskWrapper(e) {
|
||||
|
@ -375,7 +382,9 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
|
||||
async patchConnectedGuild(promiseState) {
|
||||
const ConnectedGuild = await ReactComponents.getComponentByName('DragSource(ConnectedGuild)', `.${XenoLib.getSingleClass('listItem')}`);
|
||||
const selector = `.${XenoLib.getSingleClass('listItem', true)}`;
|
||||
const ConnectedGuild = await ReactComponents.getComponentByName('DragSource(ConnectedGuild)', selector);
|
||||
if (!ConnectedGuild.selector) ConnectedGuild.selector = selector;
|
||||
if (promiseState.cancelled) return;
|
||||
const settings = this.settings;
|
||||
function PatchedConnectedGuild(e) {
|
||||
|
@ -398,7 +407,9 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
|
||||
async patchGuildIcon(promiseState) {
|
||||
const Guild = await ReactComponents.getComponentByName('Guild', `.${XenoLib.getSingleClass('listItem')}`);
|
||||
const selector = `.${XenoLib.getSingleClass('listItem', true)}`;
|
||||
const Guild = await ReactComponents.getComponentByName('Guild', selector);
|
||||
if (!Guild.selector) Guild.selector = selector;
|
||||
if (promiseState.cancelled) return;
|
||||
Patcher.after(Guild.component.prototype, 'render', (_this, _, ret) => {
|
||||
const mask = Utilities.findInTree(ret, e => e && e.type && e.type.displayName === 'BlobMask', { walkable: ['props', 'children'] });
|
||||
|
@ -410,7 +421,9 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
|
||||
async patchBlobMask(promiseState) {
|
||||
const BlobMask = await ReactComponents.getComponentByName('BlobMask', `.${XenoLib.getSingleClass('lowerBadge wrapper')}`);
|
||||
const selector = `.${XenoLib.getSingleClass('lowerBadge wrapper')}`;
|
||||
const BlobMask = await ReactComponents.getComponentByName('BlobMask', selector);
|
||||
if (!BlobMask.selector) BlobMask.selector = selector;
|
||||
if (promiseState.cancelled) return;
|
||||
const ensureUnreadBadgeMask = _this => {
|
||||
if (_this.state.unreadBadgeMask) return;
|
||||
|
@ -540,8 +553,8 @@ var UnreadBadgesRedux = (() => {
|
|||
const i = (i, n) => ((i = i.split('.').map(i => parseInt(i))), (n = n.split('.').map(i => parseInt(i))), !!(n[0] > i[0]) || !!(n[0] == i[0] && n[1] > i[1]) || !!(n[0] == i[0] && n[1] == i[1] && n[2] > i[2])),
|
||||
n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e),
|
||||
e = BdApi.getPlugin('ZeresPluginLibrary'),
|
||||
author = BdApi.getPlugin('XenoLib');
|
||||
n(e, '1.2.10') && (ZeresPluginLibraryOutdated = !0), n(author, '1.3.11') && (XenoLibOutdated = !0);
|
||||
o = BdApi.getPlugin('XenoLib');
|
||||
n(e, '1.2.11') && (ZeresPluginLibraryOutdated = !0), n(o, '1.3.14') && (XenoLibOutdated = !0);
|
||||
}
|
||||
} catch (i) {
|
||||
console.error('Error checking if libraries are out of date', i);
|
||||
|
@ -549,6 +562,9 @@ var UnreadBadgesRedux = (() => {
|
|||
|
||||
return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated
|
||||
? class {
|
||||
constructor() {
|
||||
this._XL_PLUGIN = true;
|
||||
}
|
||||
getName() {
|
||||
return this.name.replace(/\s+/g, '');
|
||||
}
|
||||
|
@ -563,96 +579,80 @@ var UnreadBadgesRedux = (() => {
|
|||
}
|
||||
stop() {}
|
||||
load() {
|
||||
const a = !global.XenoLib,
|
||||
b = !global.ZeresPluginLibrary,
|
||||
c = (a && b) || ((a || b) && (XenoLibOutdated || ZeresPluginLibraryOutdated)) || XenoLibOutdated || ZeresPluginLibraryOutdated,
|
||||
d = (() => {
|
||||
let d = '';
|
||||
return a || b ? (d += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (d += `Outdated `), (d += `${c ? 'Libraries' : 'Library'} `), d;
|
||||
})(),
|
||||
const a = BdApi.findModuleByProps('isModalOpen');
|
||||
if (a && a.isModalOpen(`${this.name}_DEP_MODAL`)) return;
|
||||
const b = !global.XenoLib,
|
||||
c = !global.ZeresPluginLibrary,
|
||||
d = (b && c) || ((b || c) && (XenoLibOutdated || ZeresPluginLibraryOutdated)),
|
||||
e = (() => {
|
||||
let d = `The ${c ? 'libraries' : 'library'} `;
|
||||
return a || XenoLibOutdated ? ((d += 'XenoLib '), (b || ZeresPluginLibraryOutdated) && (d += 'and ZeresPluginLibrary ')) : (b || ZeresPluginLibraryOutdated) && (d += 'ZeresPluginLibrary '), (d += `required for ${this.name} ${c ? 'are' : 'is'} ${a || b ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (a || b ? ' and/or outdated' : 'outdated') : ''}.`), d;
|
||||
let a = '';
|
||||
return b || c ? (a += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (a += `Outdated `), (a += `${d ? 'Libraries' : 'Library'} `), a;
|
||||
})(),
|
||||
f = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'),
|
||||
g = BdApi.findModuleByProps('Sizes', 'Weights'),
|
||||
h = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
|
||||
i = () => BdApi.getCore().alert(d, `${e}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${b || ZeresPluginLibraryOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/rauenzi/BDPluginLibrary/blob/master/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>' : ''}${a || XenoLibOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/1XenoLib.plugin.js"target="_blank">Click here to download XenoLib</a>' : ''}`);
|
||||
if (!f || !h || !g) return i();
|
||||
let j;
|
||||
const k = (() => {
|
||||
if (!global.pluginModule || !global.BDEvents) return;
|
||||
if (a || XenoLibOutdated) {
|
||||
const a = () => {
|
||||
BDEvents.off('xenolib-loaded', a), f.popWithKey(j), pluginModule.reloadPlugin(this.name);
|
||||
};
|
||||
return BDEvents.on('xenolib-loaded', a), () => BDEvents.off('xenolib-loaded', a);
|
||||
}
|
||||
const b = a => {
|
||||
'ZeresPluginLibrary' !== a || (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b), f.popWithKey(j), pluginModule.reloadPlugin(this.name));
|
||||
};
|
||||
return BDEvents.on('plugin-loaded', b), BDEvents.on('plugin-reloaded', b), () => (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b));
|
||||
})();
|
||||
class l extends BdApi.React.PureComponent {
|
||||
f = (() => {
|
||||
let a = `The ${d ? 'libraries' : 'library'} `;
|
||||
return b || XenoLibOutdated ? ((a += 'XenoLib '), (c || ZeresPluginLibraryOutdated) && (a += 'and ZeresPluginLibrary ')) : (c || ZeresPluginLibraryOutdated) && (a += 'ZeresPluginLibrary '), (a += `required for ${this.name} ${d ? 'are' : 'is'} ${b || c ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (b || c ? ' and/or outdated' : 'outdated') : ''}.`), a;
|
||||
})(),
|
||||
g = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'),
|
||||
h = BdApi.findModuleByProps('Sizes', 'Weights'),
|
||||
i = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
|
||||
j = () => BdApi.getCore().alert(e, `${f}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${c || ZeresPluginLibraryOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/rauenzi/BDPluginLibrary/blob/master/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>' : ''}${b || XenoLibOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/1XenoLib.plugin.js"target="_blank">Click here to download XenoLib</a>' : ''}`);
|
||||
if (!g || !i || !h) return j();
|
||||
class k extends BdApi.React.PureComponent {
|
||||
constructor(a) {
|
||||
super(a), (this.state = { hasError: !1 });
|
||||
}
|
||||
componentDidCatch(a, b) {
|
||||
componentDidCatch(a) {
|
||||
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`), this.setState({ hasError: !0 }), 'function' == typeof this.props.onError && this.props.onError(a);
|
||||
}
|
||||
render() {
|
||||
return this.state.hasError ? null : this.props.children;
|
||||
}
|
||||
}
|
||||
j = f.push(a =>
|
||||
BdApi.React.createElement(
|
||||
l,
|
||||
{
|
||||
label: 'missing dependency modal',
|
||||
onError: () => {
|
||||
f.popWithKey(j), i();
|
||||
}
|
||||
},
|
||||
class l extends i {
|
||||
submitModal() {
|
||||
this.props.onConfirm();
|
||||
}
|
||||
}
|
||||
let m = !1;
|
||||
const n = g.push(
|
||||
a =>
|
||||
BdApi.React.createElement(
|
||||
h,
|
||||
Object.assign(
|
||||
{
|
||||
header: d,
|
||||
children: [BdApi.React.createElement(g, { color: g.Colors.PRIMARY, children: [`${e} Please click Download Now to download ${c ? 'them' : 'it'}.`] })],
|
||||
red: !1,
|
||||
confirmText: 'Download Now',
|
||||
cancelText: 'Cancel',
|
||||
onConfirm: () => {
|
||||
k();
|
||||
const a = require('request'),
|
||||
b = require('fs'),
|
||||
c = require('path'),
|
||||
d = a => {
|
||||
if (!global.BDEvents) return a();
|
||||
const b = c => {
|
||||
'ZeresPluginLibrary' !== c || (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b), a());
|
||||
k,
|
||||
{
|
||||
label: 'missing dependency modal',
|
||||
onError: () => {
|
||||
g.popWithKey(n), j();
|
||||
}
|
||||
},
|
||||
BdApi.React.createElement(
|
||||
l,
|
||||
Object.assign(
|
||||
{
|
||||
header: e,
|
||||
children: [BdApi.React.createElement(h, { color: h.Colors.PRIMARY, children: [`${f} Please click Download Now to download ${d ? 'them' : 'it'}.`] })],
|
||||
red: !1,
|
||||
confirmText: 'Download Now',
|
||||
cancelText: 'Cancel',
|
||||
onConfirm: () => {
|
||||
if (m) return;
|
||||
m = !0;
|
||||
const a = require('request'),
|
||||
b = require('fs'),
|
||||
c = require('path'),
|
||||
d = () => {
|
||||
(global.XenoLib && !XenoLibOutdated) || a('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (a, d, e) => (a ? j() : void b.writeFile(c.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), e, () => {})));
|
||||
};
|
||||
BDEvents.on('plugin-loaded', b), BDEvents.on('plugin-reloaded', b);
|
||||
},
|
||||
e = () => {
|
||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||
if ((global.XenoLib && !XenoLibOutdated) || !global.BDEvents) return pluginModule.reloadPlugin(this.name);
|
||||
const a = () => {
|
||||
BDEvents.off('xenolib-loaded', a), pluginModule.reloadPlugin(this.name);
|
||||
};
|
||||
BDEvents.on('xenolib-loaded', a);
|
||||
},
|
||||
f = () => (global.XenoLib && !XenoLibOutdated ? e() : void a('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (a, d, f) => (a ? i() : void (e(), b.writeFile(c.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), f, () => {})))));
|
||||
!global.ZeresPluginLibrary || ZeresPluginLibraryOutdated ? a('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (a, e, g) => (a ? i() : void (d(f), b.writeFile(c.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), g, () => {})))) : f();
|
||||
}
|
||||
},
|
||||
a
|
||||
!global.ZeresPluginLibrary || ZeresPluginLibraryOutdated ? a('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (a, e, f) => (a ? j() : void (b.writeFile(c.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), f, () => {}), d()))) : d();
|
||||
}
|
||||
},
|
||||
a
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
void 0,
|
||||
`${this.name}_DEP_MODAL`
|
||||
);
|
||||
}
|
||||
|
||||
start() {}
|
||||
get [Symbol.toStringTag]() {
|
||||
return 'Plugin';
|
||||
|
|
Loading…
Reference in New Issue