This commit is contained in:
Mirco Wittrien 2023-11-02 19:06:36 +01:00
parent 8c121e74ba
commit 6ef032d2a4
2 changed files with 101 additions and 58 deletions

View File

@ -318,6 +318,7 @@
"ChannelCallGrid": {"strings": ["totalNumberOfParticipants:", "keyExtractor:", "channel_user_limit:"]}, "ChannelCallGrid": {"strings": ["totalNumberOfParticipants:", "keyExtractor:", "channel_user_limit:"]},
"ChannelCallVideoParticipants": {"strings": [".tileSizer", "participantTileWidth:", ".COVER"]}, "ChannelCallVideoParticipants": {"strings": [".tileSizer", "participantTileWidth:", ".COVER"]},
"ChannelEmptyMessages": {"strings": [".Messages.BEGINNING_CHANNEL_WELCOME", ".Messages.BEGINNING_GROUP_DM_MANAGED", "showingBanner:"]}, "ChannelEmptyMessages": {"strings": [".Messages.BEGINNING_CHANNEL_WELCOME", ".Messages.BEGINNING_GROUP_DM_MANAGED", "showingBanner:"]},
"ChannelFloatingSidebar": {"strings": ["messageRequestSidebarWidth", "floatingLayer:", "chatLayerWrapper"]},
"ChannelItem": {"strings": ["canHaveDot", "unreadRelevant", "UNREAD_HIGHLIGHT"]}, "ChannelItem": {"strings": ["canHaveDot", "unreadRelevant", "UNREAD_HIGHLIGHT"]},
"ChannelItemIcon": {"strings": ["hasActiveThreads:", "locked:", ".iconContainer"]}, "ChannelItemIcon": {"strings": ["hasActiveThreads:", "locked:", ".iconContainer"]},
"ChannelMembers": {"strings": ["MEMBER_LIST_VIEWED", "getDimensions", "member-"]}, "ChannelMembers": {"strings": ["MEMBER_LIST_VIEWED", "getDimensions", "member-"]},

View File

