2019-09-20 22:32:52 +02:00
|
|
|
//META{"name":"ServerHider","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerHider","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerHider/ServerHider.plugin.js"}*//
|
2018-10-11 10:21:26 +02:00
|
|
|
|
2019-03-11 14:49:54 +01:00
|
|
|
class ServerHider {
|
2019-01-16 00:14:18 +01:00
|
|
|
getName () {return "ServerHider";}
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
getVersion () {return "6.0.9";}
|
2019-01-16 00:14:18 +01:00
|
|
|
|
|
|
|
getAuthor () {return "DevilBro";}
|
|
|
|
|
|
|
|
getDescription () {return "Hide Servers in your Serverlist";}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-09-04 12:34:02 +02:00
|
|
|
constructor () {
|
2019-03-08 13:16:58 +01:00
|
|
|
this.changelog = {
|
2019-09-11 12:14:43 +02:00
|
|
|
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
|
2019-03-08 13:16:58 +01:00
|
|
|
};
|
2019-09-04 12:34:02 +02:00
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
this.labels = {};
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-03 14:46:41 +01:00
|
|
|
this.patchModules = {
|
2019-04-25 22:23:17 +02:00
|
|
|
"Guild":["componentDidMount","componentDidUpdate"]
|
2019-01-03 14:46:41 +01:00
|
|
|
};
|
2019-09-04 12:34:02 +02:00
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-09-04 12:34:02 +02:00
|
|
|
initConstructor () {
|
2019-01-05 01:22:16 +01:00
|
|
|
this.serverHiderModalMarkup =
|
2019-04-18 09:28:20 +02:00
|
|
|
`<span class="${this.name}-modal BDFDB-modal">
|
2018-10-11 10:21:26 +02:00
|
|
|
<div class="${BDFDB.disCN.backdrop}"></div>
|
|
|
|
<div class="${BDFDB.disCN.modal}">
|
|
|
|
<div class="${BDFDB.disCN.modalinner}">
|
|
|
|
<div class="${BDFDB.disCNS.modalsub + BDFDB.disCN.modalsizemedium}">
|
2019-10-08 11:51:41 +02:00
|
|
|
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
|
2018-10-11 10:21:26 +02:00
|
|
|
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
|
2019-09-11 12:14:43 +02:00
|
|
|
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.defaultcolor + BDFDB.disCN.h4defaultmargin}">REPLACE_modal_header_text</h4>
|
2019-10-09 14:18:28 +02:00
|
|
|
<div class="${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}"></div>
|
2018-10-11 10:21:26 +02:00
|
|
|
</div>
|
2019-01-22 20:15:31 +01:00
|
|
|
<button type="button" class="${BDFDB.disCNS.modalclose + BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookblank + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCN.buttongrow}">
|
|
|
|
<div class="${BDFDB.disCN.buttoncontents}">
|
|
|
|
<svg name="Close" width="18" height="18" viewBox="0 0 12 12" style="flex: 0 1 auto;">
|
|
|
|
<g fill="none" fill-rule="evenodd">
|
|
|
|
<path d="M0 0h12v12H0"></path>
|
|
|
|
<path class="fill" fill="currentColor" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path>
|
|
|
|
</g>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</button>
|
2018-10-11 10:21:26 +02:00
|
|
|
</div>
|
2019-10-09 14:18:28 +02:00
|
|
|
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.scrollerthemeghosthairline}">
|
2019-01-05 01:22:16 +01:00
|
|
|
<div class="${BDFDB.disCNS.scroller + BDFDB.disCN.modalsubinner} entries"></div>
|
2018-10-11 10:21:26 +02:00
|
|
|
</div>
|
2019-09-18 10:19:56 +02:00
|
|
|
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontalreverse + BDFDB.disCNS.horizontalreverse2 + BDFDB.disCNS.directionrowreverse + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCN.modalfooter}">
|
2019-01-05 01:22:16 +01:00
|
|
|
<button type="button" class="btn-ok ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorbrand + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
2019-09-11 12:14:43 +02:00
|
|
|
<div class="${BDFDB.disCN.buttoncontents}"></div>
|
2019-01-05 01:22:16 +01:00
|
|
|
</button>
|
|
|
|
<button type="button" class="btn-all ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlooklink + BDFDB.disCNS.buttoncolortransparent + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
2019-09-11 12:14:43 +02:00
|
|
|
<div class="${BDFDB.disCN.buttoncontents}"></div>
|
2018-10-11 10:21:26 +02:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-01-05 01:22:16 +01:00
|
|
|
</span>`;
|
|
|
|
|
|
|
|
this.serverEntryMarkup =
|
2019-10-08 11:51:41 +02:00
|
|
|
`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">
|
2019-10-09 14:18:28 +02:00
|
|
|
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} serverhiderName" style="flex: 1 1 auto; white-space: nowrap;"></h3>
|
2019-01-05 01:22:16 +01:00
|
|
|
<div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;">
|
|
|
|
<input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} serverhiderCheckbox">
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
|
2019-03-08 13:16:58 +01:00
|
|
|
this.defaults = {
|
|
|
|
settings: {
|
|
|
|
clearNotifications: {value:false, description:"Automatically clear any kind of notification of all hidden servers."},
|
|
|
|
}
|
|
|
|
};
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
getSettingsPanel () {
|
2019-01-22 11:28:32 +01:00
|
|
|
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
2019-09-04 12:34:02 +02:00
|
|
|
let settings = BDFDB.getAllData(this, "settings");
|
2019-10-09 14:18:28 +02:00
|
|
|
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
2019-03-08 13:16:58 +01:00
|
|
|
for (let key in settings) {
|
2019-10-09 14:18:28 +02:00
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
2019-03-08 13:16:58 +01:00
|
|
|
}
|
2019-10-09 14:18:28 +02:00
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Reset all Servers.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
|
2018-10-11 10:21:26 +02:00
|
|
|
settingshtml += `</div></div>`;
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-16 00:14:18 +01:00
|
|
|
let settingspanel = BDFDB.htmlToElement(settingshtml);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
2019-01-16 00:14:18 +01:00
|
|
|
BDFDB.initElements(settingspanel, this);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
2019-01-17 23:48:29 +01:00
|
|
|
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {
|
2019-01-16 00:14:18 +01:00
|
|
|
BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => {
|
|
|
|
BDFDB.removeAllData(this, "servers");
|
|
|
|
BDFDB.readServerList().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, false);});
|
2019-01-06 23:37:28 +01:00
|
|
|
});
|
2019-01-16 00:14:18 +01:00
|
|
|
});
|
2018-10-11 10:21:26 +02:00
|
|
|
return settingspanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
//legacy
|
|
|
|
load () {}
|
|
|
|
|
|
|
|
start () {
|
2019-02-04 09:13:15 +01:00
|
|
|
if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
|
|
|
|
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
|
2019-05-26 13:55:26 +02:00
|
|
|
var libraryScript = document.querySelector('head script#BDFDBLibraryScript');
|
|
|
|
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
|
2018-10-11 10:21:26 +02:00
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
libraryScript = document.createElement("script");
|
2019-05-26 13:55:26 +02:00
|
|
|
libraryScript.setAttribute("id", "BDFDBLibraryScript");
|
2018-10-11 10:21:26 +02:00
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
2019-10-18 10:56:41 +02:00
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
|
2019-01-17 23:48:29 +01:00
|
|
|
libraryScript.setAttribute("date", performance.now());
|
2019-05-26 13:55:26 +02:00
|
|
|
libraryScript.addEventListener("load", () => {this.initialize();});
|
2018-10-11 10:21:26 +02:00
|
|
|
document.head.appendChild(libraryScript);
|
2019-05-26 13:55:26 +02:00
|
|
|
}
|
|
|
|
else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
2018-10-11 10:21:26 +02:00
|
|
|
this.startTimeout = setTimeout(() => {this.initialize();}, 30000);
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize () {
|
2019-01-17 23:48:29 +01:00
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2019-01-22 11:05:54 +01:00
|
|
|
if (this.started) return;
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.loadMessage(this);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
BDFDB.WebModules.forceAllUpdates(this);
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-02-12 21:56:34 +01:00
|
|
|
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stop () {
|
2019-01-17 23:48:29 +01:00
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2019-03-08 13:16:58 +01:00
|
|
|
BDFDB.readServerList().forEach(info => {
|
|
|
|
if (info.div.ServerHiderChangeObserver && typeof info.div.ServerHiderChangeObserver.disconnect == "function") info.div.ServerHiderChangeObserver.disconnect();
|
|
|
|
if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, true);
|
|
|
|
delete info.div.ServerHiderChanged;
|
|
|
|
});
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
BDFDB.unloadMessage(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
// begin of own functions
|
|
|
|
|
|
|
|
changeLanguageStrings () {
|
2019-01-05 01:22:16 +01:00
|
|
|
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
this.serverEntryMarkup = this.serverEntryMarkup.replace("REPLACE_btn_visible_text", this.labels.btn_visible_text);
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
onGuildContextMenu (instance, menu, returnvalue) {
|
2019-04-18 09:28:20 +02:00
|
|
|
if (document.querySelector(".BDFDB-modal")) return;
|
2019-09-11 12:14:43 +02:00
|
|
|
if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
2019-09-11 14:31:41 +02:00
|
|
|
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
|
2019-09-11 12:14:43 +02:00
|
|
|
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
|
|
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
|
|
|
children: [
|
|
|
|
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
|
|
|
|
label: this.labels.context_serverhider_text,
|
|
|
|
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem`,
|
|
|
|
render: [BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
|
|
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
|
|
|
children: [
|
|
|
|
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
|
|
|
label: this.labels.submenu_openhidemenu_text,
|
|
|
|
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hidemenu-ContextMenuItem`,
|
|
|
|
action: e => {
|
|
|
|
BDFDB.closeContextMenu(menu);
|
|
|
|
this.showServerModal();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
|
|
|
label: this.labels.submenu_hideserver_text,
|
|
|
|
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hideserver-ContextMenuItem`,
|
|
|
|
disabled: !(instance.props.guild && !instance.props.target.getAttribute("folder")),
|
|
|
|
action: e => {
|
|
|
|
BDFDB.closeContextMenu(menu);
|
|
|
|
this.toggleServer(instance.props.guild, instance.props.target, false);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})]
|
|
|
|
})
|
|
|
|
]
|
2019-01-16 00:14:18 +01:00
|
|
|
});
|
2019-09-11 12:14:43 +02:00
|
|
|
if (index > -1) children.splice(index, 0, itemgroup);
|
|
|
|
else children.push(itemgroup);
|
2019-01-16 00:14:18 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
processGuild (instance, wrapper, returnvalue, methodnames) {
|
2019-05-07 19:42:08 +02:00
|
|
|
if (instance.props && instance.props.guild) {
|
2019-01-16 00:14:18 +01:00
|
|
|
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
|
2019-04-25 22:23:17 +02:00
|
|
|
if (methodnames.includes("componentDidMount")) this.toggleServer(instance.props.guild, wrapper, !hiddenservers.includes(instance.props.guild.id));
|
|
|
|
if (methodnames.includes("componentDidUpdate") && hiddenservers.includes(instance.props.guild.id) && instance.props.unread) this.unreadServer(instance.props.guild.id);
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
showServerModal () {
|
2019-01-16 00:14:18 +01:00
|
|
|
let serverHiderModal = BDFDB.htmlToElement(this.serverHiderModalMarkup);
|
|
|
|
let container = serverHiderModal.querySelector(".entries");
|
|
|
|
if (!container) return;
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-16 00:14:18 +01:00
|
|
|
BDFDB.addChildEventListener(serverHiderModal, "click", ".btn-all", () => {
|
|
|
|
let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox");
|
|
|
|
firstcheckbox.click();
|
|
|
|
serverHiderModal.querySelectorAll(".serverhiderCheckbox").forEach(checkbox => {
|
|
|
|
if (checkbox != firstcheckbox && checkbox.checked != firstcheckbox.checked) checkbox.click();
|
2018-10-11 10:21:26 +02:00
|
|
|
});
|
2019-01-16 00:14:18 +01:00
|
|
|
});
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-16 00:14:18 +01:00
|
|
|
for (let info of BDFDB.readServerList()) {
|
|
|
|
if (!info.div.getAttribute("folder")) {
|
2019-10-15 11:46:37 +02:00
|
|
|
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.divider}"></div>`));
|
2019-01-16 00:14:18 +01:00
|
|
|
let entry = BDFDB.htmlToElement(this.serverEntryMarkup);
|
|
|
|
container.appendChild(entry);
|
|
|
|
let name = entry.querySelector(".serverhiderName");
|
|
|
|
name.innerText = info.name || "";
|
2019-08-07 14:46:10 +02:00
|
|
|
name.parentElement.insertBefore(BDFDB.createServerDivCopy(info, {click: () => {BDFDB.removeEles(serverHiderModal);}, menu: true, size: 48}), name);
|
2019-01-16 00:14:18 +01:00
|
|
|
let hidecheckbox = entry.querySelector(".serverhiderCheckbox");
|
|
|
|
hidecheckbox.checked = !BDFDB.isEleHidden(info.div);
|
|
|
|
hidecheckbox.addEventListener("click", e => {
|
|
|
|
this.toggleServer(info, info.div, e.currentTarget.checked);
|
|
|
|
});
|
2019-01-03 14:46:41 +01:00
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
2019-01-05 01:22:16 +01:00
|
|
|
BDFDB.appendModal(serverHiderModal);
|
2018-10-11 10:21:26 +02:00
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
toggleServer (info, target, visible) {
|
|
|
|
if (!info || !target) return;
|
2019-04-24 11:46:29 +02:00
|
|
|
let guilddiv = BDFDB.getParentEle(BDFDB.dotCN.guildouter, target);
|
2019-01-05 01:22:16 +01:00
|
|
|
if (!guilddiv || guilddiv.getAttribute("folder")) return;
|
2019-01-16 00:14:18 +01:00
|
|
|
BDFDB.toggleEles(guilddiv, visible);
|
2019-01-05 01:22:16 +01:00
|
|
|
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
|
|
|
|
BDFDB.removeFromArray(hiddenservers, info.id);
|
2019-03-08 13:16:58 +01:00
|
|
|
if (!visible) {
|
2019-04-25 22:23:17 +02:00
|
|
|
if (BDFDB.getReactValue(guilddiv, "return.stateNode.props").unread) this.unreadServer(info.id);
|
2019-03-09 20:22:27 +01:00
|
|
|
hiddenservers.push(info.id);
|
2019-03-08 13:16:58 +01:00
|
|
|
}
|
2019-01-05 01:22:16 +01:00
|
|
|
BDFDB.saveData("hiddenservers", hiddenservers, this, "hiddenservers");
|
2019-01-05 01:01:34 +01:00
|
|
|
}
|
2019-09-04 12:34:02 +02:00
|
|
|
|
2019-04-25 22:23:17 +02:00
|
|
|
unreadServer (id) {
|
2019-05-09 11:40:51 +02:00
|
|
|
if (BDFDB.getData("clearNotifications", this, "settings") && !this.isInFolder(id)) BDFDB.markGuildAsRead(id);
|
2019-05-09 11:37:07 +02:00
|
|
|
}
|
2019-09-04 12:34:02 +02:00
|
|
|
|
2019-05-09 11:37:07 +02:00
|
|
|
isInFolder (id) {
|
|
|
|
if (!BDFDB.isPluginEnabled("ServerFolders")) return false;
|
2019-05-09 11:40:23 +02:00
|
|
|
let folders = BDFDB.loadAllData("ServerFolders", "folders");
|
|
|
|
for (let folderid in folders) if ((folders[folderid].servers || []).includes(id)) return true;
|
2019-05-09 11:37:07 +02:00
|
|
|
return false;
|
2019-03-08 13:16:58 +01:00
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
setLabelsByLanguage () {
|
|
|
|
switch (BDFDB.getDiscordLanguage().id) {
|
|
|
|
case "hr": //croatian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Upravljanje popisom poslužitelja",
|
|
|
|
context_serverhider_text: "Vidljivost poslužitelj",
|
|
|
|
submenu_hideserver_text: "Sakrij poslužitelj",
|
|
|
|
submenu_openhidemenu_text: "Upravljanje popisom poslužitelja"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "da": //danish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Styring af Serverliste",
|
|
|
|
context_serverhider_text: "Server synlighed",
|
|
|
|
submenu_hideserver_text: "Skjul Server",
|
|
|
|
submenu_openhidemenu_text: "Styre Serverliste"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "de": //german
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Verwaltung der Serverliste",
|
|
|
|
context_serverhider_text: "Serversichtbarkeit",
|
|
|
|
submenu_hideserver_text: "Server verstecken",
|
|
|
|
submenu_openhidemenu_text: "Serverliste verwalten"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "es": //spanish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Administración de lista de servidores",
|
|
|
|
context_serverhider_text: "Visibilidad del servidor",
|
|
|
|
submenu_hideserver_text: "Ocultar servidor",
|
|
|
|
submenu_openhidemenu_text: "Administrar lista de servidores"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "fr": //french
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Gestion de la liste des serveurs",
|
|
|
|
context_serverhider_text: "Visibilité du serveur",
|
|
|
|
submenu_hideserver_text: "Cacher le serveur",
|
|
|
|
submenu_openhidemenu_text: "Gérer la liste des serveurs"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "it": //italian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Gestione dell'elenco dei server",
|
|
|
|
context_serverhider_text: "Visibilità del server",
|
|
|
|
submenu_hideserver_text: "Nascondi il server",
|
|
|
|
submenu_openhidemenu_text: "Gestione elenco dei server"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "nl": //dutch
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Beheer van de Serverlijst",
|
|
|
|
context_serverhider_text: "Server zichtbaarheid",
|
|
|
|
submenu_hideserver_text: "Verberg server",
|
|
|
|
submenu_openhidemenu_text: "Beheer serverlijst"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "no": //norwegian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Administrasjon av serverlisten",
|
|
|
|
context_serverhider_text: "Server synlighet",
|
|
|
|
submenu_hideserver_text: "Skjul server",
|
|
|
|
submenu_openhidemenu_text: "Administrer serverliste"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "pl": //polish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Zarządzanie listą serwerów",
|
|
|
|
context_serverhider_text: "Widoczność serwera",
|
|
|
|
submenu_hideserver_text: "Ukryj serwer",
|
|
|
|
submenu_openhidemenu_text: "Zarządzaj listą serwerów"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "pt-BR": //portuguese (brazil)
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Gerenciamento da lista de servidores",
|
|
|
|
context_serverhider_text: "Visibilidade do servidor",
|
|
|
|
submenu_hideserver_text: "Ocultar servidor",
|
|
|
|
submenu_openhidemenu_text: "Gerenciar lista de servidores"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "fi": //finnish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Palvelinluettelon hallinta",
|
|
|
|
context_serverhider_text: "Palvelimen näkyvyys",
|
|
|
|
submenu_hideserver_text: "Piilota palvelin",
|
|
|
|
submenu_openhidemenu_text: "Hallinnoi palvelinluetteloa"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "sv": //swedish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Hantering av serverlistan",
|
|
|
|
context_serverhider_text: "Server sikt",
|
|
|
|
submenu_hideserver_text: "Dölj server",
|
|
|
|
submenu_openhidemenu_text: "Hantera serverlistan"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "tr": //turkish
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Sunucu Listesinin Yönetimi",
|
|
|
|
context_serverhider_text: "Sunucu görünürlüğü",
|
|
|
|
submenu_hideserver_text: "Sunucuyu Gizle",
|
|
|
|
submenu_openhidemenu_text: "Sunucu Listesini Yönet"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "cs": //czech
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Správa seznamu serverů",
|
|
|
|
context_serverhider_text: "Viditelnost serveru",
|
|
|
|
submenu_hideserver_text: "Skrýt server",
|
|
|
|
submenu_openhidemenu_text: "Správa seznamu serverů"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "bg": //bulgarian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Управление на списъка със сървъри",
|
|
|
|
context_serverhider_text: "Видимост на сървъра",
|
|
|
|
submenu_hideserver_text: "Скриване на сървър",
|
|
|
|
submenu_openhidemenu_text: "Управление на списъка със сървъри"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "ru": //russian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Управление списком серверов",
|
|
|
|
context_serverhider_text: "Видимость сервера",
|
|
|
|
submenu_hideserver_text: "Скрыть сервер",
|
|
|
|
submenu_openhidemenu_text: "Управление списком серверов"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "uk": //ukrainian
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Управління списком серверів",
|
|
|
|
context_serverhider_text: "Видимість сервера",
|
|
|
|
submenu_hideserver_text: "Сховати сервер",
|
|
|
|
submenu_openhidemenu_text: "Управління списком серверів"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "ja": //japanese
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "サーバリストの管理",
|
|
|
|
context_serverhider_text: "サーバーの可視性",
|
|
|
|
submenu_hideserver_text: "サーバーを隠す",
|
|
|
|
submenu_openhidemenu_text: "サーバーリストを管理する"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "zh-TW": //chinese (traditional)
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "管理服务器列表",
|
|
|
|
context_serverhider_text: "服務器可見性",
|
|
|
|
submenu_hideserver_text: "隐藏服务器",
|
|
|
|
submenu_openhidemenu_text: "管理服务器列表"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
case "ko": //korean
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "서버 목록 관리",
|
|
|
|
context_serverhider_text: "서버 가시성",
|
|
|
|
submenu_hideserver_text: "서버 숨기기",
|
|
|
|
submenu_openhidemenu_text: "서버 목록 관리"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
default: //default: english
|
|
|
|
return {
|
2019-01-05 01:22:16 +01:00
|
|
|
modal_header_text: "Managing Serverlist",
|
|
|
|
context_serverhider_text: "Server Visibility",
|
|
|
|
submenu_hideserver_text: "Hide Server",
|
|
|
|
submenu_openhidemenu_text: "Manage Serverlist"
|
2018-10-11 10:21:26 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|