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
|
# [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
|
### 1.0.2
|
||||||
- Heavily optimized the plugin, expect better performance if you have lots of servers
|
- 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
|
/*@cc_on
|
||||||
@if (@_jscript)
|
@if (@_jscript)
|
||||||
|
|
||||||
|
@ -41,16 +41,16 @@ var UnreadBadgesRedux = (() => {
|
||||||
twitter_username: ''
|
twitter_username: ''
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
version: '1.0.2',
|
version: '1.0.3',
|
||||||
description: 'Adds a number badge to server icons and channels.',
|
description: 'Adds a number badge to server icons and channels.',
|
||||||
github: 'https://github.com/1Lighty',
|
github: 'https://github.com/1Lighty',
|
||||||
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/UnreadBadgesRedux/UnreadBadgesRedux.plugin.js'
|
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/UnreadBadgesRedux/UnreadBadgesRedux.plugin.js'
|
||||||
},
|
},
|
||||||
changelog: [
|
changelog: [
|
||||||
{
|
{
|
||||||
title: 'wohoo!',
|
title: 'darn',
|
||||||
type: 'fixed',
|
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: [
|
defaultConfig: [
|
||||||
|
@ -235,6 +235,9 @@ var UnreadBadgesRedux = (() => {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
XenoLib.changeName(__filename, 'UnreadBadgesRedux');
|
XenoLib.changeName(__filename, 'UnreadBadgesRedux');
|
||||||
|
try {
|
||||||
|
ModalStack.popWithKey(`${this.name}_DEP_MODAL`);
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
onStart() {
|
onStart() {
|
||||||
this.promises = { state: { cancelled: false } };
|
this.promises = { state: { cancelled: false } };
|
||||||
|
@ -299,7 +302,9 @@ var UnreadBadgesRedux = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchChannelItem(promiseState) {
|
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;
|
if (promiseState.cancelled) return;
|
||||||
const settings = this.settings;
|
const settings = this.settings;
|
||||||
const MentionsBadgeClassname = XenoLib.getClass('iconVisibility mentionsBadge');
|
const MentionsBadgeClassname = XenoLib.getClass('iconVisibility mentionsBadge');
|
||||||
|
@ -345,7 +350,9 @@ var UnreadBadgesRedux = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchGuildFolder(promiseState) {
|
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;
|
if (promiseState.cancelled) return;
|
||||||
const settings = this.settings;
|
const settings = this.settings;
|
||||||
function BlobMaskWrapper(e) {
|
function BlobMaskWrapper(e) {
|
||||||
|
@ -375,7 +382,9 @@ var UnreadBadgesRedux = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchConnectedGuild(promiseState) {
|
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;
|
if (promiseState.cancelled) return;
|
||||||
const settings = this.settings;
|
const settings = this.settings;
|
||||||
function PatchedConnectedGuild(e) {
|
function PatchedConnectedGuild(e) {
|
||||||
|
@ -398,7 +407,9 @@ var UnreadBadgesRedux = (() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
async patchGuildIcon(promiseState) {
|
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;
|
if (promiseState.cancelled) return;
|
||||||
Patcher.after(Guild.component.prototype, 'render', (_this, _, ret) => {
|
Patcher.after(Guild.component.prototype, 'render', (_this, _, ret) => {
|
||||||
const mask = Utilities.findInTree(ret, e => e && e.type && e.type.displayName === 'BlobMask', { walkable: ['props', 'children'] });
|
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) {
|
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;
|
if (promiseState.cancelled) return;
|
||||||
const ensureUnreadBadgeMask = _this => {
|
const ensureUnreadBadgeMask = _this => {
|
||||||
if (_this.state.unreadBadgeMask) return;
|
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])),
|
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),
|
n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e),
|
||||||
e = BdApi.getPlugin('ZeresPluginLibrary'),
|
e = BdApi.getPlugin('ZeresPluginLibrary'),
|
||||||
author = BdApi.getPlugin('XenoLib');
|
o = BdApi.getPlugin('XenoLib');
|
||||||
n(e, '1.2.10') && (ZeresPluginLibraryOutdated = !0), n(author, '1.3.11') && (XenoLibOutdated = !0);
|
n(e, '1.2.11') && (ZeresPluginLibraryOutdated = !0), n(o, '1.3.14') && (XenoLibOutdated = !0);
|
||||||
}
|
}
|
||||||
} catch (i) {
|
} catch (i) {
|
||||||
console.error('Error checking if libraries are out of date', 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
|
return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated
|
||||||
? class {
|
? class {
|
||||||
|
constructor() {
|
||||||
|
this._XL_PLUGIN = true;
|
||||||
|
}
|
||||||
getName() {
|
getName() {
|
||||||
return this.name.replace(/\s+/g, '');
|
return this.name.replace(/\s+/g, '');
|
||||||
}
|
}
|
||||||
|
@ -563,96 +579,80 @@ var UnreadBadgesRedux = (() => {
|
||||||
}
|
}
|
||||||
stop() {}
|
stop() {}
|
||||||
load() {
|
load() {
|
||||||
const a = !global.XenoLib,
|
const a = BdApi.findModuleByProps('isModalOpen');
|
||||||
b = !global.ZeresPluginLibrary,
|
if (a && a.isModalOpen(`${this.name}_DEP_MODAL`)) return;
|
||||||
c = (a && b) || ((a || b) && (XenoLibOutdated || ZeresPluginLibraryOutdated)) || XenoLibOutdated || ZeresPluginLibraryOutdated,
|
const b = !global.XenoLib,
|
||||||
d = (() => {
|
c = !global.ZeresPluginLibrary,
|
||||||
let d = '';
|
d = (b && c) || ((b || c) && (XenoLibOutdated || ZeresPluginLibraryOutdated)),
|
||||||
return a || b ? (d += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (d += `Outdated `), (d += `${c ? 'Libraries' : 'Library'} `), d;
|
|
||||||
})(),
|
|
||||||
e = (() => {
|
e = (() => {
|
||||||
let d = `The ${c ? 'libraries' : 'library'} `;
|
let a = '';
|
||||||
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;
|
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'),
|
f = (() => {
|
||||||
g = BdApi.findModuleByProps('Sizes', 'Weights'),
|
let a = `The ${d ? 'libraries' : 'library'} `;
|
||||||
h = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
|
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;
|
||||||
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();
|
g = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'),
|
||||||
let j;
|
h = BdApi.findModuleByProps('Sizes', 'Weights'),
|
||||||
const k = (() => {
|
i = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
|
||||||
if (!global.pluginModule || !global.BDEvents) return;
|
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 (a || XenoLibOutdated) {
|
if (!g || !i || !h) return j();
|
||||||
const a = () => {
|
class k extends BdApi.React.PureComponent {
|
||||||
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 {
|
|
||||||
constructor(a) {
|
constructor(a) {
|
||||||
super(a), (this.state = { hasError: !1 });
|
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);
|
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() {
|
render() {
|
||||||
return this.state.hasError ? null : this.props.children;
|
return this.state.hasError ? null : this.props.children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
j = f.push(a =>
|
class l extends i {
|
||||||
|
submitModal() {
|
||||||
|
this.props.onConfirm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let m = !1;
|
||||||
|
const n = g.push(
|
||||||
|
a =>
|
||||||
BdApi.React.createElement(
|
BdApi.React.createElement(
|
||||||
l,
|
k,
|
||||||
{
|
{
|
||||||
label: 'missing dependency modal',
|
label: 'missing dependency modal',
|
||||||
onError: () => {
|
onError: () => {
|
||||||
f.popWithKey(j), i();
|
g.popWithKey(n), j();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
BdApi.React.createElement(
|
BdApi.React.createElement(
|
||||||
h,
|
l,
|
||||||
Object.assign(
|
Object.assign(
|
||||||
{
|
{
|
||||||
header: d,
|
header: e,
|
||||||
children: [BdApi.React.createElement(g, { color: g.Colors.PRIMARY, children: [`${e} Please click Download Now to download ${c ? 'them' : 'it'}.`] })],
|
children: [BdApi.React.createElement(h, { color: h.Colors.PRIMARY, children: [`${f} Please click Download Now to download ${d ? 'them' : 'it'}.`] })],
|
||||||
red: !1,
|
red: !1,
|
||||||
confirmText: 'Download Now',
|
confirmText: 'Download Now',
|
||||||
cancelText: 'Cancel',
|
cancelText: 'Cancel',
|
||||||
onConfirm: () => {
|
onConfirm: () => {
|
||||||
k();
|
if (m) return;
|
||||||
|
m = !0;
|
||||||
const a = require('request'),
|
const a = require('request'),
|
||||||
b = require('fs'),
|
b = require('fs'),
|
||||||
c = require('path'),
|
c = require('path'),
|
||||||
d = a => {
|
d = () => {
|
||||||
if (!global.BDEvents) return a();
|
(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, () => {})));
|
||||||
const b = c => {
|
|
||||||
'ZeresPluginLibrary' !== c || (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b), a());
|
|
||||||
};
|
};
|
||||||
BDEvents.on('plugin-loaded', b), BDEvents.on('plugin-reloaded', b);
|
!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();
|
||||||
},
|
|
||||||
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
|
a
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
void 0,
|
||||||
|
`${this.name}_DEP_MODAL`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {}
|
start() {}
|
||||||
get [Symbol.toStringTag]() {
|
get [Symbol.toStringTag]() {
|
||||||
return 'Plugin';
|
return 'Plugin';
|
||||||
|
|
Loading…
Reference in New Issue