@ -2,7 +2,7 @@
* @name EditChannels * @name EditChannels
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 4.5.4 * @version 4.5.5
* @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
@ -88,6 +88,7 @@ module.exports = (_ => {
before: [ before: [
"AuditLogEntry", "AuditLogEntry",
"AutocompleteChannelResult", "AutocompleteChannelResult",
"ChannelCallHeader",
"ChannelEmptyMessages", "ChannelEmptyMessages",
"ChannelsList", "ChannelsList",
"ChannelTextAreaEditor", "ChannelTextAreaEditor",
@ -103,11 +104,14 @@ module.exports = (_ => {
after: [ after: [
"AuditLogEntry", "AuditLogEntry",
"AutocompleteChannelResult", "AutocompleteChannelResult",
"ChannelItem", "ChannelCallHeader",
"ChannelFloatingSidebar",
"ChannelItemIcon",
"ChannelThreadItem", "ChannelThreadItem",
"DirectMessage", "DirectMessage",
"FocusRingScope", "FocusRingScope",
"HeaderBarContainer", "HeaderBarContainer",
"Mention",
"PrivateChannel", "PrivateChannel",
"QuickSwitchChannelResult", "QuickSwitchChannelResult",
"RecentsChannelHeader", "RecentsChannelHeader",
@ -128,6 +132,14 @@ module.exports = (_ => {
${BDFDB.dotCN.searchresultschannelname}:hover > span[style*="color"] { ${BDFDB.dotCN.searchresultschannelname}:hover > span[style*="color"] {
text-decoration: underline; text-decoration: underline;
} }
${BDFDB.dotCN.mention}[style*="--edited-mention-color"] {
background-color: rgba(var(--edited-mention-color), .1) !important;
color: rgb(var(--edited-mention-color)) !important;
}
${BDFDB.dotCN.mention + BDFDB.dotCN.mentioninteractive}[style*="--edited-mention-color"]:hover {
background-color: rgba(var(--edited-mention-color), .3) !important;
color: rgb(var(--edited-mention-color)) !important;
}
`; `;
} }
@ -342,6 +354,32 @@ module.exports = (_ => {
for (let id in e.instance.props.invites) e.instance.props.invites[id] = new BDFDB.DiscordObjects.Invite(Object.assign({}, e.instance.props.invites[id], {channel: this.getChannelData(e.instance.props.invites[id].channel.id)})); for (let id in e.instance.props.invites) e.instance.props.invites[id] = new BDFDB.DiscordObjects.Invite(Object.assign({}, e.instance.props.invites[id], {channel: this.getChannelData(e.instance.props.invites[id].channel.id)}));
} }
processChannelFloatingSidebar (e) {
if (!this.settings.places.channelHeader) return;
let channel = e.instance.props && e.instance.props.children && e.instance.props.children[0] && e.instance.props.children[0].props && e.instance.props.children[0].props.channel;
if (!channel || channel.isDM()) return;
let headerBar = BDFDB.ReactUtils.findChild(e.instance.props.children, {name: "HeaderBar"});
if (!headerBar) return;
let channelName = BDFDB.ReactUtils.findChild(headerBar, {name: "HeaderBarTitle"});
if (channelName) {
channelName.props.children = this.getChannelData(channel.id).name;
this.changeChannelColor(channelName, channel.id);
}
let channelIcon = BDFDB.ReactUtils.findChild(headerBar, {name: "HeaderBarTitleIcon"});
if (channelIcon) this.changeChannelIconColor(channelIcon, channel.id);
}
processChannelCallHeader (e) {
if (!this.settings.places.channelHeader || !e.instance.props.channel || e.instance.props.channel.isDM()) return;
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
else {
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "HeaderBarTitle"});
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id);
let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "HeaderBarTitleIcon"});
if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id);
}
}
processHeaderBarContainer (e) { processHeaderBarContainer (e) {
if (!this.settings.places.channelHeader) return; if (!this.settings.places.channelHeader) return;
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(e.instance.props.channelId); let channel = BDFDB.LibraryStores.ChannelStore.getChannel(e.instance.props.channelId);
@ -425,6 +463,13 @@ module.exports = (_ => {
iconClass = BDFDB.disCN.categoryicon; iconClass = BDFDB.disCN.categoryicon;
modify = {muted: BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(BDFDB.LibraryStores.SelectedGuildStore.getGuildId(), channelId)}; modify = {muted: BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(BDFDB.LibraryStores.SelectedGuildStore.getGuildId(), channelId)};
} }
if (this.settings.places.channelList && e.returnvalue.props.className.indexOf(BDFDB.disCN.channeliconvisibility) > -1) {
change = true;
hoveredEvents = true;
channelId = (BDFDB.ReactUtils.findValue(e.returnvalue, "data-list-item-id") || "").split("___").pop();
nameClass = BDFDB.disCN.channelname;
modify = {muted: BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(BDFDB.LibraryStores.SelectedGuildStore.getGuildId(), channelId)};
}
else if (this.settings.places.searchPopout && e.returnvalue.props.className.indexOf(BDFDB.disCN.searchpopoutoption) > -1) { else if (this.settings.places.searchPopout && e.returnvalue.props.className.indexOf(BDFDB.disCN.searchpopoutoption) > -1) {
change = true; change = true;
let channel = (BDFDB.ReactUtils.findValue(e.returnvalue._owner, "result", {up: true}) || {}).channel; let channel = (BDFDB.ReactUtils.findValue(e.returnvalue._owner, "result", {up: true}) || {}).channel;
@ -457,6 +502,7 @@ module.exports = (_ => {
} }
let name = nameClass && BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", nameClass]]}); let name = nameClass && BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", nameClass]]});
if (name) { if (name) {
if (name.props && typeof name.props.children == "string") name.props.children = BDFDB.ReactUtils.createElement("span", {children: name.props.children});
name = name.props && name.props.children || name; name = name.props && name.props.children || name;
this.changeChannelColor(BDFDB.ArrayUtils.is(name) ? name.find(c => c.type == "strong") || name[0] : name, channelId, modify); this.changeChannelColor(BDFDB.ArrayUtils.is(name) ? name.find(c => c.type == "strong") || name[0] : name, channelId, modify);
} }
@ -489,27 +535,18 @@ module.exports = (_ => {
}, "Error in getChannelFromSectionRow of ChannelsList!", this); }, "Error in getChannelFromSectionRow of ChannelsList!", this);
} }
processChannelItem (e) { processChannelItemIcon (e) {
if (!this.settings.places.channelList || !e.instance.props.channel) return; if (!this.settings.places.channelList || !e.instance.props.channel) return;
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected", "hovered"); let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected", "hovered");
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelname]]}); if (e.returnvalue.props && typeof e.returnvalue.props.children == "function") {
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify); let childrenRender = e.returnvalue.props.children;
let channelIcon = this.settings.general.changeChannelIcon && BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ChannelItemIcon"}); e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args2) => {
if (channelIcon && typeof channelIcon.type == "function") { let renderedChildren = childrenRender(...args2);
let type = channelIcon.type; this.changeChannelIconColor(renderedChildren.props.children, e.instance.props.channel.id, modify);
channelIcon.type = BDFDB.TimeUtils.suppress((...args) => { return renderedChildren;
let returnValue = type(...args); }, "Error in Children Render of ChannelItem!", this);
if (returnValue && typeof returnValue.props.children == "function") {
let childrenRender = returnValue.props.children;
returnValue.props.children = BDFDB.TimeUtils.suppress((...args2) => {
let renderedChildren = childrenRender(...args2);
this.changeChannelIconColor(renderedChildren.props.children, e.instance.props.channel.id, modify);
return renderedChildren;
}, "Error in Children Render of ChannelItem!", this);
}
return returnValue;
}, "Error in Type Render of ChannelItem!", this);
} }
else this.changeChannelIconColor(e.returnvalue, e.instance.props.channel.id, modify);
} }
processChannelThreadItem (e) { processChannelThreadItem (e) {
@ -615,40 +652,30 @@ module.exports = (_ => {
processMessageContent (e) { processMessageContent (e) {
if (!this.settings.places.mentions || !BDFDB.ArrayUtils.is(e.instance.props.content)) return; if (!this.settings.places.mentions || !BDFDB.ArrayUtils.is(e.instance.props.content)) return;
for (let ele of e.instance.props.content) if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && ele.type.prototype && ele.type.prototype.renderTooltip && typeof ele.props.children == "function") { for (let ele of e.instance.props.content) if (BDFDB.ReactUtils.isValidElement(ele) && ele.type) {
let children = ele.props.children({}); let children = ele.props && ele.props.className && ele.props.className.indexOf("channelMention") == 0 ? ele : ele.type.prototype && ele.type.prototype.renderTooltip && typeof ele.props.children == "function" && ele.props.children({});
if (!children || !children.props || !children.props.iconType || !children.props.className || children.props.className.indexOf("channelMention") != 0) return; if (!children || !children.props || !children.props.className || children.props.className.indexOf("channelMention") != 0) return;
const checkChild = channelName => { let channelNameWrapper = BDFDB.ReactUtils.findChild(children, {props: ["iconType"]});
let guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId(); let channelName = channelNameWrapper && BDFDB.ReactUtils.findChild(channelNameWrapper, {type: "span"});
let channels = guildId && [].concat(BDFDB.LibraryStores.GuildChannelStore.getChannels(guildId).SELECTABLE, Object.keys(BDFDB.LibraryStores.ActiveThreadsStore.getThreadsForGuild(guildId)).map(id => ({channel: BDFDB.LibraryStores.ChannelStore.getChannel(id)}))); if (!channelNameWrapper || !channelName) return;
if (!BDFDB.ArrayUtils.is(channels)) return; let guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId();
for (let channelObj of channels) { let channels = guildId && [].concat(BDFDB.LibraryStores.GuildChannelStore.getChannels(guildId).SELECTABLE, BDFDB.LibraryStores.GuildChannelStore.getChannels(guildId).VOCAL, Object.keys(BDFDB.LibraryStores.ActiveThreadsStore.getThreadsForGuild(guildId)).map(id => ({channel: BDFDB.LibraryStores.ChannelStore.getChannel(id)})));
if (channelName == channelObj.channel.name) { if (!BDFDB.ArrayUtils.is(channels)) return;
let category = BDFDB.LibraryStores.ChannelStore.getChannel(channelObj.channel.parent_id); for (let channelObj of channels) if (channelName.props.children == channelObj.channel.name && (channelNameWrapper.props.iconType == "text" && !channelObj.channel.isVocal() || channelNameWrapper.props.iconType == "voice" && channelObj.channel.isVocal())) {
if (!category || category && ele.props.text == category.name) { let name = (changedChannels[channelObj.channel.id] || {}).name;
if (category) { let color = this.getChannelDataColor(channelObj.channel.id);
let categoryData = changedChannels[category.id]; if (name || color) {
if (categoryData && categoryData.name) ele.props.text = categoryData.name; if (typeof ele.props.children == "function") {
} let renderChildren = ele.props.children;
let name = (changedChannels[channelObj.channel.id] || {}).name; ele.props.children = BDFDB.TimeUtils.suppress((...args) => {
let color = this.getChannelDataColor(channelObj.channel.id); let renderedChildren = renderChildren(...args);
if (name || color) { this.changeMention(renderedChildren, {name, color});
let renderChildren = ele.props.children; return renderedChildren;
ele.props.children = BDFDB.TimeUtils.suppress((...args) => { }, "Error in Children Render of ChannelMention in MessageContent!", this);
let renderedChildren = renderChildren(...args);
this.changeMention(renderedChildren, {name, color});
return renderedChildren;
}, "Error in Children Render of ChannelMention in MessageContent!", this);
}
break;
}
} }
else this.changeMention(channelNameWrapper, {name, color}, ele);
} }
}; break;
if (typeof children.props.children == "string") checkChild(children.props.children);
else if (BDFDB.ArrayUtils.is(children.props.children)) for (let i in children.props.children) {
if (typeof children.props.children[i] == "string") checkChild(children.props.children[i]);
else if (BDFDB.ArrayUtils.is(children.props.children[i])) for (let j in children.props.children[i]) if (typeof children.props.children[i][j] == "string") checkChild(children.props.children[i][j]);
} }
} }
} }
@ -679,7 +706,7 @@ module.exports = (_ => {
} }
} }
changeMention (mention, data) { changeMention (mention, data, wrapper) {
if (!mention) return; if (!mention) return;
if (data.name) { if (data.name) {
const changeMentionName = (child, name) => { const changeMentionName = (child, name) => {
@ -693,6 +720,7 @@ module.exports = (_ => {
} }
else if (child.props) { else if (child.props) {
if (child.props.iconType && typeof child.props.children == "string") child.props.children = data.name; if (child.props.iconType && typeof child.props.children == "string") child.props.children = data.name;
else if (child.props.iconType && BDFDB.ArrayUtils.is(child.props.children) && child.props.children.length == 1 && child.props.children[0] && child.props.children[0].props) child.props.children[0].props.children = data.name;
else if (child.props.iconType && BDFDB.ArrayUtils.is(child.props.children) && child.props.children.length == 1) child.props.children = [data.name]; else if (child.props.iconType && BDFDB.ArrayUtils.is(child.props.children) && child.props.children.length == 1) child.props.children = [data.name];
else if (typeof child.props.children == "string" && child.props.children[0] == "#") child.props.children = "#" + data.name; else if (typeof child.props.children == "string" && child.props.children[0] == "#") child.props.children = "#" + data.name;
else if (BDFDB.ArrayUtils.is(child.props.children)) changeMentionName(child.props.children); else if (BDFDB.ArrayUtils.is(child.props.children)) changeMentionName(child.props.children);
@ -700,7 +728,19 @@ module.exports = (_ => {
}; };
changeMentionName(mention); changeMentionName(mention);
} }
if (data.color) mention.props.color = BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(data.color) ? data.color[0] : data.color, "INT"); if (data.color) {
wrapper = wrapper || mention;
wrapper.props.color = BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(data.color) ? data.color[0] : data.color, "INT");
wrapper.props["edited-mention-color"] = BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(data.color) ? data.color[0] : data.color, "RGBCOMP").slice(0, 3).join(",");
if (wrapper.props.children && wrapper.props.children.props) {
wrapper.props.children.props.color = wrapper.props.color;
wrapper.props.children.props["edited-mention-color"] = BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(data.color) ? data.color[0] : data.color, "RGBCOMP").slice(0, 3).join(",");
}
}
}
processMention (e) {
if (e.instance.props["edited-mention-color"]) e.returnvalue.props.style = Object.assign({}, e.returnvalue.props.style, {"--edited-mention-color": e.instance.props["edited-mention-color"]});
} }
changeChannelColor (child, channelId, modify) { changeChannelColor (child, channelId, modify) {
@ -729,10 +769,12 @@ module.exports = (_ => {
if (!color) return; if (!color) return;
child.props.foreground = null; child.props.foreground = null;
child.props.color = color || "currentColor"; child.props.color = color || "currentColor";
child.props.children = [child.props.children].flat(10).filter(n => n); if (typeof child.props.children != "function") {
for (let c of child.props.children) { child.props.children = [child.props.children].flat(10).filter(n => n);
if (c && c.props && c.props.fill == "currentColor") c.props.fill = color || "currentColor"; for (let c of child.props.children) {
if (c && c.props && c.props.path == "currentColor") c.props.path = color || "currentColor"; if (c && c.props && c.props.fill == "currentColor") c.props.fill = color || "currentColor";
if (c && c.props && c.props.path == "currentColor") c.props.path = color || "currentColor";
}
} }
} }