//META{"name":"DisplayServersAsChannels"}*// class DisplayServersAsChannels { getName () {return "DisplayServersAsChannels";} getVersion () {return "1.1.6";} getAuthor () {return "DevilBro";} getDescription () {return "Display servers in a similar way as channels.";} initConstructor () { this.verificationBadgeMarkup = ` `; this.css = ` .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildswrapper}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.scrollerwrapold}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guilds} { width: 160px; } .DSAC-styled ${BDFDB.dotCN.guildswrapper}, .DSAC-styled ${BDFDB.dotCN.scrollerwrapold}, .DSAC-styled ${BDFDB.dotCN.guilds} { width: 240px; } .DSAC-styled ${BDFDB.dotCN.guilds}::-webkit-scrollbar-track-piece { background-color: rgb(27, 29, 32); border-color: rgb(32, 34, 37); } .DSAC-styled ${BDFDB.dotCN.guilds}::-webkit-scrollbar-thumb { background-color: rgb(17, 19, 22); border-color: rgb(32, 34, 37); } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild} { margin-left: 55px; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.friendsonline} { margin-left: 40px; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner} a, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner} a, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror} { height: 20px; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon} { line-height: 20px; } .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner} a, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon}, .DSAC-styled ${BDFDB.dotCN.guild}.copy, .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner}, .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner} a, .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCNS.guildinner + BDFDB.dotCN.guildicon}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror} { margin-left: 0px; height: 32px; } .DSAC-styled ${BDFDB.dotCN.guildseparator} { margin-left: 0px; } .DSAC-styled ${BDFDB.dotCN.guild}, .DSAC-styled ${BDFDB.dotCN.friendsonline} { margin-left: 80px; } .DSAC-styled ${BDFDB.dotCN.guild}.folder.open ${BDFDB.dotCN.guildicon} { text-decoration: underline; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror} { width: 130px; } .DSAC-styled ${BDFDB.dotCN.guildseparator}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, .DSAC-styled ${BDFDB.dotCN.guild}.copy, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror} { width: 215px; box-sizing: border-box; opacity: 0.4; padding-left: 5px; border-radius: 3px; align-items: center; justify-content: flex-start; } .DSAC-styled ${BDFDB.dotCN.guildseparator}:not([style*="display: none"]), .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}:not([style*="display: none"]), .DSAC-styled ${BDFDB.dotCN.guild}.copy:not([style*="display: none"]), .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror}:not([style*="display: none"]) { display: flex; } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildunread}.copy. .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildunread} { opacity: 0.7; } .DSAC-styled ${BDFDB.dotCN.guild}.copy:not(${BDFDB.dotCN.guildselected}):hover, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}:not(${BDFDB.dotCN.guildselected}):hover { opacity: 0.9; background-color: rgba(79,84,92,.3); } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildselected}.copy, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildselected} { opacity: 1; background-color: rgba(79,84,92,.6); } .DSAC-styled ${BDFDB.dotCN.guild}.copy > div[draggable], .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild} > div[draggable] { flex: 1 1 auto; } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildaudio}.copy > div[draggable], .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildvideo}.copy > div[draggable], .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildaudio} > div[draggable], .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildvideo} > div[draggable] { padding-right: 20px; margin-right: 5px; } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildaudio}.copy > div[draggable], .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildaudio} > div[draggable] { background: url(/assets/382ca83d9dc390c4be715248bb4864f4.svg) right no-repeat !important; } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildvideo}.copy > div[draggable], .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildvideo} > div[draggable] { background: url(/assets/c46f51f425c824899b6138ea2b61b41d.svg) right no-repeat !important; } .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.badge}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.badge} { position: static; margin: 0 3px; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner} { width: unset; } .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner} { background: transparent !important; border-radius: 0px !important; position: relative; } .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildaudio}.copy ${BDFDB.dotCN.guildinner}:after, .DSAC-styled ${BDFDB.dotCN.guild + BDFDB.dotCN.guildvideo}.copy ${BDFDB.dotCN.guildinner}:after, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCNS.guildaudio + BDFDB.dotCN.guildinner}:after, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCNS.guildvideo + BDFDB.dotCN.guildinner}:after { display: none !important; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildicon}, .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildicon} { font-size: 14px !important; } .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildicon}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildicon} { background: transparent !important; font-size: 16px !important; line-height: 32px; white-space: nowrap; text-align: left; position: absolute; left: 0; right: 0; width: unset; } .DSAC-styled ${BDFDB.dotCN.guild}.copy ${BDFDB.dotCN.guildinner} .DSAC-verification-badge, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildinner} .DSAC-verification-badge { position: absolute; left: 0; } .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror} { margin-left: -5px; line-height: 28px; } .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCNS.guild + BDFDB.dotCN.guildserror}, .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCN.guildsadd} { display: block !important; } .bd-minimal .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCNS.guildsadd + BDFDB.dotCN.guildsaddinner} { top: -0.2em; } .DSAC-styled ${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild + BDFDB.dotCNS.guildsadd + BDFDB.dotCN.guildsaddinner} { top: -6px; }`; } //legacy load () {} start () { var libraryScript = null; if (!global.BDFDB || typeof BDFDB !== "object" || typeof BDFDB.isLibraryOutdated !== "function" || BDFDB.isLibraryOutdated()) { libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]'); if (libraryScript) libraryScript.remove(); libraryScript = document.createElement("script"); libraryScript.setAttribute("type", "text/javascript"); libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"); document.head.appendChild(libraryScript); } this.startTimeout = setTimeout(() => {this.initialize();}, 30000); if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); else if (libraryScript) libraryScript.addEventListener("load", () => { BDFDB.loaded = true; this.initialize(); }); } initialize () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { BDFDB.loadMessage(this); var observer = null; observer = new MutationObserver((changes, _) => { changes.forEach( (change, i) => { var addedNodes = change.addedNodes; if (change.attributeName == "class" && change.oldValue && change.oldValue.indexOf(BDFDB.disCN.guildplaceholder) > -1) addedNodes = [change.target]; if (change.attributeName == "draggable" && change.oldValue && change.oldValue == "false") addedNodes = [change.target.parentElement]; if (addedNodes) { addedNodes.forEach((node) => { if (node && BDFDB.containsClass(node, BDFDB.disCN.guild) && !node.querySelector(BDFDB.dotCN.guildserror)) { if (BDFDB.containsClass(node, "folder")) this.changeServer(this.getFolderObject(node)); else this.changeServer(BDFDB.getServerData(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.guild + ".folder").forEach(folderdiv => {this.changeServer(this.getFolderObject(folderdiv));}); var appcontainer = document.querySelector(BDFDB.dotCN.appcontainer); if (appcontainer) { BDFDB.addEventListener(this, appcontainer, "mouseenter", `${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, ${BDFDB.dotCN.guild}.copy`, e => { if (e.currentTarget.tagName && e.currentTarget.querySelector(BDFDB.dotCN.guildserror)) return; BDFDB.appendLocalStyle("HideAllToolTips" + this.getName(), `${BDFDB.dotCN.tooltip} {display: none !important;}`); }); BDFDB.addEventListener(this, appcontainer, "mouseleave", `${BDFDB.dotCN.guildseparator} ~ ${BDFDB.dotCN.guild}, ${BDFDB.dotCN.guild}.copy`, e => { if (e.currentTarget.tagName && e.currentTarget.querySelector(BDFDB.dotCN.guildserror)) return; BDFDB.removeLocalStyle("HideAllToolTips" + this.getName()); }); } BDFDB.addClass(appcontainer, "DSAC-styled"); } else { console.error(this.getName() + ": Fatal Error: Could not load BD functions!"); } } stop () { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { BDFDB.readServerList().forEach(info => {this.resetServer(info);}); document.querySelectorAll(BDFDB.dotCN.guild + ".folder").forEach(folderdiv => {this.resetServer(this.getFolderObject(folderdiv));}); BDFDB.removeClasses("DSAC-styled"); BDFDB.unloadMessage(this); } } // begin of own functions changeServer (info) { if (!info || !info.div) return; var avatar = info.div.querySelector(BDFDB.dotCN.guildicon); if (avatar) { avatar.DSAColdName = avatar.textContent; avatar.innerHTML = `
${BDFDB.encodeToHTML(info.name || info.folderName || "")}
`; BDFDB.initElements(avatar); if (info.features && info.features.has("VERIFIED")) avatar.parentElement.insertBefore(avatar, BDFDB.htmlToElement(this.verificationBadgeMarkup)); } } resetServer (info) { if (!info || !info.div) return; var avatar = info.div.querySelector(BDFDB.dotCN.guildicon); if (avatar) { avatar.innerHTML = BDFDB.encodeToHTML(avatar.DSAColdName); BDFDB.removeEles(info.div.querySelector(".DSAC-verification-badge")); } } getFolderObject (folderdiv) { var data = BDFDB.loadData(folderdiv.id, "ServerFolders", "folders"); return data ? Object.assign({div:folderdiv}, data) : null; } }