This commit is contained in:
Mirco Wittrien 2021-06-09 17:52:32 +02:00
parent 52b211691c
commit 97d40e991a
3 changed files with 79 additions and 48 deletions

View File

@ -2,7 +2,7 @@
* @name EditChannels * @name EditChannels
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 4.2.8 * @version 4.2.9
* @description Allows you to locally edit Channels * @description Allows you to locally edit Channels
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,12 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "EditChannels", "name": "EditChannels",
"author": "DevilBro", "author": "DevilBro",
"version": "4.2.8", "version": "4.2.9",
"description": "Allows you to locally edit Channels" "description": "Allows you to locally edit Channels"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"New Mention Style": "" "Group DMs": "Fixed some stuff in Group DMs"
} }
} }
}; };
@ -118,6 +118,8 @@ module.exports = (_ => {
} }
}; };
this.patchPriority = 9;
this.css = ` this.css = `
${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"], ${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"],
${BDFDB.dotCN.recentmentionschannelname}:hover > span[style*="color"], ${BDFDB.dotCN.recentmentionschannelname}:hover > span[style*="color"],
@ -127,21 +129,7 @@ module.exports = (_ => {
`; `;
} }
onStart () { onStart () {
// REMOVE 16.05.2021
let oldData = BDFDB.DataUtils.load(this);
if (oldData.settings) {
this.settings.general = BDFDB.ObjectUtils.filter(oldData.settings, k => k.indexOf("changeIn") == -1, true);
this.settings.places = Object.entries(BDFDB.ObjectUtils.filter(oldData.settings, k => k.indexOf("changeIn") == 0, true)).reduce((n, p) => {
let k = p[0].replace("changeIn", "");
n[k[0].toLowerCase() + k.slice(1)] = p[1];
return n;
}, {});
BDFDB.DataUtils.save(this.settings.general, this, "general");
BDFDB.DataUtils.save(this.settings.places, this, "places");
BDFDB.DataUtils.remove(this, "settings");
}
let observer = new MutationObserver(_ => {this.changeAppTitle();}); let observer = new MutationObserver(_ => {this.changeAppTitle();});
BDFDB.ObserverUtils.connect(this, document.head.querySelector("title"), {name: "appTitleObserver", instance: observer}, {childList: true}); BDFDB.ObserverUtils.connect(this, document.head.querySelector("title"), {name: "appTitleObserver", instance: observer}, {childList: true});
@ -274,9 +262,8 @@ module.exports = (_ => {
} }
processChannelEditorContainer (e) { processChannelEditorContainer (e) {
if (!e.instance.props.disabled && e.instance.props.channel && BDFDB.ChannelUtils.isTextChannel(e.instance.props.channel) && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL && this.settings.places.chatTextarea) { if (!e.instance.props.disabled && e.instance.props.channel && (BDFDB.ChannelUtils.isTextChannel(e.instance.props.channel) || e.instance.props.channel.isGroupDM()) && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL && this.settings.places.chatTextarea) {
let data = changedChannels[e.instance.props.channel.id]; if (changedChannels[e.instance.props.channel.id] && changedChannels[e.instance.props.channel.id].name) e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${changedChannels[e.instance.props.channel.id].name}`);
e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${data && data.name || e.instance.props.channel.name}`);
} }
} }
@ -324,7 +311,7 @@ module.exports = (_ => {
let channelName = BDFDB.ReactUtils.findChild(e.instance, {name: ["Title", "ChannelName"]}); let channelName = BDFDB.ReactUtils.findChild(e.instance, {name: ["Title", "ChannelName"]});
if (channelName) { if (channelName) {
if (channelName.props.children) { if (channelName.props.children) {
channelName.props.children = channel.isGroupDM() ? this.getGroupName(channel.id) : this.getChannelData(channel.id).name; if (changedChannels[channel.id] && changedChannels[channel.id].name) channelName.props.children = channel.isGroupDM() ? this.getGroupName(channel.id) : this.getChannelData(channel.id).name;
this.changeChannelColor(channelName, channel.id); this.changeChannelColor(channelName, channel.id);
} }
if (channelName.props.channel) channelName.props.channel = this.getChannelData(channel.id); if (channelName.props.channel) channelName.props.channel = this.getChannelData(channel.id);
@ -419,8 +406,10 @@ module.exports = (_ => {
processDirectMessage (e) { processDirectMessage (e) {
if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.recentDms) { if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.recentDms) {
let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"}); if (changedChannels[e.instance.props.channel.id] && changedChannels[e.instance.props.channel.id].name) {
if (tooltip) tooltip.props.text = this.getGroupName(e.instance.props.channel.id); let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"});
if (tooltip) tooltip.props.text = this.getGroupName(e.instance.props.channel.id);
}
let avatar = BDFDB.ReactUtils.findChild(e.returnvalue, {filter: c => c && c.props && !isNaN(parseInt(c.props.id))}); let avatar = BDFDB.ReactUtils.findChild(e.returnvalue, {filter: c => c && c.props && !isNaN(parseInt(c.props.id))});
if (avatar && typeof avatar.props.children == "function") { if (avatar && typeof avatar.props.children == "function") {
let childrenRender = avatar.props.children; let childrenRender = avatar.props.children;
@ -435,7 +424,9 @@ module.exports = (_ => {
processPrivateChannel (e) { processPrivateChannel (e) {
if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.channelList) { if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.channelList) {
e.returnvalue.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)}); if (changedChannels[e.instance.props.channel.id] && changedChannels[e.instance.props.channel.id].name) {
e.returnvalue.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)});
}
this.changeChannelColor(e.returnvalue.props.name, e.instance.props.channel.id, {modify: BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "hovered", "selected", "hasUnreadMessages", "muted")}); this.changeChannelColor(e.returnvalue.props.name, e.instance.props.channel.id, {modify: BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "hovered", "selected", "hasUnreadMessages", "muted")});
e.returnvalue.props.name = [e.returnvalue.props.name]; e.returnvalue.props.name = [e.returnvalue.props.name];
e.returnvalue.props.avatar.props.src = this.getGroupIcon(e.instance.props.channel.id); e.returnvalue.props.avatar.props.src = this.getGroupIcon(e.instance.props.channel.id);
@ -583,11 +574,13 @@ module.exports = (_ => {
} }
changeAppTitle () { changeAppTitle () {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); if (this.settings.places.appTitle) {
let title = document.head.querySelector("title"); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
if (title) { let title = document.head.querySelector("title");
if (BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "#" + this.getChannelData(channel.id, this.settings.places.appTitle).name); if (title && changedChannels[channel.id] && changedChannels[channel.id].name) {
else if (channel && channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id, this.settings.places.appTitle)); if (BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "#" + this.getChannelData(channel.id).name);
else if (channel && channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id));
}
} }
} }
@ -655,8 +648,8 @@ module.exports = (_ => {
return new BDFDB.DiscordObjects.Channel(channel); return new BDFDB.DiscordObjects.Channel(channel);
} }
getGroupName (channelId, change = true) { getGroupName (channelId) {
let channel = this.getChannelData(channelId, change); let channel = this.getChannelData(channelId);
if (channel.name) return channel.name; if (channel.name) return channel.name;
let recipients = channel.recipients.map(BDFDB.LibraryModules.UserStore.getUser).filter(n => n); let recipients = channel.recipients.map(BDFDB.LibraryModules.UserStore.getUser).filter(n => n);
return recipients.length > 0 ? recipients.map(u => u.toString()).join(", ") : BDFDB.LanguageUtils.LanguageStrings.UNNAMED; return recipients.length > 0 ? recipients.map(u => u.toString()).join(", ") : BDFDB.LanguageUtils.LanguageStrings.UNNAMED;

View File

@ -2,7 +2,7 @@
* @name NotificationSounds * @name NotificationSounds
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 3.6.0 * @version 3.6.1
* @description Allows you to replace the native Sounds with custom Sounds * @description Allows you to replace the native Sounds with custom Sounds
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,8 +17,13 @@ module.exports = (_ => {
"info": { "info": {
"name": "NotificationSounds", "name": "NotificationSounds",
"author": "DevilBro", "author": "DevilBro",
"version": "3.6.0", "version": "3.6.1",
"description": "Allows you to replace the native Sounds with custom Sounds" "description": "Allows you to replace the native Sounds with custom Sounds"
},
"changeLog": {
"added": {
"Replies": "Same as @here/@everyone/role mentions a new sub type for replies was added, this allows you to set a custom sound for only replies or mute reply pings"
}
} }
}; };
@ -68,11 +73,14 @@ module.exports = (_ => {
var currentDevice = defaultDevice, createdAudios = {}, repatchIncoming; var currentDevice = defaultDevice, createdAudios = {}, repatchIncoming;
const message1Types = ["dm", "mentioned", "reply", "role", "everyone", "here"];
/* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SOUNDS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */ /* NEVER CHANGE THE SRC LINKS IN THE PLUGIN FILE, TO ADD NEW SOUNDS ADD THEM IN THE SETTINGS GUI IN THE PLUGINS PAGE */
const types = { const types = {
"message1": {implemented: true, name: "New Chat Message", src: "/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute: true, focus: null, include: true}, "message1": {implemented: true, name: "New Chat Message", src: "/assets/dd920c06a01e5bb8b09678581e29d56f.mp3", mute: true, focus: null, include: true},
"dm": {implemented: true, name: "Direct Message", src: "/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute: true, focus: true, include: false}, "dm": {implemented: true, name: "Direct Message", src: "/assets/84c9fa3d07da865278bd77c97d952db4.mp3", mute: true, focus: true, include: false},
"mentioned": {implemented: true, name: "Mentioned", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false}, "mentioned": {implemented: true, name: "Mentioned", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false},
"reply": {implemented: true, name: "Mentioned (reply)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false},
"role": {implemented: true, name: "Mentioned (role)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false}, "role": {implemented: true, name: "Mentioned (role)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false},
"everyone": {implemented: true, name: "Mentioned (@everyone)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false}, "everyone": {implemented: true, name: "Mentioned (@everyone)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false},
"here": {implemented: true, name: "Mentioned (@here)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false}, "here": {implemented: true, name: "Mentioned (@here)", src: "/assets/a5f42064e8120e381528b14fd3188b72.mp3", mute: true, focus: true, include: false},
@ -234,8 +242,8 @@ module.exports = (_ => {
} }
else if (BDFDB.LibraryModules.MentionUtils.isRawMessageMentioned(message, BDFDB.UserUtils.me.id)) { else if (BDFDB.LibraryModules.MentionUtils.isRawMessageMentioned(message, BDFDB.UserUtils.me.id)) {
if (message.mentions.length && !this.isSuppressMentionEnabled(guildId, message.channel_id) && !(choices.mentioned.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) for (let mention of message.mentions) if (mention.id == BDFDB.UserUtils.me.id) { if (message.mentions.length && !this.isSuppressMentionEnabled(guildId, message.channel_id) && !(choices.mentioned.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) for (let mention of message.mentions) if (mention.id == BDFDB.UserUtils.me.id) {
this.fireEvent("mentioned"); this.fireEvent(message.message_reference ? "reply" : "mentioned");
this.playAudio("mentioned"); this.playAudio(message.message_reference ? "reply" : "mentioned");
return; return;
} }
if (guildId && message.mention_roles.length && !BDFDB.LibraryModules.MutedUtils.isSuppressRolesEnabled(guildId, message.channel_id) && !(choices.role.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) { if (guildId && message.mention_roles.length && !BDFDB.LibraryModules.MutedUtils.isSuppressRolesEnabled(guildId, message.channel_id) && !(choices.role.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) {
@ -270,12 +278,13 @@ module.exports = (_ => {
e.stopOriginalMethodCall(); e.stopOriginalMethodCall();
BDFDB.TimeUtils.timeout(_ => { BDFDB.TimeUtils.timeout(_ => {
if (type == "message1") { if (type == "message1") {
if (firedEvents["dm"]) firedEvents["dm"] = false; let called = false;
else if (firedEvents["mentioned"]) firedEvents["mentioned"] = false; for (let subType of message1Types) if (firedEvents[subType]) {
else if (firedEvents["role"]) firedEvents["role"] = false; delete firedEvents[subType];
else if (firedEvents["everyone"]) firedEvents["everyone"] = false; called = true;
else if (firedEvents["here"]) firedEvents["here"] = false; break;
else this.playAudio(type); }
if (!called) this.playAudio(type);
} }
else this.playAudio(type); else this.playAudio(type);
}); });
@ -686,7 +695,7 @@ module.exports = (_ => {
fireEvent (type) { fireEvent (type) {
firedEvents[type] = true; firedEvents[type] = true;
BDFDB.TimeUtils.timeout(_ => {firedEvents[type] = false;},3000); BDFDB.TimeUtils.timeout(_ => delete firedEvents[type], 3000);
} }
}; };
})(window.BDFDB_Global.PluginUtils.buildPlugin(config)); })(window.BDFDB_Global.PluginUtils.buildPlugin(config));

View File

@ -2,7 +2,7 @@
* @name RemoveBlockedMessages * @name RemoveBlockedMessages
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.2.6 * @version 1.2.7
* @description Removes blocked Messages/Users * @description Removes blocked Messages/Users
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,12 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "RemoveBlockedMessages", "name": "RemoveBlockedMessages",
"author": "DevilBro", "author": "DevilBro",
"version": "1.2.6", "version": "1.2.7",
"description": "Removes blocked Messages/Users" "description": "Removes blocked Messages/Users"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"New Messages Bar": "No longer shows on newly added blocked Messages" "Group DMs": "Fixed some stuff in Group DMs"
} }
} }
}; };
@ -84,7 +84,9 @@ module.exports = (_ => {
autocompletes: {value: true, description: "Autocomplete Entries"}, autocompletes: {value: true, description: "Autocomplete Entries"},
memberList: {value: true, description: "Members in List"}, memberList: {value: true, description: "Members in List"},
voiceList: {value: true, description: "Members in Voice List"}, voiceList: {value: true, description: "Members in Voice List"},
voiceChat: {value: true, description: "Members in Voice Chat"} voiceChat: {value: true, description: "Members in Voice Chat"},
channelList: {value: true, description: "Channel/Group List"},
recentDms: {value: true, description: "Group Notifications"}
} }
}; };
@ -107,6 +109,8 @@ module.exports = (_ => {
Reactions: "render", Reactions: "render",
MemberListItem: "render", MemberListItem: "render",
VoiceUser: "render", VoiceUser: "render",
DirectMessage: "render",
PrivateChannel: "render",
UserMention: "default", UserMention: "default",
RichUserMention: "UserMention" RichUserMention: "UserMention"
} }
@ -116,6 +120,10 @@ module.exports = (_ => {
} }
onStart () { onStart () {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.ChannelStore, "getChannel", {after: e => {
if (e.returnValue && e.returnValue.isGroupDM()) return new BDFDB.DiscordObjects.Channel(Object.assign({}, e.returnValue, {rawRecipients: e.returnValue.rawRecipients.filter(n => !n || !BDFDB.LibraryModules.RelationshipStore.isBlocked(n.id)), recipients: e.returnValue.recipients.filter(id => !id || !BDFDB.LibraryModules.RelationshipStore.isBlocked(id))}))
}});
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RelationshipUtils, "addRelationship", {after: e => { BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.RelationshipUtils, "addRelationship", {after: e => {
if (e.methodArguments[2] == BDFDB.DiscordConstants.RelationshipTypes.BLOCKED) this.forceUpdateAll(); if (e.methodArguments[2] == BDFDB.DiscordConstants.RelationshipTypes.BLOCKED) this.forceUpdateAll();
}}); }});
@ -390,8 +398,22 @@ module.exports = (_ => {
if (this.settings.places.voiceList && e.instance.props.user && BDFDB.LibraryModules.RelationshipStore.isBlocked(e.instance.props.user.id)) return null; if (this.settings.places.voiceList && e.instance.props.user && BDFDB.LibraryModules.RelationshipStore.isBlocked(e.instance.props.user.id)) return null;
} }
processDirectMessage (e) {
if (e.instance.props.channel && !e.instance.props.channel.name && e.instance.props.channel.isGroupDM() && this.settings.places.recentDms) {
let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"});
if (tooltip) tooltip.props.text = this.getGroupName(e.instance.props.channel.id);
}
}
processPrivateChannel (e) { processPrivateChannel (e) {
if (this.settings.places.memberList && e.instance.props.channel && e.instance.props.channel.isGroupDM()) e.instance.props.channel = new BDFDB.DiscordObjects.Channel(Object.assign({}, e.instance.props.channel, {rawRecipients: e.instance.props.channel.rawRecipients.filter(n => !n || !BDFDB.LibraryModules.RelationshipStore.isBlocked(n.id)), recipients: e.instance.props.channel.recipients.filter(id => !id || !BDFDB.LibraryModules.RelationshipStore.isBlocked(id))})); if (this.settings.places.channelList && e.instance.props.channel && 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.LibraryModules.RelationshipStore.isBlocked(n.id)), recipients: e.instance.props.channel.recipients.filter(id => !id || !BDFDB.LibraryModules.RelationshipStore.isBlocked(id))}));
}
else {
if (!e.instance.props.channel.name) e.returnvalue.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)});
}
}
} }
processPrivateChannelCallParticipants (e) { processPrivateChannelCallParticipants (e) {
@ -419,6 +441,13 @@ module.exports = (_ => {
children: ["@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER] children: ["@" + BDFDB.LanguageUtils.LanguageStrings.UNKNOWN_USER]
}); });
} }
getGroupName (channelId) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId);
if (channel.name) return channel.name;
let recipients = channel.recipients.map(BDFDB.LibraryModules.UserStore.getUser).filter(n => n && !BDFDB.LibraryModules.RelationshipStore.isBlocked(n.id));
return recipients.length > 0 ? recipients.map(u => u.toString()).join(", ") : BDFDB.LanguageUtils.LanguageStrings.UNNAMED;
}
}; };
})(window.BDFDB_Global.PluginUtils.buildPlugin(config)); })(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})(); })();