//META{"name":"DisplayServersAsChannels","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/DisplayServersAsChannels","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/DisplayServersAsChannels/DisplayServersAsChannels.plugin.js"}*//
class DisplayServersAsChannels {
getName () {return "DisplayServersAsChannels";}
getVersion () {return "1.2.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Display servers in a similar way as channels.";}
initConstructor () {
this.changelog = {
"added":[["Width settings","Added the option to change the width of the changed server list"]]
};
this.patchModules = {
"Guilds":"componentDidMount",
"StandardSidebarView":"componentWillUnmount"
};
this.verificationBadgeMarkup =
``;
this.defaults = {
amounts: {
serverListWidth: {value:240, min:45, description:"Server list width in px:"}
}
};
}
getSettingsPanel () {
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
var amounts = BDFDB.getAllData(this, "amounts");
var settingshtml = `
${this.name}
`;
for (let key in amounts) {
settingshtml += `
`;
}
settingshtml += `
`;
settingshtml += `
`;
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel, this);
return settingspanel;
}
//legacy
load () {}
start () {
if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
var libraryScript = document.querySelector('head script#BDFDBLibraryScript');
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", () => {this.initialize();});
document.head.appendChild(libraryScript);
this.libLoadTimeout = setTimeout(() => {
libraryScript.remove();
require("request")("https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js", (error, response, body) => {
if (body) {
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("date", performance.now());
libraryScript.innerText = body;
document.head.appendChild(libraryScript);
}
this.initialize();
});
}, 15000);
}
else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
}
initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.loadMessage(this);
BDFDB.addClass(document.body, "DSAC-styled");
this.addCSS();
BDFDB.WebModules.forceAllUpdates(this);
BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCN.guildouter, e => {
if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *")) BDFDB.appendLocalStyle("HideAllToolTips" + this.name, `${BDFDB.dotCN.tooltip} {display: none !important;}`);
});
BDFDB.addEventListener(this, document, "mouseleave", BDFDB.dotCN.guildouter, e => {
if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *") && !document.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *:hover")) BDFDB.removeLocalStyle("HideAllToolTips" + this.name);
});
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
BDFDB.removeClasses("DSAC-styled");
BDFDB.removeEles(".DSAC-verification-badge, .DSAC-name, .DSAC-icon");
BDFDB.removeLocalStyle("HideAllToolTips" + this.name);
BDFDB.removeLocalStyle("DSACStyle" + this.name);
for (let changedSVG of document.querySelectorAll(BDFDB.dotCN.guildsvg + "[DSAC-oldViewBox")) {
changedSVG.setAttribute("viewBox", changedSVG.getAttribute("DSAC-oldViewBox"));
changedSVG.removeAttribute("DSAC-oldViewBox");
}
BDFDB.unloadMessage(this);
}
}
// begin of own functions
processGuilds (instance, wrapper) {
var observer = new MutationObserver((changes, _) => {changes.forEach((change, i) => {if (change.addedNodes) {change.addedNodes.forEach((node) => {
if (node && BDFDB.containsClass(node, BDFDB.disCN.guildouter) && !node.querySelector(BDFDB.dotCN.guildserror)) {
if (BDFDB.containsClass(node, "folder")) this.changeServer(this.getFolderObject(node));
else this.changeServer(BDFDB.getServerData(node));
}
if (node && node.tagName && (node = node.querySelector(BDFDB.dotCN.guildbuttoncontainer)) != null) {
this.changeButton(node);
}
if (node && node.tagName && (node = node.querySelector(BDFDB.dotCN.guildserror)) != null) {
this.changeError(node);
}
});}});});
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilter: ["class", "draggable"], attributeOldValue: true});
BDFDB.readServerList().forEach(info => {this.changeServer(info);});
document.querySelectorAll(BDFDB.dotCN.guildouter + ".folder").forEach(folderdiv => {this.changeServer(this.getFolderObject(folderdiv));});
document.querySelectorAll(BDFDB.dotCN.homebuttonpill + " + *").forEach(homebuttoncontainer => {this.changeHome(homebuttoncontainer);});
document.querySelectorAll(BDFDB.dotCN.guildbuttonpill + " + *").forEach(guildbuttoncontainer => {this.changeButton(guildbuttoncontainer);});
document.querySelectorAll(BDFDB.dotCN.guildserror).forEach(guildserror => {this.changeError(guildserror);});
}
processStandardSidebarView (instance, wrapper) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.addCSS();
}
}
changeServer (info) {
if (!info || !info.div) return;
var guildbadgewrapper = info.div.querySelector(BDFDB.dotCN.guildbadgewrapper);
if (guildbadgewrapper) {
BDFDB.removeEles(guildbadgewrapper.parentElement.querySelectorAll(".DSAC-verification-badge, .DSAC-name"));
if (info.features && info.features.has("VERIFIED")) {
guildbadgewrapper.parentElement.insertBefore(BDFDB.htmlToElement(this.verificationBadgeMarkup), guildbadgewrapper);
}
guildbadgewrapper.parentElement.insertBefore(BDFDB.htmlToElement(`${BDFDB.encodeToHTML(info.name || info.folderName || "")}
`), guildbadgewrapper);
}
this.changeSVG(info.div);
}
changeHome (div) {
if (!div) return;
var homebutton = div.querySelector(BDFDB.dotCN.homebutton);
if (homebutton) {
BDFDB.removeEles(homebutton.querySelectorAll(".DSAC-name"));
homebutton.insertBefore(BDFDB.htmlToElement(`${BDFDB.encodeToHTML(BDFDB.LanguageStrings.HOME)}
`), homebutton.firstElementChild);
}
this.changeSVG(div);
}
changeButton (div) {
if (!div) return;
var guildbuttoninner = div.querySelector(BDFDB.dotCN.guildbuttoninner);
if (guildbuttoninner) {
BDFDB.removeEles(guildbuttoninner.querySelectorAll(".DSAC-name"));
guildbuttoninner.insertBefore(BDFDB.htmlToElement(`${BDFDB.encodeToHTML(BDFDB.getKeyInformation({node:div, key:"text", up:true}) || "")}
`), guildbuttoninner.firstElementChild);
}
this.changeSVG(div);
}
changeSVG (div) {
var guildsvg = div.querySelector(BDFDB.dotCN.guildsvg);
if (guildsvg && !guildsvg.getAttribute("DSAC-oldViewBox")) {
guildsvg.setAttribute("DSAC-oldViewBox", guildsvg.getAttribute("viewBox"));
guildsvg.removeAttribute("viewBox");
}
}
changeError (div) {
if (!div) return;
BDFDB.removeEles(div.querySelectorAll(".DSAC-name, .DSAC-icon"));
div.insertBefore(BDFDB.htmlToElement(`Server Outage
`), div.firstChild);
div.appendChild(BDFDB.htmlToElement(`!
`));
}
getFolderObject (folderdiv) {
var data = BDFDB.loadData(folderdiv.id, "ServerFolders", "folders");
return data ? Object.assign({div:folderdiv}, data) : null;
}
addCSS () {
var listwidth = BDFDB.getData("serverListWidth", this, "amounts");
BDFDB.appendLocalStyle("DSACStyle" + this.name, `
.DSAC-styled ${BDFDB.dotCN.guildswrapper},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscrollerwrap},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guilds},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsindicatortop},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsindicatorbottom} {
width: ${listwidth}px !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guilds + BDFDB.dotCN.scroller}::-webkit-scrollbar-thumb {
background-color: rgb(22, 24, 27);
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} {
box-sizing: border-box;
padding-left: 5px;
align-items: center;
justify-content: flex-start;
width: auto !important;
height: auto !important;
min-height: 16px !important;
margin: 2px 0 !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildicon},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildiconacronym} {
display: none !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guilds} > div[style*="height"]:not([class]) {
margin-top: 8px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guilds} > div[style*="height"]:not([class]) + div[style*="height"]:not([class]) {
margin-top: 0px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.dmpill} + * {
margin-left: 5px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildcontainer},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + ${BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildiconwrapper},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildbuttoninner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildserror},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildplaceholder} {
height: 32px !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildseparator} {
width: ${listwidth - 10}px !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCNS.guildcontainer},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildsvg},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildiconwrapper},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildbuttoninner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildplaceholder} {
width: ${listwidth - 15}px !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + ${BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildserror} {
width: ${listwidth - 18}px !important;
display: flex !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * foreignObject {
width: ${listwidth - 15}px !important;
mask: none;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} {
top: -8px;
transform: scaleY(calc(32/50));
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCNS.dmpill + BDFDB.dotCN.guildpillitem} {
min-height: calc(8px * (50/32));
}
.DSAC-styled #bd-pub-button,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} .RANbutton,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * {
margin-left: 3px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.homebutton},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildbuttoninner} {
display: flex;
justify-content: flex-start;
align-items: center;
padding-right: 5px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildbuttoninner} svg {
margin-right: 3px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.homebutton} svg {
margin-right: 8px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildserror} {
border-radius: 3px;
margin-left: 3px;
font-size: 0;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildbadgewrapper} {
display: flex;
flex: 0 0;
position: static;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildlowerbadge},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildupperbadge} {
position: static;
margin-top: 7px;
margin-right: 3px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter} .DSAC-verification-badge {
margin-top: 3px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} .DSAC-name {
flex: 1 1;
width: ${listwidth - 25}px;
margin: 0 5px;
font-size: 16px;
font-weight: 400;
line-height: 32px;
color: white;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
pointer-events: none;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} .DSAC-icon {
font-size: 20px;
margin-right: 13px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildserror} .DSAC-name {
margin-left: 4px;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.homebutton} .DSAC-name,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildbuttoninner} .DSAC-name {
color: currentColor;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.homebutton} .DSAC-name {
margin-top: 2px;
}
.DSAC-styled #bd-pub-li,
.DSAC-styled #bd-pub-button,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter}.RANbutton-frame,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} .RANbutton {
width: ${listwidth - 10}px !important;
height: 32px !important;
}
.DSAC-styled #bd-pub-button,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} .RANbutton {
border-radius: 3px !important;
display: block !important;
color: white !important;
font-weight: 400 !important;
font-size: 16px !important;
line-height: 32px !important;
padding-left: 5px !important;
text-transform: capitalize !important;
text-align: left !important;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter}.folder.open .DSAC-name {
text-decoration: underline;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + ${BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildinner} {
background-color: transparent;
border-radius: 3px;
overflow: hidden;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill} + * ${BDFDB.dotCN.guildinner}:hover {
background-color: rgba(79,84,92,.3);
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + BDFDB.dotCNS._bdguildselected + BDFDB.dotCN.guildinner},
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + BDFDB.dotCNS._bdguildselected + BDFDB.dotCN.guildinner}:hover {
background-color: rgba(79,84,92,.6);
}
.DSAC-styled #bd-pub-button {
transition: background-color .15s ease-out,color .15s ease-out;
}
.DSAC-styled bd-pub-button:hover {
background-color: rgb(114,137,218);
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildinner} .DSAC-name {
opacity: 0.4;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildpill} + * ${BDFDB.dotCN.guildinner}:hover .DSAC-name {
opacity: 0.9;
}
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + BDFDB.dotCNS._bdguildselected + BDFDB.dotCN.guildinner} .DSAC-name,
.DSAC-styled ${BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + BDFDB.dotCNS._bdguildselected + BDFDB.dotCN.guildinner}:hover .DSAC-name {
opacity: 1;
}
.DSAC-styled .serverfolders-dragpreview .DSAC-name {
color: white;
font-size: 16px;
font-weight: 400;
width: ${listwidth - 20}px;
height: 32px;
line-height: 32px;
margin-top: 9px;
padding-left: 5px;
text-overflow: ellipsis;
overflow: hidden;
background-color: rgba(79,84,92,.6);
border-radius: 3px;
}
.DSAC-styled .serverfolders-dragpreview ${BDFDB.dotCN.guildiconacronym},
.DSAC-styled .serverfolders-dragpreview ${BDFDB.dotCN.guildicon} {
display: none;
}`);
}
}