Update EditServers.plugin.js
This commit is contained in:
parent
214edf7b8a
commit
052045c28a
|
@ -3,7 +3,7 @@
|
||||||
class EditServers {
|
class EditServers {
|
||||||
getName () {return "EditServers";}
|
getName () {return "EditServers";}
|
||||||
|
|
||||||
getVersion () {return "2.1.5";}
|
getVersion () {return "2.1.6";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class EditServers {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"improved":[["Serveracronyms","You can now choose to use the native serveracronym for servers without icons even if you set a local custom servername"],["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
"improved":[["Recent Mentions","Servernames are now changed in the recent mentions popout"],["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchedModules = {
|
this.patchedModules = {
|
||||||
|
@ -26,6 +26,7 @@ class EditServers {
|
||||||
GuildHeader: "render"
|
GuildHeader: "render"
|
||||||
},
|
},
|
||||||
after: {
|
after: {
|
||||||
|
MessagesPopout: "render",
|
||||||
Guild: "render",
|
Guild: "render",
|
||||||
BlobMask: "render",
|
BlobMask: "render",
|
||||||
GuildIconWrapper: "render",
|
GuildIconWrapper: "render",
|
||||||
|
@ -40,9 +41,10 @@ class EditServers {
|
||||||
settings: {
|
settings: {
|
||||||
addOriginalTooltip: {value:true, inner:false, description:"Hovering over a changed Server Header shows the original Name as Tooltip"},
|
addOriginalTooltip: {value:true, inner:false, description:"Hovering over a changed Server Header shows the original Name as Tooltip"},
|
||||||
changeInGuildList: {value:true, inner:true, description:"Server List"},
|
changeInGuildList: {value:true, inner:true, description:"Server List"},
|
||||||
|
changeInGuildHeader: {value:true, inner:true, description:"Server Header"},
|
||||||
changeInMutualGuilds: {value:true, inner:true, description:"Mutual Servers"},
|
changeInMutualGuilds: {value:true, inner:true, description:"Mutual Servers"},
|
||||||
changeInQuickSwitcher: {value:true, inner:true, description:"Quick Switcher"},
|
changeInRecentMentions: {value:true, inner:true, description:"Recent Mentions Popout"},
|
||||||
changeInGuildHeader: {value:true, inner:true, description:"Server Header"}
|
changeInQuickSwitcher: {value:true, inner:true, description:"Quick Switcher"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -229,7 +231,8 @@ class EditServers {
|
||||||
|
|
||||||
processGuildAcronym (e) {
|
processGuildAcronym (e) {
|
||||||
if (typeof e.returnvalue.props.children == "function" && BDFDB.DataUtils.get(this, "settings", "changeInGuildList")) {
|
if (typeof e.returnvalue.props.children == "function" && BDFDB.DataUtils.get(this, "settings", "changeInGuildList")) {
|
||||||
let data = BDFDB.DataUtils.load(this, "servers", (e.instance.props.to.pathname.split("/channels/")[1] || "").split("/")[0]);
|
let pathname = BDFDB.ReactUtils.getValue(e.instance, "props.to.pathname");
|
||||||
|
let data = pathname && BDFDB.DataUtils.load(this, "servers", (pathname.split("/channels/")[1] || "").split("/")[0]);
|
||||||
if (data) {
|
if (data) {
|
||||||
let renderChildren = e.returnvalue.props.children;
|
let renderChildren = e.returnvalue.props.children;
|
||||||
e.returnvalue.props.children = (...args) => {
|
e.returnvalue.props.children = (...args) => {
|
||||||
|
@ -291,6 +294,16 @@ class EditServers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 dividerAndMessage of children[index].props.children[0]) if (dividerAndMessage[0].props.children[1]) {
|
||||||
|
let channel = BDFDB.ReactUtils.getValue(dividerAndMessage[1], "props.children.props.children.props.channel");
|
||||||
|
if (channel && BDFDB.ChannelUtils.isTextChannel(channel)) dividerAndMessage[0].props.children[1].props.children = this.getGuildData(channel.guild_id).name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processGuildSidebar (e) {
|
processGuildSidebar (e) {
|
||||||
if (e.instance.props.guild) {
|
if (e.instance.props.guild) {
|
||||||
let data = BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id);
|
let data = BDFDB.DataUtils.load(this, "servers", e.instance.props.guild.id);
|
||||||
|
@ -367,35 +380,31 @@ class EditServers {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: this.labels.modal_guildname_text,
|
title: this.labels.modal_guildname_text,
|
||||||
className: BDFDB.disCN.marginbottom8,
|
className: BDFDB.disCN.marginbottom8,
|
||||||
children: [
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
inputClassName: "input-guildname",
|
||||||
inputClassName: "input-guildname",
|
value: data.name,
|
||||||
value: data.name,
|
placeholder: guild.name,
|
||||||
placeholder: guild.name,
|
autoFocus: true,
|
||||||
autoFocus: true,
|
onChange: (value, instance) => {
|
||||||
onChange: (value, instance) => {
|
if (!currentIgnoreCustomNameState) {
|
||||||
if (!currentIgnoreCustomNameState) {
|
let acronyminputins = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return.return.return, {props:[["inputId","GUILDACRONYM"]]});
|
||||||
let acronyminputins = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return.return.return, {props:[["inputId","GUILDACRONYM"]]});
|
if (acronyminputins) {
|
||||||
if (acronyminputins) {
|
acronyminputins.props.placeholder = value && BDFDB.LibraryModules.StringUtils.getAcronym(value) || guild.acronym;
|
||||||
acronyminputins.props.placeholder = value && BDFDB.LibraryModules.StringUtils.getAcronym(value) || guild.acronym;
|
BDFDB.ReactUtils.forceUpdate(acronyminputins);
|
||||||
BDFDB.ReactUtils.forceUpdate(acronyminputins);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
]
|
})
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: this.labels.modal_guildacronym_text,
|
title: this.labels.modal_guildacronym_text,
|
||||||
className: BDFDB.disCN.marginbottom4,
|
className: BDFDB.disCN.marginbottom4,
|
||||||
children: [
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
inputClassName: "input-guildacronym",
|
||||||
inputClassName: "input-guildacronym",
|
inputId: "GUILDACRONYM",
|
||||||
inputId: "GUILDACRONYM",
|
value: data.shortName,
|
||||||
value: data.shortName,
|
placeholder: !data.ignoreCustomName && data.name && BDFDB.LibraryModules.StringUtils.getAcronym(data.name) || guild.acronym
|
||||||
placeholder: !data.ignoreCustomName && data.name && BDFDB.LibraryModules.StringUtils.getAcronym(data.name) || guild.acronym
|
})
|
||||||
})
|
|
||||||
]
|
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
@ -414,19 +423,17 @@ class EditServers {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: this.labels.modal_guildicon_text,
|
title: this.labels.modal_guildicon_text,
|
||||||
className: BDFDB.disCN.marginbottom4,
|
className: BDFDB.disCN.marginbottom4,
|
||||||
children: [
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
inputClassName: "input-guildicon",
|
||||||
inputClassName: "input-guildicon",
|
inputId: "GUILDICON",
|
||||||
inputId: "GUILDICON",
|
success: !data.removeIcon && data.url,
|
||||||
success: !data.removeIcon && data.url,
|
value: data.url,
|
||||||
value: data.url,
|
placeholder: BDFDB.GuildUtils.getIcon(guild.id),
|
||||||
placeholder: BDFDB.GuildUtils.getIcon(guild.id),
|
disabled: data.removeIcon,
|
||||||
disabled: data.removeIcon,
|
onChange: (value, instance) => {
|
||||||
onChange: (value, instance) => {
|
this.checkUrl(value, instance);
|
||||||
this.checkUrl(value, instance);
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
]
|
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
@ -446,19 +453,17 @@ class EditServers {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
|
||||||
title: this.labels.modal_guildbanner_text,
|
title: this.labels.modal_guildbanner_text,
|
||||||
className: BDFDB.disCN.marginbottom4,
|
className: BDFDB.disCN.marginbottom4,
|
||||||
children: [
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
|
inputClassName: "input-guildbanner",
|
||||||
inputClassName: "input-guildbanner",
|
inputId: "GUILDBANNER",
|
||||||
inputId: "GUILDBANNER",
|
success: !data.removeBanner && data.banner,
|
||||||
success: !data.removeBanner && data.banner,
|
value: data.banner,
|
||||||
value: data.banner,
|
placeholder: BDFDB.GuildUtils.getBanner(guild.id),
|
||||||
placeholder: BDFDB.GuildUtils.getBanner(guild.id),
|
disabled: data.removeBanner || guild.id == "410787888507256842",
|
||||||
disabled: data.removeBanner || guild.id == "410787888507256842",
|
onChange: (value, instance) => {
|
||||||
onChange: (value, instance) => {
|
this.checkUrl(value, instance);
|
||||||
this.checkUrl(value, instance);
|
}
|
||||||
}
|
})
|
||||||
})
|
|
||||||
]
|
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||||
type: "Switch",
|
type: "Switch",
|
||||||
|
|
Loading…
Reference in New Issue