Update RemoveBlockedUsers.plugin.js
This commit is contained in:
parent
7f112bab32
commit
437153f83c
|
@ -2,7 +2,7 @@
|
|||
* @name RemoveBlockedUsers
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.5.2
|
||||
* @version 1.5.3
|
||||
* @description Removes blocked Messages/Users
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -83,37 +83,35 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
SearchResults: "render",
|
||||
Message: "default",
|
||||
ReactorsComponent: "render",
|
||||
PrivateChannelRecipients: "default",
|
||||
NowPlayingItem: "default",
|
||||
ChannelItem: "default",
|
||||
VoiceUsers: "render",
|
||||
PrivateChannel: "render",
|
||||
PrivateChannelCallParticipants: "render",
|
||||
ChannelCall: "render",
|
||||
UserSummaryItem: "render"
|
||||
},
|
||||
after: {
|
||||
ChannelPins: "default",
|
||||
RecentMentions: "default",
|
||||
Messages: "type",
|
||||
SearchResultsInner: "default",
|
||||
Reactions: "render",
|
||||
ActiveThread: "type",
|
||||
ConnectedChannelMembers: "default",
|
||||
MemberListItem: "render",
|
||||
NowPlayingItem: "default",
|
||||
VoiceUsers: "render",
|
||||
VoiceUser: "render",
|
||||
DirectMessage: "render",
|
||||
PrivateChannel: "render",
|
||||
UserMention: "default",
|
||||
RichUserMention: "UserMention"
|
||||
}
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"ChannelCall",
|
||||
"ChannelItem",
|
||||
"ChannelMembers",
|
||||
"PrivateChannel",
|
||||
"PrivateChannelRecipients",
|
||||
"Message",
|
||||
"Messages",
|
||||
"NowPlayingItem",
|
||||
"ReactorsComponent",
|
||||
"SearchResults",
|
||||
"UserSummaryItem",
|
||||
"VoiceUsers"
|
||||
],
|
||||
after: [
|
||||
"ActiveThread",
|
||||
"ChannelPins",
|
||||
"DirectMessage",
|
||||
"MemberListItem",
|
||||
"NowPlayingItem",
|
||||
"PrivateChannel",
|
||||
"Reactions",
|
||||
"RecentMentions",
|
||||
"RichUserMention",
|
||||
"SearchResultsInner",
|
||||
"VoiceUser",
|
||||
"VoiceUsers"
|
||||
]
|
||||
};
|
||||
|
||||
this.patchPriority = 8;
|
||||
|
@ -251,10 +249,9 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processMessages (e) {
|
||||
if (this.settings.places.messages) {
|
||||
let messagesIns = e.returnvalue.props.children;
|
||||
if (BDFDB.ArrayUtils.is(messagesIns.props.channelStream)) {
|
||||
let oldStream = messagesIns.props.channelStream.filter(n => n.type != "MESSAGE_GROUP_BLOCKED"), newStream = [];
|
||||
if (!this.settings.places.messages) return;
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.channelStream)) {
|
||||
let oldStream = e.instance.props.channelStream.filter(n => n.type != "MESSAGE_GROUP_BLOCKED"), newStream = [];
|
||||
for (let i in oldStream) {
|
||||
let next = parseInt(i)+1;
|
||||
if (oldStream[i].type != "DIVIDER" || (oldStream[next] && oldStream[i].type == "DIVIDER" && oldStream[next].type != "DIVIDER" && oldStream.slice(next).some(nextStream => nextStream.type != "DIVIDER"))) newStream.push(oldStream[i]);
|
||||
|
@ -268,20 +265,19 @@ module.exports = (_ => {
|
|||
else author = null;;
|
||||
groupId = newStream[i].groupId;
|
||||
}
|
||||
messagesIns.props.channelStream = newStream;
|
||||
}
|
||||
if (BDFDB.ObjectUtils.is(messagesIns.props.messages) && BDFDB.ArrayUtils.is(messagesIns.props.messages._array)) {
|
||||
let messages = messagesIns.props.messages;
|
||||
messagesIns.props.messages = new BDFDB.DiscordObjects.Messages(messages);
|
||||
for (let key in messages) messagesIns.props.messages[key] = messages[key];
|
||||
messagesIns.props.messages._array = [].concat(messagesIns.props.messages._array.filter(n => !n.author || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id)));
|
||||
if (messagesIns.props.oldestUnreadMessageId && messagesIns.props.messages._array.every(n => n.id != messagesIns.props.oldestUnreadMessageId)) messagesIns.props.oldestUnreadMessageId = null;
|
||||
e.instance.props.channelStream = newStream;
|
||||
}
|
||||
if (BDFDB.ObjectUtils.is(e.instance.props.messages) && BDFDB.ArrayUtils.is(e.instance.props.messages._array)) {
|
||||
let messages = e.instance.props.messages;
|
||||
e.instance.props.messages = new BDFDB.DiscordObjects.Messages(messages);
|
||||
for (let key in messages) e.instance.props.messages[key] = messages[key];
|
||||
e.instance.props.messages._array = [].concat(e.instance.props.messages._array.filter(n => !n.author || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id)));
|
||||
if (e.instance.props.oldestUnreadMessageId && e.instance.props.messages._array.every(n => n.id != e.instance.props.oldestUnreadMessageId)) e.instance.props.oldestUnreadMessageId = null;
|
||||
}
|
||||
}
|
||||
|
||||
processMessage (e) {
|
||||
if (this.settings.places.replies) {
|
||||
if (!this.settings.places.replies) return;
|
||||
let repliedMessage = e.instance.props.childrenRepliedMessage;
|
||||
if (repliedMessage && repliedMessage.props && repliedMessage.props.children && repliedMessage.props.children.props && repliedMessage.props.children.props.referencedMessage && repliedMessage.props.children.props.referencedMessage.message && repliedMessage.props.children.props.referencedMessage.message.author && BDFDB.LibraryStores.RelationshipStore.isBlocked(repliedMessage.props.children.props.referencedMessage.message.author.id)) {
|
||||
delete e.instance.props.childrenRepliedMessage;
|
||||
|
@ -294,18 +290,16 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processSearchResults (e) {
|
||||
if (this.settings.places.messages && e.instance.props.blockCount && e.instance.props.search && e.instance.props.search.totalResults <= BDFDB.DiscordConstants.SEARCH_PAGE_SIZE) e.instance.props.search = Object.assign({}, e.instance.props.search, {totalResults: e.instance.props.search.totalResults - e.instance.props.blockCount});
|
||||
}
|
||||
|
||||
processSearchResultsInner (e) {
|
||||
if (this.settings.places.messages && e.instance.props.search) {
|
||||
if (!this.settings.places.messages || !e.instance.props.search) return;
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.searchresultsblocked]]});
|
||||
if (index > -1) children.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
processChannelPins (e) {
|
||||
if (this.settings.places.pins && e.returnvalue.props && e.returnvalue.props.children && e.returnvalue.props.children.props && BDFDB.ArrayUtils.is(e.returnvalue.props.children.props.messages)) e.returnvalue.props.children.props.messages = e.returnvalue.props.children.props.messages.filter(n => !n || !n.author || !n.author.id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.author.id));
|
||||
|
@ -316,7 +310,8 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processReactions (e) {
|
||||
if (this.settings.places.reactions && e.returnvalue && e.returnvalue.props.children && BDFDB.ArrayUtils.is(e.returnvalue.props.children[0])) {
|
||||
if (!this.settings.places.reactions) return;
|
||||
if (e.returnvalue && e.returnvalue.props.children && BDFDB.ArrayUtils.is(e.returnvalue.props.children[0])) {
|
||||
let updateTimeout, relationshipCount = BDFDB.LibraryStores.RelationshipStore.getRelationshipCount();
|
||||
if (cachedChannelId != e.instance.props.message.channel_id) {
|
||||
cachedReactions = {};
|
||||
|
@ -372,14 +367,12 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
|
||||
processConnectedChannelMembers (e) {
|
||||
processChannelMembers (e) {
|
||||
if (!this.settings.places.memberList) return;
|
||||
let channelMembers = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ChannelMembers"});
|
||||
if (!channelMembers) return;
|
||||
let hiddenRows = false, newRows = new Array(channelMembers.props.rows.length), newGroups = new Array(channelMembers.props.groups.length);
|
||||
for (let i in channelMembers.props.groups) newGroups[i] = Object.assign({}, channelMembers.props.groups[i]);
|
||||
for (let i in channelMembers.props.rows) {
|
||||
let row = channelMembers.props.rows[i];
|
||||
let hiddenRows = false, newRows = new Array(e.instance.props.rows.length), newGroups = new Array(e.instance.props.groups.length);
|
||||
for (let i in e.instance.props.groups) newGroups[i] = Object.assign({}, e.instance.props.groups[i]);
|
||||
for (let i in e.instance.props.rows) {
|
||||
let row = e.instance.props.rows[i];
|
||||
if (!row || row.type != "MEMBER") newRows[i] = row;
|
||||
else if (!row.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(row.user.id)) newRows[i] = row;
|
||||
else {
|
||||
|
@ -413,8 +406,8 @@ module.exports = (_ => {
|
|||
}
|
||||
return [].concat(array.filter(filter), new Array(suffixLength))
|
||||
};
|
||||
channelMembers.props.rows = removeEmptyWithin(newRows, n => n);
|
||||
channelMembers.props.groups = removeEmptyWithin(newGroups, g => g && g.count > 0);
|
||||
e.instance.props.rows = removeEmptyWithin(newRows, n => n);
|
||||
e.instance.props.groups = removeEmptyWithin(newGroups, g => g && g.count > 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,7 +420,7 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processNowPlayingItem (e) {
|
||||
if (this.settings.places.activity) {
|
||||
if (!this.settings.places.activity) return;
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {name: "NowPlayingHeader"});
|
||||
if (index > -1) for (let child of children) if (child && child.props && child.props.party) {
|
||||
if (!e.returnvalue) {
|
||||
|
@ -446,10 +439,9 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processChannelItem (e) {
|
||||
if (this.settings.places.voiceList) {
|
||||
if (!this.settings.places.voiceList) return;
|
||||
let channelInfo = BDFDB.ReactUtils.findChild(e.instance.props.children, {props: [["className", BDFDB.disCN.channelinfo]]});
|
||||
if (channelInfo && channelInfo.props && channelInfo.props.children && channelInfo.props.children.props && BDFDB.ArrayUtils.is(channelInfo.props.children.props.voiceStates)) {
|
||||
let newVoiceStates = [].concat(channelInfo.props.children.props.voiceStates).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
|
@ -457,10 +449,13 @@ module.exports = (_ => {
|
|||
channelInfo.props.children.props.voiceStates = newVoiceStates;
|
||||
}
|
||||
}
|
||||
|
||||
processVoiceUser (e) {
|
||||
if (this.settings.places.voiceList && e.instance.props.user && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.user.id)) return null;
|
||||
}
|
||||
|
||||
processVoiceUsers (e) {
|
||||
if (this.settings.places.voiceList && BDFDB.ArrayUtils.is(e.instance.props.voiceStates)) {
|
||||
if (!this.settings.places.voiceList || !BDFDB.ArrayUtils.is(e.instance.props.voiceStates)) return;
|
||||
if (!e.returnvalue) {
|
||||
if (e.instance.props.children && e.instance.props.children.props && e.instance.props.children.props.numAudience) e.instance.props.children.props.numAudience = BDFDB.LibraryStores.StageChannelParticipantStore.getMutableParticipants(e.instance.props.channel.id).length;
|
||||
e.instance.props.voiceStates = [].concat(e.instance.props.voiceStates).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
|
@ -469,14 +464,9 @@ module.exports = (_ => {
|
|||
if (e.instance.props.children && e.instance.props.children.props && e.instance.props.children.props.numAudience === 0) return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processVoiceUser (e) {
|
||||
if (this.settings.places.voiceList && e.instance.props.user && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.user.id)) return null;
|
||||
}
|
||||
|
||||
processDirectMessage (e) {
|
||||
if (this.settings.places.recentDms && e.instance.props.channel) {
|
||||
if (!this.settings.places.recentDms || !e.instance.props.channel) return;
|
||||
if (e.instance.props.channel.isGroupDM()) {
|
||||
if (!e.instance.props.channel.name) {
|
||||
let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"});
|
||||
|
@ -487,10 +477,9 @@ module.exports = (_ => {
|
|||
if (BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.channel.getRecipientId())) e.returnvalue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processPrivateChannel (e) {
|
||||
if (this.settings.places.channelList && e.instance.props.channel) {
|
||||
if (!this.settings.places.channelList || !e.instance.props.channel) return;
|
||||
if (e.instance.props.channel.isGroupDM()) {
|
||||
if (!e.returnvalue) {
|
||||
e.instance.props.channel = new BDFDB.DiscordObjects.Channel(Object.assign({}, e.instance.props.channel, {rawRecipients: e.instance.props.channel.rawRecipients.filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id)), recipients: e.instance.props.channel.recipients.filter(id => !id || !BDFDB.LibraryStores.RelationshipStore.isBlocked(id))}));
|
||||
|
@ -514,26 +503,18 @@ module.exports = (_ => {
|
|||
if (e.returnvalue && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.channel.getRecipientId())) e.returnvalue = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processPrivateChannelCallParticipants (e) {
|
||||
if (this.settings.places.voiceChat) {
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.participants)) e.instance.props.participants = [].concat(e.instance.props.participants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.filteredParticipants)) e.instance.props.filteredParticipants = [].concat(e.instance.props.filteredParticipants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
}
|
||||
}
|
||||
|
||||
processChannelCall (e) {
|
||||
if (this.settings.places.voiceChat) {
|
||||
if (!this.settings.places.voiceChat) return;
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.participants)) e.instance.props.participants = [].concat(e.instance.props.participants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.filteredParticipants)) e.instance.props.filteredParticipants = [].concat(e.instance.props.filteredParticipants).filter(n => !n.user || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
|
||||
}
|
||||
}
|
||||
|
||||
processUserSummaryItem (e) {
|
||||
if (this.settings.places.memberList && BDFDB.ArrayUtils.is(e.instance.props.users)) e.instance.props.users = [].concat(e.instance.props.users).filter(n => !n || !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.id));
|
||||
}
|
||||
|
||||
// TODO FIX IN react FUNCTION BDFDB.ModuleUtils.findByString(".inlinePreview", "renderPopout", "mention", {all: true})
|
||||
processUserMention (e) {
|
||||
if (e.instance.props.userId && this.settings.places.mentions && BDFDB.LibraryStores.RelationshipStore.isBlocked(e.instance.props.userId)) return BDFDB.ReactUtils.createElement("span", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.mention, BDFDB.disCN.mentionwrapper, e.instance.props.className),
|
||||
|
|
Loading…
Reference in New Issue