diff options
author | Loek Le Blansch <l.leblansch@gmail.com> | 2020-07-14 20:36:19 +0200 |
---|---|---|
committer | Loek Le Blansch <l.leblansch@gmail.com> | 2020-07-14 20:36:19 +0200 |
commit | e6a025a7cca1abb7b2719a281308bd93f03f1a16 (patch) | |
tree | 322eea054e9efd44acbec265472e254e3c134e7f /.config/BetterDiscord | |
parent | 4581376a1b136bda087190f4c6b440d55801aeaa (diff) |
commit message here
Diffstat (limited to '.config/BetterDiscord')
10 files changed, 652 insertions, 482 deletions
diff --git a/.config/BetterDiscord/plugins/EditChannels.config.json b/.config/BetterDiscord/plugins/EditChannels.config.json index ac031cf..e50dff3 100644 --- a/.config/BetterDiscord/plugins/EditChannels.config.json +++ b/.config/BetterDiscord/plugins/EditChannels.config.json @@ -1,6 +1,82 @@ { "changelog": { - "currentversion": "4.1.3" + "currentversion": "4.1.5" + }, + "channels": { + "716039712799719489": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "716039712799719490": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "716708258123087873": { + "color": [ + 233, + 30, + 99 + ], + "inheritColor": false, + "name": null + }, + "716739284089962577": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "719892211000672296": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "722724726425911316": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "722732084342423592": { + "color": [ + 233, + 30, + 99, + 1 + ], + "inheritColor": false, + "name": null + }, + "715240118952263691": { + "color": null, + "inheritColor": false, + "name": "announcements" + } }, "settings": { "changeChannelIcon": true, diff --git a/.config/BetterDiscord/plugins/EditChannels.plugin.js b/.config/BetterDiscord/plugins/EditChannels.plugin.js index 955776e..74327e3 100644 --- a/.config/BetterDiscord/plugins/EditChannels.plugin.js +++ b/.config/BetterDiscord/plugins/EditChannels.plugin.js @@ -1,20 +1,18 @@ //META{"name":"EditChannels","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditChannels","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditChannels/EditChannels.plugin.js"}*// var EditChannels = (_ => { + var changedChannels = {}, settings = {}; + return class EditChannels { getName () {return "EditChannels";} - getVersion () {return "4.1.3";} + getVersion () {return "4.1.6";} getAuthor () {return "DevilBro";} getDescription () {return "Allows you to rename and recolor channelnames.";} constructor () { - this.changelog = { - "fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]] - }; - this.patchedModules = { before: { ChannelEditorContainer: "render", @@ -35,22 +33,17 @@ var EditChannels = (_ => { ChannelCategoryItem: "render", ChannelItem: "render", QuickSwitchChannelResult: "render", - MessagesPopout: "render" + RecentsChannelHeader: "default" } }; } initConstructor () { this.css = ` - ${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"] { + ${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"], + ${BDFDB.dotCN.recentmentionschannelname}:hover > span[style*="color"] { text-decoration: underline; } - ${BDFDB.dotCN.categorywrapper}:hover ${BDFDB.dotCN.categoryname} span[style*="color"], - ${BDFDB.dotCN.categorywrapper}:hover ${BDFDB.dotCN.categoryicon}.EC-changed, - ${BDFDB.dotCN.channelwrapper + BDFDB.notCN.channelmodeselected + BDFDB.notCN.channelmodeconnected}:hover ${BDFDB.dotCN.channelname} span[style*="color"], - ${BDFDB.dotCN.channelwrapper + BDFDB.notCN.channelmodeselected + BDFDB.notCN.channelmodeconnected}:hover ${BDFDB.dotCN.channelicon}.EC-changed { - filter: brightness(150%); - } `; this.defaults = { @@ -145,10 +138,7 @@ var EditChannels = (_ => { if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { this.stopping = true; - let data = BDFDB.DataUtils.load(this, "channels"); - BDFDB.DataUtils.remove(this, "channels"); - try {this.forceUpdateAll();} catch (err) {} - BDFDB.DataUtils.save(data, this, "channels"); + this.forceUpdateAll(); BDFDB.PluginUtils.clear(this); } @@ -177,7 +167,7 @@ var EditChannels = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.submenu_resetsettings_text, id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), - disabled: !BDFDB.DataUtils.load(this, "channels", e.instance.props.channel.id), + disabled: !changedChannels[e.instance.props.channel.id], action: _ => { BDFDB.ContextMenuUtils.close(e.instance); BDFDB.DataUtils.remove(this, "channels", e.instance.props.channel.id); @@ -199,49 +189,48 @@ var EditChannels = (_ => { } 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 && BDFDB.DataUtils.get(this, "settings", "changeInChatTextarea")) { - let data = BDFDB.DataUtils.load(this, "channels", e.instance.props.channel.id); + if (!e.instance.props.disabled && e.instance.props.channel && BDFDB.ChannelUtils.isTextChannel(e.instance.props.channel) && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL && settings.changeInChatTextarea) { + let data = changedChannels[e.instance.props.channel.id]; e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${data && data.name || e.instance.props.channel.name}`); } } processChannelAutoComplete (e) { if (e.instance.state.autocompleteType == "CHANNELS" && BDFDB.ArrayUtils.is(e.instance.state.autocompletes.channels) && e.instance.props.channel && e.instance.props.channel.guild_id) { - let lastword = (e.instance.props.textValue || "").slice(1).toLowerCase(); - let channels = BDFDB.DataUtils.load(this, "channels"); - if (!channels || !lastword) return; - let channelarray = []; - for (let id in channels) if (channels[id] && channels[id].name) { + let lastWord = (e.instance.props.textValue || "").slice(1).toLowerCase(); + if (!lastWord) return; + let channelArray = []; + for (let id in changedChannels) if (changedChannels[id] && changedChannels[id].name) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(id); let category = channel && channel.parent_id && BDFDB.LibraryModules.ChannelStore.getChannel(channel.parent_id); - let catdata = category && channels[category.id] || {}; - if (BDFDB.ChannelUtils.isTextChannel(channel) && channel.guild_id == e.instance.props.channel.guild_id) channelarray.push(Object.assign({ - lowercasename: channels[id].name.toLowerCase(), - lowercasecatname: catdata && catdata.name && catdata.name.toLowerCase(), + let catdata = category && changedChannels[category.id] || {}; + if (BDFDB.ChannelUtils.isTextChannel(channel) && channel.guild_id == e.instance.props.channel.guild_id) channelArray.push(Object.assign({ + lowerCaseName: changedChannels[id].name.toLowerCase(), + lowerCaseCatName: catdata && catdata.name && catdata.name.toLowerCase(), channel, category, catdata - }, channels[id])); + }, changedChannels[id])); } - channelarray = BDFDB.ArrayUtils.keySort(channelarray.filter(n => e.instance.state.autocompletes.channels.every(channel => channel.id != n.channel.id) && (n.lowercasename.indexOf(lastword) != -1 || (n.lowercasecatname && n.lowercasecatname.indexOf(lastword) != -1))), "lowercasename"); - e.instance.state.autocompletes.channels = [].concat(e.instance.state.autocompletes.channels, channelarray.map(n => n.channel)).slice(0, BDFDB.DiscordConstants.MAX_AUTOCOMPLETE_RESULTS); + channelArray = BDFDB.ArrayUtils.keySort(channelArray.filter(n => e.instance.state.autocompletes.channels.every(channel => channel.id != n.channel.id) && (n.lowerCaseName.indexOf(lastWord) != -1 || (n.lowerCaseCatName && n.lowerCaseCatName.indexOf(lastWord) != -1))), "lowerCaseName"); + e.instance.state.autocompletes.channels = [].concat(e.instance.state.autocompletes.channels, channelArray.map(n => n.channel)).slice(0, BDFDB.DiscordConstants.MAX_AUTOCOMPLETE_RESULTS); } } processAutocompleteChannelResult (e) { - if (e.instance.props.channel && BDFDB.DataUtils.get(this, "settings", "changeInAutoComplete")) { + if (e.instance.props.channel && settings.changeInAutoComplete) { if (!e.returnvalue) { e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id); } else { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.marginleft4]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id); - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.autocompleteicon]]}); - if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, {alpha: 0.6}); + let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.marginleft4]]}); + if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id); + let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.autocompleteicon]]}); + if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, {alpha: 0.6}); if (e.instance.props.category) { - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.autocompletedescription]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.category.id); + let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.autocompletedescription]]}); + if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id); } } } @@ -249,17 +238,17 @@ var EditChannels = (_ => { processAuditLog (e) { let channel = BDFDB.ReactUtils.getValue(e.instance, "props.log.options.channel"); - if (channel && BDFDB.DataUtils.get(this, "settings", "changeInAuditLog")) { + if (channel && settings.changeInAuditLog) { if (!e.returnvalue) e.instance.props.log.options.channel = this.getChannelData(channel.id); else { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["children", [["#" + channel.name]]]]}); - if (index > -1) this.changeChannelColor(children[index], channel.id); + let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["children", [["#" + channel.name]]]]}); + if (channelName) this.changeChannelColor(channelName, channel.id); } } } processSettingsInvites (e) { - if (BDFDB.ObjectUtils.is(e.instance.props.invites) && BDFDB.DataUtils.get(this, "settings", "changeInInviteLog")) { + if (BDFDB.ObjectUtils.is(e.instance.props.invites) && settings.changeInInviteLog) { e.instance.props.invites = Object.assign({}, e.instance.props.invites); 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)})); } @@ -267,16 +256,16 @@ var EditChannels = (_ => { processHeaderBarContainer (e) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.channelId); - if (channel && BDFDB.ChannelUtils.isTextChannel(channel) && BDFDB.DataUtils.get(this, "settings", "changeInChannelHeader")) { + if (channel && BDFDB.ChannelUtils.isTextChannel(channel) && settings.changeInChannelHeader) { if (!e.returnvalue) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.instance, {name: "Title"}); - if (index > -1) { - children[index].props.children = this.getChannelData(channel.id).name; - this.changeChannelColor(children[index], channel.id); + let channelName = BDFDB.ReactUtils.findChild(e.instance, {name: "Title"}); + if (channelName) { + channelName.props.children = this.getChannelData(channel.id).name; + this.changeChannelColor(channelName, channel.id); } } else { - let [children, index] = BDFDB.ReactUtils.findChildren(e.instance, {name: "Icon"}); + let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {name: "Icon"}); if (index > -1) { let icon = BDFDB.ReactUtils.createElement(children[index].props.icon, { className: BDFDB.disCN.channelheadericon @@ -292,72 +281,77 @@ var EditChannels = (_ => { } processChannelCategoryItem (e) { - if (e.instance.props.channel && BDFDB.DataUtils.get(this, "settings", "changeInChannelList")) { + if (e.instance.props.channel && settings.changeInChannelList) { if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); else { - let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected"); - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.categoryname]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.categoryicon]]}); - if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); + let onMouseEnter = e.returnvalue.props.onMouseEnter || ( _ => {}); + e.returnvalue.props.onMouseEnter = event => {e.instance.setState({hovered: true});}; + let onMouseLeave = e.returnvalue.props.onMouseLeave || ( _ => {}); + e.returnvalue.props.onMouseLeave = event => {e.instance.setState({hovered: false});}; + let modify = BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "muted", "locked", "selected", "unread", "connected", "hovered"); + let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.categoryname]]}); + if (categoryName) this.changeChannelColor(categoryName, e.instance.props.channel.id, modify); + let categoryIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.categoryicon]]}); + if (categoryIcon) this.changeChannelIconColor(categoryIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); } } } processChannelItem (e) { - if (e.instance.props.channel && BDFDB.DataUtils.get(this, "settings", "changeInChannelList")) { + if (e.instance.props.channel && settings.changeInChannelList) { if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); else { - let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected"); - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.channelname]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.channelicon]]}); - if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); + let onMouseEnter = e.returnvalue.props.onMouseEnter || ( _ => {}); + e.returnvalue.props.onMouseEnter = event => {e.instance.setState({hovered: true});}; + let onMouseLeave = e.returnvalue.props.onMouseLeave || ( _ => {}); + e.returnvalue.props.onMouseLeave = event => {e.instance.setState({hovered: false});}; + let modify = BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "muted", "locked", "selected", "unread", "connected", "hovered"); + let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.channelname]]}); + if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify); + let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.channelicon]]}); + if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); } } } processQuickSwitchChannelResult (e) { - if (e.instance.props.channel && BDFDB.DataUtils.get(this, "settings", "changeInQuickSwitcher")) { + if (e.instance.props.channel && settings.changeInQuickSwitcher) { if (!e.returnvalue) { e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id); } else { let modify = BDFDB.ObjectUtils.extract(e.instance.props, "focused", "unread", "mentions"); - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultmatch]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresulticon]]}); - if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); + let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultmatch]]}); + if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify); + let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresulticon]]}); + if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); if (e.instance.props.category) { - [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultnote]]}); - if (index > -1) this.changeChannelColor(children[index], e.instance.props.category.id); + let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultnote]]}); + if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id); } } } } - processMessagesPopout (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInRecentMentions")) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "VerticalScroller"}); - if (index > -1 && children[index].props.children && BDFDB.ArrayUtils.is(children[index].props.children[0])) for (let i in children[index].props.children[0]) { - let divider = children[index].props.children[0][i]; - if (divider && divider.props && divider.props.className == BDFDB.disCN.messagespopoutchannelseparator) { - let channel = BDFDB.ReactUtils.findValue(children[index].props.children[0][parseInt(i)+1], "channel"); - if (BDFDB.ChannelUtils.isTextChannel(channel)) { - let [children2, index2] = BDFDB.ReactUtils.findChildren(divider, {props:[["className", BDFDB.disCN.messagespopoutchannelname]]}); - if (index2 > -1) { - children2[index2].props.children = "#" + this.getChannelData(channel.id).name; - this.changeChannelColor(children2[index2], channel.id); - } - } - } + processRecentsChannelHeader (e) { + if (settings.changeInRecentMentions && BDFDB.ArrayUtils.is(e.returnvalue.props.children)) { + for (let child of e.returnvalue.props.children) if (child && child.props && child.props.channel && child.type.displayName == "ChannelName") { + child.props.channel = this.getChannelData(child.props.channel.id); + let oldType = child.type; + child.type = (...args) => { + let instance = oldType(...args); + let channelName = BDFDB.ReactUtils.findChild(instance, {props:[["className", BDFDB.disCN.recentmentionschannelname]]}); + if (channelName) this.changeChannelColor(channelName, child.props.channel.id); + return instance; + }; + child.type.displayName = oldType.displayName; } } } processMessageContent (e) { - if (BDFDB.ArrayUtils.is(e.instance.props.content) && BDFDB.DataUtils.get(this, "settings", "changeInMentions")) for (let ele of e.instance.props.content) { + if (BDFDB.ArrayUtils.is(e.instance.props.content) && settings.changeInMentions) for (let ele of e.instance.props.content) { if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && ele.type.displayName == "Tooltip" && typeof ele.props.children == "function") { let children = ele.props.children({}); if (children && children.type.displayName == "Mention" && children.props.children && typeof children.props.children[0] == "string" && children.props.children[0][0] == "#") { @@ -369,10 +363,10 @@ var EditChannels = (_ => { let category = BDFDB.LibraryModules.ChannelStore.getChannel(channelObj.channel.parent_id); if (!category || category && ele.props.text == category.name) { if (category) { - let categoryData = BDFDB.DataUtils.load(this, "channels", category.id); + let categoryData = changedChannels[category.id]; if (categoryData && categoryData.name) ele.props.text = categoryData.name; } - let name = (BDFDB.DataUtils.load(this, "channels", channelObj.channel.id) || {}).name; + let name = (changedChannels[channelObj.channel.id] || {}).name; let color = this.getChannelDataColor(channelObj.channel.id); if (name || color) { let renderChildren = ele.props.children; @@ -415,34 +409,34 @@ var EditChannels = (_ => { changeAppTitle () { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); let title = document.head.querySelector("title"); - if (title && BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "@" + this.getChannelData(channel.id, BDFDB.DataUtils.get(this, "settings", "changeAppTitle")).name); + if (title && BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "@" + this.getChannelData(channel.id, settings.changeAppTitle).name); } changeChannelColor (child, channelId, modify) { - let color = this.getChannelDataColor(channelId); - if (color) { - color = modify ? this.chooseColor(color, modify) : BDFDB.ColorUtils.convert(color, "RGBA"); - let fontGradient = BDFDB.ObjectUtils.is(color); - if (fontGradient) child.props.children = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextGradientElement, { - gradient: BDFDB.ColorUtils.createGradient(color), - children: child.props.children - }); - else child.props.children = BDFDB.ReactUtils.createElement("span", { - style: {color: color}, - children: child.props.children - }); + if (BDFDB.ReactUtils.isValidElement(child)) { + let color = this.getChannelDataColor(channelId); + if (color) { + color = modify ? this.chooseColor(color, modify) : BDFDB.ColorUtils.convert(color, "RGBA"); + let childProp = child.props.children ? "children" : "text"; + let fontGradient = BDFDB.ObjectUtils.is(color); + if (fontGradient) child.props[childProp] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextGradientElement, { + gradient: BDFDB.ColorUtils.createGradient(color), + children: child.props[childProp] + }); + else child.props[childProp] = BDFDB.ReactUtils.createElement("span", { + style: {color: color}, + children: child.props[childProp] + }); + } } } changeChannelIconColor (child, channelId, modify) { let color = this.getChannelDataColor(channelId); - if (color && BDFDB.DataUtils.get(this, "settings", "changeChannelIcon")) { + if (color && settings.changeChannelIcon) { color = modify ? this.chooseColor(BDFDB.ObjectUtils.is(color) ? color[0] : color, modify) : BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(color) ? color[0] : color, "RGBA"); child.props.color = color || "currentColor"; - if (color) { - child.props.foreground = null; - child.props.className = BDFDB.DOMUtils.formatClassName(child.props.className, "EC-changed"); - } + if (color) child.props.foreground = null; } } @@ -460,11 +454,11 @@ var EditChannels = (_ => { getChannelDataColor (channelId) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId); if (!channel) return null; - let channelData = BDFDB.DataUtils.load(this, "channels", channel.id); + let channelData = changedChannels[channel.id]; if (channelData && channelData.color) return channelData.color; let category = channel.parent_id && BDFDB.LibraryModules.ChannelStore.getChannel(channel.parent_id); if (category) { - let categoryData = BDFDB.DataUtils.load(this, "channels", category.id); + let categoryData = changedChannels[category.id]; if (categoryData && categoryData.inheritColor && categoryData.color) return categoryData.color; } return null; @@ -473,7 +467,7 @@ var EditChannels = (_ => { getChannelData (channelId, change = true) { let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId); if (!channel) return new BDFDB.DiscordObjects.Channel({}); - let data = change && BDFDB.DataUtils.load(this, "channels", channel.id); + let data = change && changedChannels[channel.id]; if (data) { let nativeObject = new BDFDB.DiscordObjects.Channel(channel); nativeObject.name = data.name || nativeObject.name; @@ -483,13 +477,16 @@ var EditChannels = (_ => { } forceUpdateAll () { + changedChannels = BDFDB.DataUtils.load(this, "channels"); + settings = BDFDB.DataUtils.get(this, "settings"); + this.changeAppTitle(); BDFDB.ModuleUtils.forceAllUpdates(this); BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Channel", unlimited:true})); } openChannelSettingsModal (channel) { - let data = BDFDB.DataUtils.load(this, "channels", channel.id) || {}; + let data = changedChannels[channel.id] || {}; BDFDB.ModalUtils.open(this, { size: "MEDIUM", diff --git a/.config/BetterDiscord/plugins/EditServers.config.json b/.config/BetterDiscord/plugins/EditServers.config.json index 8544d34..aa0d0d0 100644 --- a/.config/BetterDiscord/plugins/EditServers.config.json +++ b/.config/BetterDiscord/plugins/EditServers.config.json @@ -1,6 +1,6 @@ { "changelog": { - "currentversion": "2.2.1" + "currentversion": "2.2.2" }, "servers": { "624859996949315584": { @@ -15,6 +15,39 @@ "removeIcon": false, "shortName": null, "url": null + }, + "716039712799719486": { + "banner": null, + "color1": [ + 233, + 30, + 99, + 1 + ], + "color2": [ + 233, + 30, + 99, + 1 + ], + "color3": [ + 233, + 30, + 99, + 1 + ], + "color4": [ + 44, + 44, + 44, + 1 + ], + "ignoreCustomName": false, + "name": null, + "removeBanner": false, + "removeIcon": false, + "shortName": null, + "url": null } }, "settings": { diff --git a/.config/BetterDiscord/plugins/EditServers.plugin.js b/.config/BetterDiscord/plugins/EditServers.plugin.js index 3291113..9c80f58 100644 --- a/.config/BetterDiscord/plugins/EditServers.plugin.js +++ b/.config/BetterDiscord/plugins/EditServers.plugin.js @@ -1,10 +1,12 @@ //META{"name":"EditServers","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditServers","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditServers/EditServers.plugin.js"}*// var EditServers = (_ => { + var changedGuilds = {}, settings = {}; + return class EditServers { getName () {return "EditServers";} - getVersion () {return "2.2.1";} + getVersion () {return "2.2.2";} getAuthor () {return "DevilBro";} @@ -12,7 +14,7 @@ var EditServers = (_ => { constructor () { this.changelog = { - "fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]] + "fixed":[["Inbox update","Fixes for the inbox update"]] }; this.patchedModules = { @@ -20,14 +22,13 @@ var EditServers = (_ => { Guild: "render", GuildIconWrapper: "render", MutualGuilds: "render", - FriendRow: "render", QuickSwitcher: "render", QuickSwitchChannelResult: "render", GuildSidebar: "render", GuildHeader: "render" }, after: { - MessagesPopout: "render", + RecentsChannelHeader: "default", Guild: "render", BlobMask: "render", GuildIconWrapper: "render", @@ -78,7 +79,7 @@ var EditServers = (_ => { onClick: _ => { BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset all Servers?", _ => { BDFDB.DataUtils.remove(this, "servers"); - BDFDB.ModuleUtils.forceAllUpdates(this);; + this.forceUpdateAll();; }); }, children: BDFDB.LanguageUtils.LanguageStrings.RESET @@ -120,7 +121,7 @@ var EditServers = (_ => { let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.methodArguments[0].id); if (guild) { if (e.methodArguments[0].id == "410787888507256842") return guild.banner; - let data = BDFDB.DataUtils.load(this, "servers", guild.id); + let data = changedGuilds[guild.id]; if (data && data.banner && !data.removeBanner) return data.banner; } return e.callOriginalMethod(); @@ -137,7 +138,7 @@ var EditServers = (_ => { } }); - BDFDB.ModuleUtils.forceAllUpdates(this); + this.forceUpdateAll(); } else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!"); } @@ -146,7 +147,7 @@ var EditServers = (_ => { if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { this.stopping = true; - BDFDB.ModuleUtils.forceAllUpdates(this); + this.forceUpdateAll(); for (let guildobj of BDFDB.GuildUtils.getAll()) if (guildobj.instance) delete guildobj.instance.props.guild.EditServersCachedBanner; @@ -176,11 +177,11 @@ var EditServers = (_ => { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { label: this.labels.submenu_resetsettings_text, id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), - disabled: !BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id), + disabled: !changedGuilds[e.instance.props.guild.id], action: _ => { BDFDB.ContextMenuUtils.close(e.instance); BDFDB.DataUtils.remove(this, "servers", e.instance.props.guild.id); - BDFDB.ModuleUtils.forceAllUpdates(this); + this.forceUpdateAll(); } }) ] @@ -191,12 +192,12 @@ var EditServers = (_ => { } processGuild (e) { - if (BDFDB.GuildUtils.is(e.instance.props.guild) && BDFDB.DataUtils.get(this, "settings", "changeInGuildList")) { + if (BDFDB.GuildUtils.is(e.instance.props.guild) && settings.changeInGuildList) { e.instance.props.guild = this.getGuildData(e.instance.props.guild.id); if (e.returnvalue) { - let data = BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id); + let data = changedGuilds[e.instance.props.guild.id]; if (data && (data.color3 || data.color4)) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: ["GuildTooltip", "BDFDB_TooltipContainer"]}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["GuildTooltip", "BDFDB_TooltipContainer"]}); if (index > -1) children[index] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { tooltipConfig: { type: "right", @@ -214,12 +215,12 @@ var EditServers = (_ => { } processBlobMask (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInGuildList")) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "NavItem"}); + if (settings.changeInGuildList) { + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "NavItem"}); if (index > -1 && children[index].props.to && children[index].props.to.pathname) { let guild = BDFDB.LibraryModules.GuildStore.getGuild((children[index].props.to.pathname.split("/channels/")[1] || "").split("/")[0]); if (guild) { - let data = BDFDB.DataUtils.load(this, "servers", guild.id); + let data = changedGuilds[guild.id]; if (data) { if (data.shortName) children[index].props.name = data.shortName.split("").join(" "); else if (data.name && data.ignoreCustomName) children[index].props.name = guild.name; @@ -230,14 +231,14 @@ var EditServers = (_ => { } processGuildAcronym (e) { - if (typeof e.returnvalue.props.children == "function" && BDFDB.DataUtils.get(this, "settings", "changeInGuildList")) { + if (typeof e.returnvalue.props.children == "function" && settings.changeInGuildList) { let pathname = BDFDB.ReactUtils.getValue(e.instance, "props.to.pathname"); - let data = pathname && BDFDB.DataUtils.load(this, "servers", (pathname.split("/channels/")[1] || "").split("/")[0]); + let data = pathname && changedGuilds[(pathname.split("/channels/")[1] || "").split("/")[0]]; if (data) { let renderChildren = e.returnvalue.props.children; e.returnvalue.props.children = (...args) => { let renderedChildren = renderChildren(...args); - let [children, index] = BDFDB.ReactUtils.findChildren(renderedChildren, {props:[["className", BDFDB.disCN.guildiconacronym]]}); + let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {props:[["className", BDFDB.disCN.guildiconacronym]]}); if (index > -1) { let fontGradient = BDFDB.ObjectUtils.is(data.color2); children[index].props.style = Object.assign({}, children[index].props.style, { @@ -257,7 +258,6 @@ var EditServers = (_ => { processGuildIconWrapper (e) { if (BDFDB.GuildUtils.is(e.instance.props.guild)) { - let settings = BDFDB.DataUtils.get(this, "settings"); if (e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.guildfolderguildicon) > -1) e.instance.props.guild = this.getGuildData(e.instance.props.guild.id, settings.changeInGuildList); else if (e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.listavatar) > -1) e.instance.props.guild = this.getGuildData(e.instance.props.guild.id, settings.changeInMutualGuilds); else e.instance.props.guild = this.getGuildData(e.instance.props.guild.id); @@ -266,9 +266,8 @@ var EditServers = (_ => { processGuildIcon (e) { if (BDFDB.GuildUtils.is(e.instance.props.guild) && e.instance.props.style && (!e.instance.props.style.backgroundImage || e.instance.props.style.backgroundImage == "none")) { - let data = BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id); + let data = changedGuilds[e.instance.props.guild.id]; if (data) { - let settings = BDFDB.DataUtils.get(this, "settings"); if (e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.guildfolderguildicon) > -1) this.changeGuildIcon(e, data, settings.changeInGuildList); else if (e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.listavatar) > -1 || BDFDB.ReactUtils.findConstructor(e.instance, "MutualGuild", {up: true})) this.changeGuildIcon(e, data, settings.changeInMutualGuilds); else this.changeGuildIcon(e, data); @@ -277,42 +276,37 @@ var EditServers = (_ => { } processMutualGuilds (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInMutualGuilds")) for (let i in e.instance.props.mutualGuilds) e.instance.props.mutualGuilds[i].guild = this.getGuildData(e.instance.props.mutualGuilds[i].guild.id); - } - - processFriendRow (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInMutualGuilds")) for (let i in e.instance.props.mutualGuilds) e.instance.props.mutualGuilds[i] = this.getGuildData(e.instance.props.mutualGuilds[i].id); + if (settings.changeInMutualGuilds) for (let i in e.instance.props.mutualGuilds) e.instance.props.mutualGuilds[i].guild = this.getGuildData(e.instance.props.mutualGuilds[i].guild.id); } processQuickSwitcher (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInQuickSwitcher")) for (let i in e.instance.props.results) if (e.instance.props.results[i].type == "GUILD") e.instance.props.results[i].record = this.getGuildData(e.instance.props.results[i].record.id); + if (settings.changeInQuickSwitcher) for (let i in e.instance.props.results) if (e.instance.props.results[i].type == "GUILD") e.instance.props.results[i].record = this.getGuildData(e.instance.props.results[i].record.id); } processQuickSwitchChannelResult (e) { - if (e.instance.props.channel && e.instance.props.channel.guild_id && BDFDB.DataUtils.get(this, "settings", "changeInQuickSwitcher")) { + if (e.instance.props.channel && e.instance.props.channel.guild_id && settings.changeInQuickSwitcher) { e.instance.props.children.props.children = this.getGuildData(e.instance.props.channel.guild_id).name; } } - processMessagesPopout (e) { - if (BDFDB.DataUtils.get(this, "settings", "changeInRecentMentions")) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "VerticalScroller"}); - if (index > -1 && children[index].props.children && BDFDB.ArrayUtils.is(children[index].props.children[0])) for (let i in children[index].props.children[0]) { - let divider = children[index].props.children[0][i]; - if (divider && divider.props && divider.props.className == BDFDB.disCN.messagespopoutchannelseparator) { - let channel = BDFDB.ReactUtils.findValue(children[index].props.children[0][parseInt(i)+1], "channel"); - if (BDFDB.ChannelUtils.isTextChannel(channel)) { - let [children2, index2] = BDFDB.ReactUtils.findChildren(divider, {props:[["className", BDFDB.disCN.messagespopoutguildname]]}); - if (index2 > -1) children2[index2].props.children = this.getGuildData(channel.guild_id).name; - } - } + processRecentsChannelHeader (e) { + if (settings.changeInRecentMentions && BDFDB.ArrayUtils.is(e.returnvalue.props.children)) { + for (let child of e.returnvalue.props.children) if (child && child.props && child.props.channel && child.type.displayName == "ChannelName") { + let oldType = child.type; + child.type = (...args) => { + let instance = oldType(...args); + let guildName = BDFDB.ReactUtils.findChild(instance, {props:[["className", BDFDB.disCN.recentmentionsguildname]]}); + if (guildName) guildName.props.children = (this.getGuildData(e.instance.props.channel.guild_id) || {}).name || guildName.props.children; + return instance; + }; + child.type.displayName = oldType.displayName; } } } processGuildSidebar (e) { if (e.instance.props.guild) { - let data = BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id); + let data = changedGuilds[e.instance.props.guild.id]; if (data) { if (data.removeBanner) e.instance.props.guild = new BDFDB.DiscordObjects.Guild(Object.assign({}, e.instance.props.guild, {banner: null})); else if (data.banner) e.instance.props.guild = new BDFDB.DiscordObjects.Guild(Object.assign({}, e.instance.props.guild, {banner: data.banner})); @@ -322,7 +316,6 @@ var EditServers = (_ => { processGuildHeader (e) { if (e.instance.props.guild) { - let settings = BDFDB.DataUtils.get(this, "settings"); if (settings.changeInGuildHeader) { e.instance.props.guild = this.getGuildData(e.instance.props.guild.id); let oldName = (BDFDB.LibraryModules.GuildStore.getGuild(e.instance.props.guild.id) || {}).name; @@ -340,7 +333,7 @@ var EditServers = (_ => { getGuildData (guildId, change = true) { let guild = BDFDB.LibraryModules.GuildStore.getGuild(guildId); if (!guild) return new BDFDB.DiscordObjects.Guild({}); - let data = change && BDFDB.DataUtils.load(this, "servers", guild.id); + let data = change && changedGuilds[guild.id]; if (data) { let newGuildObject = {}, nativeObject = new BDFDB.DiscordObjects.Guild(guild); for (let key in nativeObject) newGuildObject[key] = nativeObject[key]; @@ -374,11 +367,18 @@ var EditServers = (_ => { }); } } + + forceUpdateAll () { + changedGuilds = BDFDB.DataUtils.load(this, "servers"); + settings = BDFDB.DataUtils.get(this, "settings"); + + BDFDB.ModuleUtils.forceAllUpdates(this); + } openGuildSettingsModal (guildId) { let guild = BDFDB.LibraryModules.GuildStore.getGuild(guildId); if (!guild) return; - let data = BDFDB.DataUtils.load(this, "servers", guild.id) || {}; + let data = changedGuilds[guild.id] || {}; let currentIgnoreCustomNameState = data.ignoreCustomName; @@ -614,7 +614,7 @@ var EditServers = (_ => { let changed = false; if (Object.keys(data).every(key => !data[key]) && (changed = true)) BDFDB.DataUtils.remove(this, "servers", guild.id); else if (!BDFDB.equals(olddata, data) && (changed = true)) BDFDB.DataUtils.save(data, this, "servers", guild.id); - if (changed) BDFDB.ModuleUtils.forceAllUpdates(this);; + if (changed) this.forceUpdateAll();; } }] }); diff --git a/.config/BetterDiscord/plugins/NotificationSounds.config.json b/.config/BetterDiscord/plugins/NotificationSounds.config.json index 5101ee4..5b47690 100644 --- a/.config/BetterDiscord/plugins/NotificationSounds.config.json +++ b/.config/BetterDiscord/plugins/NotificationSounds.config.json @@ -53,7 +53,7 @@ } }, "changelog": { - "currentversion": "3.4.5" + "currentversion": "3.4.6" }, "choices": { "message1": { diff --git a/.config/BetterDiscord/plugins/NotificationSounds.plugin.js b/.config/BetterDiscord/plugins/NotificationSounds.plugin.js index 8e48187..c90246f 100644 --- a/.config/BetterDiscord/plugins/NotificationSounds.plugin.js +++ b/.config/BetterDiscord/plugins/NotificationSounds.plugin.js @@ -2,6 +2,7 @@ var NotificationSounds = (_ => { var audios, choices, firedEvents, repatchIncoming, callAudio; + const removeAllKey = "REMOVE_ALL_BDFDB_DEVILBRO_DO_NOT_COPY"; const settingsAudio = new Audio(); @@ -68,7 +69,7 @@ var NotificationSounds = (_ => { return class NotificationSounds { getName () {return "NotificationSounds";} - getVersion () {return "3.4.5";} + getVersion () {return "3.4.6";} getAuthor () {return "DevilBro";} @@ -76,7 +77,7 @@ var NotificationSounds = (_ => { constructor () { this.changelog = { - "fixed":[["Mention Sound","No longer plays when the server/channel has message notifications completely disabled"]] + "improved":[["Song Deletion","You can now delete single songs, whole categories or all songs"]] }; this.patchedModules = { @@ -94,8 +95,121 @@ var NotificationSounds = (_ => { getSettingsPanel (collapseStates = {}) { if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; - let settingsPanel = {node: null}, settingsItems = []; + let createSoundCard = type => { + return [ + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { + className: BDFDB.disCN.marginbottom8, + align: BDFDB.LibraryComponents.Flex.Align.CENTER, + direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL, + children: [ + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, { + label: types[type].name + }), + types[type].focus != null ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { + type: "Switch", + mini: true, + grow: 0, + label: "Mute when Channel focused:", + value: choices[type].focus, + onChange: value => { + choices[type].focus = value; + this.saveChoice(type, false); + } + }) : null, + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { + type: "Switch", + mini: true, + grow: 0, + label: "Mute in DnD:", + value: choices[type].mute, + onChange: value => { + choices[type].mute = value; + this.saveChoice(type, false); + } + }) + ].filter(n => n) + }), + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { + className: BDFDB.disCN.marginbottom8, + children: [ + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { + grow: 0, + shrink: 0, + basis: "31%", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { + title: "Category", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, { + value: choices[type].category, + options: Object.keys(audios).map(name => ({value:name, label:name})), + searchable: true, + onChange: category => { + choices[type].category = category.value; + choices[type].song = Object.keys(audios[category.value] || {})[0]; + choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src; + this.saveChoice(type, true); + BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); + } + }) + }) + }), + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { + grow: 0, + shrink: 0, + basis: "31%", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { + title: "Song", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, { + value: choices[type].song, + options: Object.keys(audios[choices[type].category] || {}).map(name => ({value:name, label:name})), + searchable: true, + onChange: song => { + choices[type].song = song.value; + choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src; + this.saveChoice(type, true); + BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); + } + }) + }) + }), + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { + grow: 0, + shrink: 0, + basis: "31%", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { + title: "Volume", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Slider, { + defaultValue: choices[type].volume, + digits: 1, + onValueRender: value => { + return value + "%"; + }, + onValueChange: value => { + choices[type].volume = value; + this.saveChoice(type, true); + } + }) + }) + }) + ] + }), + BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { + className: BDFDB.disCN.marginbottom8 + }) + ]; + }; + + let successSavedAudio = data => { + BDFDB.NotificationUtils.toast(`Song ${data.song} was added to category ${data.category}.`, {type:"success"}); + if (!audios[data.category]) audios[data.category] = {}; + audios[data.category][data.song] = data.source; + BDFDB.DataUtils.save(audios, this, "audios"); + BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); + + }; + + let settingsPanel, settingsItems = []; + settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { title: "Add new Song", collapseStates: collapseStates, @@ -145,20 +259,20 @@ var NotificationSounds = (_ => { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, { style: {marginBottom: 1}, onClick: _ => { - for (let input of settingsPanel.node.querySelectorAll(".input-newsong " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new song.", {type:"danger"}); - let category = settingsPanel.node.querySelector(".input-category " + BDFDB.dotCN.input).value.trim(); - let song = settingsPanel.node.querySelector(".input-song " + BDFDB.dotCN.input).value.trim(); - let source = settingsPanel.node.querySelector(".input-source " + BDFDB.dotCN.input).value.trim(); + for (let input of settingsPanel.querySelectorAll(".input-newsong " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new song.", {type:"danger"}); + let category = settingsPanel.querySelector(".input-category " + BDFDB.dotCN.input).value.trim(); + let song = settingsPanel.querySelector(".input-song " + BDFDB.dotCN.input).value.trim(); + let source = settingsPanel.querySelector(".input-source " + BDFDB.dotCN.input).value.trim(); if (source.indexOf("http") == 0) BDFDB.LibraryRequires.request(source, (error, response, result) => { if (response) { let type = response.headers["content-type"]; - if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) return this.successSavedAudio(settingsPanel.node, collapseStates, {category, song, source}); + if (type && (type.indexOf("octet-stream") > -1 || type.indexOf("audio") > -1 || type.indexOf("video") > -1)) return successSavedAudio({category, song, source}); } BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"}); }); else BDFDB.LibraryRequires.fs.readFile(source, (error, response) => { if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"}); - else return this.successSavedAudio(settingsPanel.node, collapseStates, {category, song, source:`data:audio/mpeg;base64,${response.toString("base64")}`}); + else return successSavedAudio({category, song, source:`data:audio/mpeg;base64,${response.toString("base64")}`}); }); }, children: BDFDB.LanguageUtils.LanguageStrings.SAVE @@ -171,92 +285,43 @@ var NotificationSounds = (_ => { title: "Implemented Sounds", collapseStates: collapseStates, dividertop: true, - children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => typedata.implemented)).map(type => this.createSoundCard(type, settingsPanel, collapseStates)).flat(10).filter(n => n) + children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n) })); settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { title: "Unimplemented Sounds", collapseStates: collapseStates, dividertop: true, - children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => !typedata.implemented)).map(type => this.createSoundCard(type, settingsPanel, collapseStates)).flat(10).filter(n => n) + children: Object.keys(BDFDB.ObjectUtils.filter(types, typedata => !typedata.implemented)).map(type => createSoundCard(type)).flat(10).filter(n => n) })); + + let removeableAudios = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios).filter(name => !defaultAudios[name]).map(name => ({value:name, label:name}))); + let removeableSongs = {}; + for (let audio of removeableAudios) removeableSongs[audio.value] = [{value:removeAllKey, label:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL}].concat(Object.keys(audios[audio.value] || {}).map(name => ({value:name, label:name}))); settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, { title: "Remove Songs", collapseStates: collapseStates, dividertop: true, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Button", - className: BDFDB.disCN.marginbottom8, - color: BDFDB.LibraryComponents.Button.Colors.RED, - label: "Delete all added songs", - onClick: _ => { - BDFDB.ModalUtils.confirm(this, "Are you sure you want to delete all added songs?", _ => { - BDFDB.DataUtils.remove(this, "choices"); - BDFDB.DataUtils.remove(this, "audios"); - this.loadAudios(); - this.loadChoices(); - BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel.node, collapseStates); - }); - }, - children: BDFDB.LanguageUtils.LanguageStrings.DELETE - }) - })); - - return settingsPanel.node = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); - } - - createSoundCard (type, settingsPanel, collapseStates) { - return [ - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { - className: BDFDB.disCN.marginbottom8, - align: BDFDB.LibraryComponents.Flex.Align.CENTER, - direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL, - children: [ - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, { - label: types[type].name - }), - types[type].focus != null ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Switch", - mini: true, - grow: 0, - label: "Mute when Channel focused:", - value: choices[type].focus, - onChange: value => { - choices[type].focus = value; - this.saveChoice(type, false); - } - }) : null, - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, { - type: "Switch", - mini: true, - grow: 0, - label: "Mute in DnD:", - value: choices[type].mute, - onChange: value => { - choices[type].mute = value; - this.saveChoice(type, false); - } - }) - ].filter(n => n) - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { - className: BDFDB.disCN.marginbottom8, + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { + className: BDFDB.disCN.margintop4, + align: BDFDB.LibraryComponents.Flex.Align.END, children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { grow: 0, shrink: 0, - basis: "31%", + basis: "35%", children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: "Category", children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, { - value: choices[type].category, - options: Object.keys(audios).map(name => {return {value:name, label:name}}), + key: "REMOVE_CATEGORY", + value: removeAllKey, + options: removeableAudios, searchable: true, - onChange: category => { - choices[type].category = category.value; - choices[type].song = Object.keys(audios[category.value] || {})[0]; - choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src; - this.saveChoice(type, true); - BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel.node, collapseStates); + onChange: (category, instance) => { + let songSelectIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}), {key:"REMOVE_SONG"}); + if (songSelectIns && removeableSongs[category.value]) { + songSelectIns.props.options = removeableSongs[category.value]; + BDFDB.ReactUtils.forceUpdate(songSelectIns); + } } }) }) @@ -264,47 +329,59 @@ var NotificationSounds = (_ => { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { grow: 0, shrink: 0, - basis: "31%", + basis: "35%", children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { title: "Song", children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, { - value: choices[type].song, - options: Object.keys(audios[choices[type].category] || {}).map(name => {return {value:name, label:name}}), - searchable: true, - onChange: song => { - choices[type].song = song.value; - choices[type].src = audios[choices[type].category][choices[type].song] || types[type].src; - this.saveChoice(type, true); - BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel.node, collapseStates); - } + key: "REMOVE_SONG", + value: removeAllKey, + options: removeableSongs[removeAllKey], + searchable: true }) }) }), BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, { grow: 0, shrink: 0, - basis: "31%", - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { - title: "Volume", - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Slider, { - defaultValue: choices[type].volume, - digits: 1, - onValueRender: value => { - return value + "%"; - }, - onValueChange: value => { - choices[type].volume = value; - this.saveChoice(type, true); + basis: "25%", + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, { + style: {marginBottom: 1}, + color: BDFDB.LibraryComponents.Button.Colors.RED, + onClick: (event, instance) => { + let wrapperIns = BDFDB.ReactUtils.findOwner(instance, {name:["BDFDB_Modal", "BDFDB_SettingsPanel"], up:true}); + let categorySelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_CATEGORY"}); + let songSelectIns = BDFDB.ReactUtils.findOwner(wrapperIns, {key:"REMOVE_SONG"}); + if (categorySelectIns && songSelectIns) { + let songAmount = 0; + let catAll = categorySelectIns.props.value == removeAllKey; + let songAll = songSelectIns.props.value == removeAllKey; + if (catAll) songAmount = BDFDB.ArrayUtils.sum(Object.keys(audios).filter(name => !defaultAudios[name]).map(category => Object.keys(audios[category] || {}).length)); + else if (songAll) songAmount = Object.keys(audios[categorySelectIns.props.value] || {}).length; + else if (audios[categorySelectIns.props.value][songSelectIns.props.value]) songAmount = 1; + + if (songAmount) BDFDB.ModalUtils.confirm(this, `Are you sure you want to delete ${songAmount} added song${songAmount == 1 ? "" : "s"}?`, _ => { + if (catAll) BDFDB.DataUtils.remove(this, "audios"); + else if (songAll) BDFDB.DataUtils.remove(this, "audios", categorySelectIns.props.value); + else { + delete audios[categorySelectIns.props.value][songSelectIns.props.value]; + if (BDFDB.ObjectUtils.isEmpty(audios[categorySelectIns.props.value])) delete audios[categorySelectIns.props.value]; + BDFDB.DataUtils.save(audios, this, "audios"); + } + this.loadAudios(); + this.loadChoices(); + BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); + }); + else BDFDB.NotificationUtils.toast("No songs to delete.", {type:"danger"}); } - }) + }, + children: BDFDB.LanguageUtils.LanguageStrings.DELETE }) }) ] - }), - BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { - className: BDFDB.disCN.marginbottom8 }) - ]; + })); + + return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems); } // Legacy @@ -453,7 +530,7 @@ var NotificationSounds = (_ => { } processShakeable (e) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "IncomingCalls"}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "IncomingCalls"}); if (index > -1) { if (repatchIncoming) { children[index] = null; @@ -465,15 +542,6 @@ var NotificationSounds = (_ => { else children[index] = BDFDB.ReactUtils.createElement(children[index].type, {}); } } - - successSavedAudio (settingsPanel, collapseStates, data) { - BDFDB.NotificationUtils.toast(`Song ${data.song} was added to category ${data.category}.`, {type:"success"}); - if (!audios[data.category]) audios[data.category] = {}; - audios[data.category][data.song] = data.source; - BDFDB.DataUtils.save(audios, this, "audios"); - BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates); - - } forceUpdateAll () { repatchIncoming = true; diff --git a/.config/BetterDiscord/plugins/PinDMs.plugin.js b/.config/BetterDiscord/plugins/PinDMs.plugin.js index 4c5b002..1ec09ea 100644 --- a/.config/BetterDiscord/plugins/PinDMs.plugin.js +++ b/.config/BetterDiscord/plugins/PinDMs.plugin.js @@ -1,23 +1,21 @@ //META{"name":"PinDMs","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/PinDMs","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PinDMs/PinDMs.plugin.js"}*// var PinDMs = (_ => { - let hoveredCategory, draggedCategory, releasedCategory; - let hoveredChannel, draggedChannel, releasedChannel; + var hoveredCategory, draggedCategory, releasedCategory; + var hoveredChannel, draggedChannel, releasedChannel; + + var settings = {}; return class PinDMs { getName () {return "PinDMs";} - getVersion () {return "1.7.2";} + getVersion () {return "1.7.3";} getAuthor () {return "DevilBro";} getDescription () {return "Allows you to pin DMs, making them appear at the top of your DMs/Guild-list.";} - constructor () { - this.changelog = { - "fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]] - }; - + constructor () { this.patchedModules = { before: { PrivateChannelsList: "render", @@ -110,7 +108,6 @@ var PinDMs = (_ => { getSettingsPanel () { if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; - let settings = BDFDB.DataUtils.get(this, "settings"); let settingsPanel, settingsItems = [], innerItems = []; for (let key in settings) (!this.defaults.settings[key].inner ? settingsItems : innerItems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, { @@ -181,7 +178,7 @@ var PinDMs = (_ => { if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { this.stopping = true; - this.forceUpdateAll(true); + this.forceUpdateAll(); let unreadDMsInstance = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"UnreadDMs", unlimited:true}); if (unreadDMsInstance) { @@ -197,7 +194,7 @@ var PinDMs = (_ => { // Begin of own functions - onSettingsClosed (instance, wrapper, returnvalue) { + onSettingsClosed () { if (this.SettingsUpdated) { delete this.SettingsUpdated; this.forceUpdateAll(); @@ -357,136 +354,134 @@ var PinDMs = (_ => { } return rowHeightFunc(...args); }; - } - - let settings = BDFDB.DataUtils.get(this, "settings"); - BDFDB.ModuleUtils.unpatch(this, e.instance, "renderSection"); - BDFDB.ModuleUtils.patch(this, e.instance, "renderSection", {after: e2 => { - if (e2.methodArguments[0].section != 0 && e2.methodArguments[0].section != e.instance.props.listRef.current.props.sections.length - 1) { - let category = categories[e2.methodArguments[0].section - 1]; - if (category && draggedCategory != category.id) { - let color = BDFDB.ColorUtils.convert(category.color, "RGBA"); - let foundDMs = this.filterDMs(category.dms); - let unreadAmount = settings.showCategoryUnread && BDFDB.ArrayUtils.sum(foundDMs.map(id => BDFDB.LibraryModules.UnreadChannelUtils.getMentionCount(id))); - e2.returnValue = [ - BDFDB.ReactUtils.createElement("h2", { - className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.dmchannelheadercontainer, BDFDB.disCN._pindmspinnedchannelsheadercontainer, category.collapsed && BDFDB.disCN._pindmspinnedchannelsheadercollapsed, color && BDFDB.disCN._pindmspinnedchannelsheadercolored, BDFDB.disCN.namecontainernamecontainer), - categoryId: category.id, - onMouseDown: event => { - event = event.nativeEvent || event; - let node = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmspinnedchannelsheadercontainer, event.target).cloneNode(true); - let mousemove = event2 => { - if (Math.sqrt((event.pageX - event2.pageX)**2) > 20 || Math.sqrt((event.pageY - event2.pageY)**2) > 20) { - BDFDB.ListenerUtils.stopEvent(event); - draggedCategory = category.id; - this.updateContainer("dmCategories"); - let dragPreview = this.createDragPreview(node, event2); + + let renderSection = e.returnvalue.props.renderSection; + e.returnvalue.props.renderSection = (...args) => { + if (args[0].section != 0 && args[0].section != e.returnvalue.props.sections.length - 1) { + let category = categories[args[0].section - 1]; + if (category && draggedCategory != category.id) { + let color = BDFDB.ColorUtils.convert(category.color, "RGBA"); + let foundDMs = this.filterDMs(category.dms); + let unreadAmount = settings.showCategoryUnread && BDFDB.ArrayUtils.sum(foundDMs.map(id => BDFDB.LibraryModules.UnreadChannelUtils.getMentionCount(id))); + return [ + BDFDB.ReactUtils.createElement("h2", { + className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.dmchannelheadercontainer, BDFDB.disCN._pindmspinnedchannelsheadercontainer, category.collapsed && BDFDB.disCN._pindmspinnedchannelsheadercollapsed, color && BDFDB.disCN._pindmspinnedchannelsheadercolored, BDFDB.disCN.namecontainernamecontainer), + categoryId: category.id, + onMouseDown: event => { + event = event.nativeEvent || event; + let node = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmspinnedchannelsheadercontainer, event.target).cloneNode(true); + let mousemove = event2 => { + if (Math.sqrt((event.pageX - event2.pageX)**2) > 20 || Math.sqrt((event.pageY - event2.pageY)**2) > 20) { + BDFDB.ListenerUtils.stopEvent(event); + draggedCategory = category.id; + this.updateContainer("dmCategories"); + let dragPreview = this.createDragPreview(node, event2); + document.removeEventListener("mousemove", mousemove); + document.removeEventListener("mouseup", mouseup); + let dragging = event3 => { + this.updateDragPreview(dragPreview, event3); + let placeholder = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmsdmchannelplaceholder, event3.target); + let categoryNode = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmspinnedchannelsheadercontainer, placeholder ? placeholder.previousSibling : event3.target); + let maybeHoveredCategory = categoryNode && categoryNode.getAttribute("categoryId"); + let update = maybeHoveredCategory != hoveredCategory; + if (maybeHoveredCategory) hoveredCategory = maybeHoveredCategory; + else hoveredCategory = null; + if (update) this.updateContainer("dmCategories"); + }; + let releasing = event3 => { + BDFDB.DOMUtils.remove(dragPreview); + if (hoveredCategory) releasedCategory = hoveredCategory; + else draggedCategory = null; + hoveredCategory = null; + this.updateContainer("dmCategories"); + document.removeEventListener("mousemove", dragging); + document.removeEventListener("mouseup", releasing); + }; + document.addEventListener("mousemove", dragging); + document.addEventListener("mouseup", releasing); + } + }; + let mouseup = _ => { document.removeEventListener("mousemove", mousemove); document.removeEventListener("mouseup", mouseup); - let dragging = event3 => { - this.updateDragPreview(dragPreview, event3); - let placeholder = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmsdmchannelplaceholder, event3.target); - let categoryNode = BDFDB.DOMUtils.getParent(BDFDB.dotCN._pindmspinnedchannelsheadercontainer, placeholder ? placeholder.previousSibling : event3.target); - let maybeHoveredCategory = categoryNode && categoryNode.getAttribute("categoryId"); - let update = maybeHoveredCategory != hoveredCategory; - if (maybeHoveredCategory) hoveredCategory = maybeHoveredCategory; - else hoveredCategory = null; - if (update) this.updateContainer("dmCategories"); - }; - let releasing = event3 => { - BDFDB.DOMUtils.remove(dragPreview); - if (hoveredCategory) releasedCategory = hoveredCategory; - else draggedCategory = null; - hoveredCategory = null; - this.updateContainer("dmCategories"); - document.removeEventListener("mousemove", dragging); - document.removeEventListener("mouseup", releasing); - }; - document.addEventListener("mousemove", dragging); - document.addEventListener("mouseup", releasing); + }; + document.addEventListener("mousemove", mousemove); + document.addEventListener("mouseup", mouseup); + }, + onClick: _ => { + if (foundDMs.length || !category.collapsed) { + category.collapsed = !category.collapsed; + BDFDB.DataUtils.save(category, this, "dmCategories", category.id); + this.updateContainer("dmCategories"); } - }; - let mouseup = _ => { - document.removeEventListener("mousemove", mousemove); - document.removeEventListener("mouseup", mouseup); - }; - document.addEventListener("mousemove", mousemove); - document.addEventListener("mouseup", mouseup); - }, - onClick: _ => { - if (foundDMs.length || !category.collapsed) { - category.collapsed = !category.collapsed; - BDFDB.DataUtils.save(category, this, "dmCategories", category.id); - this.updateContainer("dmCategories"); - } - }, - onContextMenu: event => { - BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: [ - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: BDFDB.LanguageUtils.LanguageStrings.CATEGORY_SETTINGS, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "category-settings"), - action: event2 => { - BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, event2.target)); - this.openCategorySettingsModal(category, "dmCategories"); - } - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: BDFDB.LanguageUtils.LanguageStrings.DELETE_CATEGORY, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "remove-category"), - color: BDFDB.LibraryComponents.MenuItems.Colors.DANGER, - action: event2 => { - BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, event2.target)); - BDFDB.DataUtils.remove(this, "dmCategories", category.id); - this.updateContainer("dmCategories"); - } + }, + onContextMenu: event => { + BDFDB.ContextMenuUtils.open(this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { + children: [ + BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: BDFDB.LanguageUtils.LanguageStrings.CATEGORY_SETTINGS, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "category-settings"), + action: event2 => { + this.openCategorySettingsModal(category, "dmCategories"); + } + }), + BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: BDFDB.LanguageUtils.LanguageStrings.DELETE_CATEGORY, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "remove-category"), + color: BDFDB.LibraryComponents.MenuItems.Colors.DANGER, + action: event2 => { + BDFDB.DataUtils.remove(this, "dmCategories", category.id); + this.updateContainer("dmCategories"); + } + }) + ] + })); + }, + children: [ + BDFDB.ObjectUtils.is(color) ? BDFDB.ReactUtils.createElement("span", { + className: BDFDB.disCN.dmchannelheadertext, + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextGradientElement, { + gradient: BDFDB.ColorUtils.createGradient(color), + children: category.name + }) + }) : BDFDB.ReactUtils.createElement("span", { + className: BDFDB.disCN.dmchannelheadertext, + style: {color: color}, + children: category.name, + }), + unreadAmount ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, { + className: BDFDB.disCN._pindmspinnedchannelsheaderamount, + count: unreadAmount, + style: {backgroundColor: BDFDB.DiscordConstants.Colors.STATUS_RED} + }) : null, + settings.showCategoryAmount ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, { + className: BDFDB.disCN._pindmspinnedchannelsheaderamount, + count: foundDMs.length, + style: {backgroundColor: BDFDB.DiscordConstants.Colors.BRAND} + }) : null, + BDFDB.ReactUtils.createElement("div", { + className: BDFDB.disCNS._pindmspinnedchannelsheaderarrow + BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable, + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { + className: BDFDB.disCNS._pindmspinnedchannelsheaderarrow + BDFDB.disCN.channelheadericon, + nativeClass: true, + iconSVG: `<svg width="24" height="24" viewBox="4 4 16 16"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M16.59 8.59004L12 13.17L7.41 8.59004L6 10L12 16L18 10L16.59 8.59004Z"></path></svg>` }) - ] - })); - }, - children: [ - BDFDB.ObjectUtils.is(color) ? BDFDB.ReactUtils.createElement("span", { - className: BDFDB.disCN.dmchannelheadertext, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextGradientElement, { - gradient: BDFDB.ColorUtils.createGradient(color), - children: category.name - }) - }) : BDFDB.ReactUtils.createElement("span", { - className: BDFDB.disCN.dmchannelheadertext, - style: {color: color}, - children: category.name, - }), - unreadAmount ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, { - className: BDFDB.disCN._pindmspinnedchannelsheaderamount, - count: unreadAmount, - style: {backgroundColor: BDFDB.DiscordConstants.Colors.STATUS_RED} - }) : null, - settings.showCategoryAmount ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, { - className: BDFDB.disCN._pindmspinnedchannelsheaderamount, - count: foundDMs.length, - style: {backgroundColor: BDFDB.DiscordConstants.Colors.BRAND} - }) : null, - BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS._pindmspinnedchannelsheaderarrow + BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable, - children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { - className: BDFDB.disCNS._pindmspinnedchannelsheaderarrow + BDFDB.disCN.channelheadericon, - nativeClass: true, - iconSVG: `<svg width="24" height="24" viewBox="4 4 16 16"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M16.59 8.59004L12 13.17L7.41 8.59004L6 10L12 16L18 10L16.59 8.59004Z"></path></svg>` }) + ].filter(n => n) + }), + hoveredChannel == "header_" + category.id && BDFDB.ReactUtils.createElement("div", { + className: BDFDB.disCNS.dmchannel + BDFDB.disCNS._pindmsdmchannelpinned + BDFDB.disCNS._pindmsdmchannelplaceholder + BDFDB.disCN.namecontainernamecontainer, + children: BDFDB.ReactUtils.createElement("div", { + className: BDFDB.disCN.namecontainerlayout }) - ].filter(n => n) - }), - hoveredChannel == "header_" + category.id && BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCNS.dmchannel + BDFDB.disCNS._pindmsdmchannelpinned + BDFDB.disCNS._pindmsdmchannelplaceholder + BDFDB.disCN.namecontainernamecontainer, - children: BDFDB.ReactUtils.createElement("div", { - className: BDFDB.disCN.namecontainerlayout }) - }) - ].filter(n => n); + ].filter(n => n); + } + else return null; } - else e2.returnValue = null; - } - }}, {force: true, noCache: true}); + else return renderSection(...args); + }; + } let pinnedIds = BDFDB.ObjectUtils.toArray(e.instance.props.pinnedChannelIds).reverse(); BDFDB.ModuleUtils.unpatch(this, e.instance, "renderDM"); @@ -552,11 +547,11 @@ var PinDMs = (_ => { BDFDB.ReactUtils.forceUpdate(e.instance); } if (draggedChannel) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {filter: child => BDFDB.ReactUtils.getValue(child, "props.channel.id") == draggedChannel}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {filter: child => BDFDB.ReactUtils.getValue(child, "props.channel.id") == draggedChannel}); children.splice(index, 1); } if (this.hoveredChannel) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {filter: child => BDFDB.ReactUtils.getValue(child, "props.channel.id") == this.hoveredChannel}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {filter: child => BDFDB.ReactUtils.getValue(child, "props.channel.id") == this.hoveredChannel}); children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", { className: BDFDB.disCNS.guildouter + BDFDB.disCN._pindmsrecentplaceholder, children: BDFDB.ReactUtils.createElement("div", { @@ -712,7 +707,7 @@ var PinDMs = (_ => { BDFDB.ModuleUtils.forceAllUpdates(this, "PrivateChannelsList"); } if (e.returnvalue && this.isPinned(e.instance.props.channel.id, "pinnedRecents") && BDFDB.DataUtils.get(this, "settings", "showPinIcon")) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:"BlobMask"}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name:"BlobMask"}); if (index > -1) children[index].props.upperLeftBadge = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.IconBadge, { className: BDFDB.disCN.guildiconbadge, disableColor: true, @@ -883,7 +878,9 @@ var PinDMs = (_ => { return this.sortDMsByTime(existingDMs, type); } - forceUpdateAll (stopped) { + forceUpdateAll () { + settings = BDFDB.DataUtils.get(this, "settings"); + BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"FluxContainer(PrivateChannels)", all:true, unlimited:true})); BDFDB.ModuleUtils.forceAllUpdates(this); } diff --git a/.config/BetterDiscord/plugins/SendLargeMessages.plugin.js b/.config/BetterDiscord/plugins/SendLargeMessages.plugin.js index 3827ee2..110667b 100644 --- a/.config/BetterDiscord/plugins/SendLargeMessages.plugin.js +++ b/.config/BetterDiscord/plugins/SendLargeMessages.plugin.js @@ -1,10 +1,12 @@ //META{"name":"SendLargeMessages","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SendLargeMessages","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SendLargeMessages/SendLargeMessages.plugin.js"}*// var SendLargeMessages = (_ => { + var messageDelay = 1000; //changing at own risk, might result in bans or mutes + return class SendLargeMessages { getName () {return "SendLargeMessages";} - getVersion () {return "1.6.4";} + getVersion () {return "1.6.5";} getAuthor () {return "DevilBro";} @@ -23,8 +25,6 @@ var SendLargeMessages = (_ => { } initConstructor () { - this.messageDelay = 1000; //changing at own risk, might result in bans or mutes - this.css = ` .${this.name}-modal textarea { height: 50vh; @@ -88,7 +88,7 @@ var SendLargeMessages = (_ => { BDFDB.TimeUtils.timeout(_ => { e2.originalMethod(message); if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"}); - }, this.messageDelay * i); + }, messageDelay * i); }); return Promise.resolve({ shouldClear: true, @@ -101,7 +101,7 @@ var SendLargeMessages = (_ => { processChannelTextAreaContainer (e) { if (e.returnvalue.ref && e.returnvalue.ref.current && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, e.returnvalue.ref.current)) { - let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name: "SlateCharacterCount"}); + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SlateCharacterCount"}); if (index > -1) { let text = BDFDB.LibraryModules.SlateSelectionUtils.serialize(children[index].props.document, "raw"); if (text.length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) children[index] = BDFDB.ReactUtils.createElement("div", { @@ -123,15 +123,15 @@ var SendLargeMessages = (_ => { formatText (text) { text = text.replace(/\t/g, " "); - let longwords = text.match(/[\S]{1800,}/gm); - if (longwords) for (let longword of longwords) { + let longWords = text.match(new RegExp(`[^ ]{${BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)},}`, "gm")); + if (longWords) for (let longWord of longWords) { let count1 = 0; - let shortwords = []; - longword.split("").forEach(c => { - if (shortwords[count1] && shortwords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)) count1++; - shortwords[count1] = shortwords[count1] ? shortwords[count1] + c : c; + let shortWords = []; + longWord.split("").forEach(c => { + if (shortWords[count1] && (shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) || (c == "\n" && shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) - 100))) count1++; + shortWords[count1] = shortWords[count1] ? shortWords[count1] + c : c; }); - text = text.replace(longword, shortwords.join(" ")); + text = text.replace(longWord, shortWords.join(" ")); } let messages = []; let count2 = 0; @@ -163,7 +163,6 @@ var SendLargeMessages = (_ => { messages[j] = messages[j] + insertCodeLine; } } - return messages; } diff --git a/.config/BetterDiscord/themes/MinimalCord.theme.css b/.config/BetterDiscord/themes/MinimalCord.theme.css index 87e66f9..1350f84 100644 --- a/.config/BetterDiscord/themes/MinimalCord.theme.css +++ b/.config/BetterDiscord/themes/MinimalCord.theme.css @@ -88,7 +88,7 @@ } .da-username { - filter: saturate(0.4) brightness(2); + filter: saturate(0.4) brightness(1.5); } .da-itemCard > div > div { diff --git a/.config/BetterDiscord/themes/pywal.theme.css b/.config/BetterDiscord/themes/pywal.theme.css index e4f70a2..2f0f6b5 100644 --- a/.config/BetterDiscord/themes/pywal.theme.css +++ b/.config/BetterDiscord/themes/pywal.theme.css @@ -6,70 +6,70 @@ */ :root { - --pywal-shade0: #2A2C2D; - --pywal-shade1: #323536; - --pywal-shade2: #36393B; - --pywal-shade3: #3B3E3F; - --pywal-shade4: #383F41; + --pywal-shade0: #15181E; + --pywal-shade1: #191C24; + --pywal-shade2: #1B1F27; + --pywal-shade3: #1D212A; + --pywal-shade4: #161F31; - --accent: 228, 182, 149; + --accent: 60, 75, 105; - --pywal-serverside: #191919; - --pywal-serverfolder-transparent: hsla(0, 0%, 9.9%, 0.55); + --pywal-serverside: #131416; + --pywal-serverfolder-transparent: hsla(220, 6.7%, 7.9%, 0.75); - --pywal-bg0: #1C1C1C; - --pywal-bg1: #222222; - --pywal-bg2: #272727; - --pywal-bg3: #2D2D2D; + --pywal-bg0: #151618; + --pywal-bg1: #191A1D; + --pywal-bg2: #1D1F22; + --pywal-bg3: #222326; - --pywal-color0: #1c1c1c; - --pywal-color1: #616c71; - --pywal-color2: #7f8485; - --pywal-color3: #9099ba; - --pywal-color4: #c79c95; - --pywal-color5: #9fc0c8; - --pywal-color6: #e4b695; - --pywal-color7: #c6c6c6; - --pywal-color8: #545454; - --pywal-color9: #616c71; - --pywal-color10: #7f8485; - --pywal-color11: #9099ba; - --pywal-color12: #c79c95; - --pywal-color13: #9fc0c8; - --pywal-color14: #e4b695; - --pywal-color15: #c6c6c6; + --pywal-color0: #151618; + --pywal-color1: #131e35; + --pywal-color2: #222323; + --pywal-color3: #1d2841; + --pywal-color4: #2a2929; + --pywal-color5: #2a313f; + --pywal-color6: #303d57; + --pywal-color7: #c4c4c5; + --pywal-color8: #4f5051; + --pywal-color9: #131e35; + --pywal-color10: #222323; + --pywal-color11: #1d2841; + --pywal-color12: #2a2929; + --pywal-color13: #2a313f; + --pywal-color14: #303d57; + --pywal-color15: #c4c4c5; - --pywal-readable-color0: #6B6B6B; - --pywal-readable-color1: #616C71; - --pywal-readable-color2: #7F8485; - --pywal-readable-color3: #9099BA; - --pywal-readable-color4: #C79C95; - --pywal-readable-color5: #9FC0C8; - --pywal-readable-color6: #E4B695; - --pywal-readable-color7: #C6C6C6; - --pywal-readable-color8: #545454; - --pywal-readable-color9: #616C71; - --pywal-readable-color10: #7F8485; - --pywal-readable-color11: #9099BA; - --pywal-readable-color12: #C79C95; - --pywal-readable-color13: #9FC0C8; - --pywal-readable-color14: #E4B695; - --pywal-readable-color15: #C6C6C6; + --pywal-readable-color0: #676B73; + --pywal-readable-color1: #415D96; + --pywal-readable-color2: #666969; + --pywal-readable-color3: #465A89; + --pywal-readable-color4: #656363; + --pywal-readable-color5: #505B71; + --pywal-readable-color6: #3C4B69; + --pywal-readable-color7: #C4C4C5; + --pywal-readable-color8: #4F5051; + --pywal-readable-color9: #415D96; + --pywal-readable-color10: #666969; + --pywal-readable-color11: #465A89; + --pywal-readable-color12: #656363; + --pywal-readable-color13: #505B71; + --pywal-readable-color14: #3C4B69; + --pywal-readable-color15: #C4C4C5; - --pywal-readableOn-color0: #c6c6c6; - --pywal-readableOn-color1: #c6c6c6; - --pywal-readableOn-color2: #1c1c1c; - --pywal-readableOn-color3: #1c1c1c; - --pywal-readableOn-color4: #1c1c1c; - --pywal-readableOn-color5: #1c1c1c; - --pywal-readableOn-color6: #1c1c1c; - --pywal-readableOn-color7: #1c1c1c; - --pywal-readableOn-color8: #c6c6c6; - --pywal-readableOn-color9: #c6c6c6; - --pywal-readableOn-color10: #1c1c1c; - --pywal-readableOn-color11: #1c1c1c; - --pywal-readableOn-color12: #1c1c1c; - --pywal-readableOn-color13: #1c1c1c; - --pywal-readableOn-color14: #1c1c1c; - --pywal-readableOn-color15: #1c1c1c; + --pywal-readableOn-color0: #c4c4c5; + --pywal-readableOn-color1: #c4c4c5; + --pywal-readableOn-color2: #c4c4c5; + --pywal-readableOn-color3: #c4c4c5; + --pywal-readableOn-color4: #c4c4c5; + --pywal-readableOn-color5: #c4c4c5; + --pywal-readableOn-color6: #c4c4c5; + --pywal-readableOn-color7: #151618; + --pywal-readableOn-color8: #c4c4c5; + --pywal-readableOn-color9: #c4c4c5; + --pywal-readableOn-color10: #c4c4c5; + --pywal-readableOn-color11: #c4c4c5; + --pywal-readableOn-color12: #c4c4c5; + --pywal-readableOn-color13: #c4c4c5; + --pywal-readableOn-color14: #c4c4c5; + --pywal-readableOn-color15: #151618; }
\ No newline at end of file |