2019-01-31 17:06:48 +01: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-05-07 19:42:08 +02:00
|
|
|
|
getVersion () {return "6.0.7";}
|
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
|
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
|
initConstructor () {
|
2019-03-08 13:16:58 +01:00
|
|
|
|
this.changelog = {
|
2019-05-07 19:42:08 +02:00
|
|
|
|
"fixed":[["Server Object","Changes in the Server Object broke the plugin"]]
|
2019-03-08 13:16:58 +01: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-01-26 22:45:19 +01:00
|
|
|
|
|
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}">
|
|
|
|
|
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.modalheader}" style="flex: 0 0 auto;">
|
|
|
|
|
<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">
|
|
|
|
|
<h4 class="${BDFDB.disCNS.h4 + BDFDB.disCNS.headertitle + BDFDB.disCNS.size16 + BDFDB.disCNS.height20 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.defaultcolor + BDFDB.disCNS.h4defaultmargin + BDFDB.disCN.marginreset}">REPLACE_modal_header_text</h4>
|
|
|
|
|
<div class="${BDFDB.disCNS.modalguildname + BDFDB.disCNS.small + BDFDB.disCNS.size12 + BDFDB.disCNS.height16 + BDFDB.disCN.primary}"></div>
|
|
|
|
|
</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>
|
|
|
|
|
<div class="${BDFDB.disCNS.scrollerwrap + BDFDB.disCNS.modalcontent + BDFDB.disCNS.scrollerthemed + BDFDB.disCN.themeghosthairline}">
|
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>
|
|
|
|
|
<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + 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}">
|
|
|
|
|
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_btn_ok_text</div>
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" class="btn-all ${BDFDB.disCNS.button + BDFDB.disCNS.buttonlooklink + BDFDB.disCNS.buttoncolortransparent + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow}">
|
|
|
|
|
<div class="${BDFDB.disCN.buttoncontents}">REPLACE_btn_all_text</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 =
|
|
|
|
|
`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">
|
|
|
|
|
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCNS.overflowellipsis} serverhiderName" style="flex: 1 1 auto;"></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" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} serverhiderCheckbox">
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
|
|
this.serverContextEntryMarkup =
|
|
|
|
|
`<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
|
|
|
|
<div class="${BDFDB.disCN.contextmenuitem} serverhider-item ${BDFDB.disCN.contextmenuitemsubmenu}">
|
2019-04-18 09:28:20 +02:00
|
|
|
|
<span class="BDFDB-textscrollwrapper" speed=3><div class="BDFDB-textscroll">REPLACE_context_serverhider_text</div></span>
|
2019-01-05 01:22:16 +01:00
|
|
|
|
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
|
this.serverContextSubMenuMarkup =
|
|
|
|
|
`<div class="${BDFDB.disCN.contextmenu} serverhider-submenu">
|
|
|
|
|
<div class="${BDFDB.disCN.contextmenuitemgroup}">
|
|
|
|
|
<div class="${BDFDB.disCN.contextmenuitem} hideserver-item ${BDFDB.disCN.contextmenuitemdisabled}">
|
2019-04-18 09:28:20 +02:00
|
|
|
|
<span class="BDFDB-textscrollwrapper" speed=3><div class="BDFDB-textscroll">REPLACE_submenu_hideserver_text</div></span>
|
2019-01-05 01:22:16 +01:00
|
|
|
|
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="${BDFDB.disCN.contextmenuitem} openhidemenu-item">
|
2019-04-18 09:28:20 +02:00
|
|
|
|
<span class="BDFDB-textscrollwrapper" speed=3><div class="BDFDB-textscroll">REPLACE_submenu_openhidemenu_text</div></span>
|
2019-01-05 01:22:16 +01:00
|
|
|
|
<div class="${BDFDB.disCN.contextmenuhint}"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</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-03-08 13:16:58 +01:00
|
|
|
|
let settings = BDFDB.getAllData(this, "settings");
|
2019-04-18 09:28:20 +02:00
|
|
|
|
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.size18 + 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) {
|
|
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + 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-01-05 01:22:16 +01:00
|
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.flex2 + BDFDB.disCNS.horizontal + BDFDB.disCNS.horizontal2 + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.title + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.size16 + 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-01-17 23:48:29 +01:00
|
|
|
|
var libraryScript = document.querySelector('head script[src="https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js"]');
|
|
|
|
|
if (!libraryScript || performance.now() - libraryScript.getAttribute("date") > 600000) {
|
2018-10-11 10:21:26 +02:00
|
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
|
libraryScript = document.createElement("script");
|
|
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
|
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.js");
|
2019-01-17 23:48:29 +01:00
|
|
|
|
libraryScript.setAttribute("date", performance.now());
|
2019-01-30 21:23:49 +01:00
|
|
|
|
libraryScript.addEventListener("load", () => {if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();});
|
2018-10-11 10:21:26 +02:00
|
|
|
|
document.head.appendChild(libraryScript);
|
|
|
|
|
}
|
2019-01-17 23:48:29 +01: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.serverContextEntryMarkup = this.serverContextEntryMarkup.replace("REPLACE_context_serverhider_text", this.labels.context_serverhider_text);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
|
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_hideserver_text", this.labels.submenu_hideserver_text);
|
|
|
|
|
this.serverContextSubMenuMarkup = this.serverContextSubMenuMarkup.replace("REPLACE_submenu_openhidemenu_text", this.labels.submenu_openhidemenu_text);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-05 01:22:16 +01:00
|
|
|
|
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_modal_header_text", this.labels.modal_header_text);
|
|
|
|
|
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_ok_text", this.labels.btn_ok_text);
|
|
|
|
|
this.serverHiderModalMarkup = this.serverHiderModalMarkup.replace("REPLACE_btn_all_text", this.labels.btn_all_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-01-03 14:46:41 +01:00
|
|
|
|
onGuildContextMenu (instance, menu) {
|
2019-04-18 09:28:20 +02:00
|
|
|
|
if (document.querySelector(".BDFDB-modal")) return;
|
2019-01-05 01:22:16 +01:00
|
|
|
|
if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(".serverhider-item")) {
|
2019-01-16 00:14:18 +01:00
|
|
|
|
let serverContextEntry = BDFDB.htmlToElement(this.serverContextEntryMarkup);
|
2019-03-09 20:22:27 +01:00
|
|
|
|
let devgroup = BDFDB.React.findDOMNodeSafe(BDFDB.getOwnerInstance({node:menu,name:["DeveloperModeGroup","MessageDeveloperModeGroup"]}));
|
|
|
|
|
if (devgroup) devgroup.parentElement.insertBefore(serverContextEntry, devgroup);
|
|
|
|
|
else menu.appendChild(serverContextEntry, menu);
|
2019-01-16 00:14:18 +01:00
|
|
|
|
let hideritem = serverContextEntry.querySelector(".serverhider-item");
|
|
|
|
|
hideritem.addEventListener("mouseenter", () => {
|
|
|
|
|
let serverContextSubMenu = BDFDB.htmlToElement(this.serverContextSubMenuMarkup);
|
|
|
|
|
let openitem = serverContextSubMenu.querySelector(".openhidemenu-item");
|
|
|
|
|
openitem.addEventListener("click", () => {
|
2019-03-08 13:16:58 +01:00
|
|
|
|
BDFDB.closeContextMenu(menu);
|
2019-01-16 00:14:18 +01:00
|
|
|
|
this.showServerModal();
|
2018-10-11 10:21:26 +02:00
|
|
|
|
});
|
2019-01-16 00:14:18 +01:00
|
|
|
|
if (instance.props.guild && !instance.props.target.getAttribute("folder")) {
|
|
|
|
|
let hideitem = serverContextSubMenu.querySelector(".hideserver-item");
|
|
|
|
|
BDFDB.removeClass(hideitem, BDFDB.disCN.contextmenuitemdisabled);
|
|
|
|
|
hideitem.addEventListener("click", () => {
|
2019-03-08 13:16:58 +01:00
|
|
|
|
BDFDB.closeContextMenu(menu);
|
2019-01-16 00:14:18 +01:00
|
|
|
|
this.toggleServer(instance.props.guild, instance.props.target, false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
BDFDB.appendSubMenu(hideritem, serverContextSubMenu);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-04-25 22:23:17 +02:00
|
|
|
|
processGuild (instance, wrapper, 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")) {
|
|
|
|
|
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.modaldivider}"></div>`));
|
|
|
|
|
let entry = BDFDB.htmlToElement(this.serverEntryMarkup);
|
|
|
|
|
container.appendChild(entry);
|
|
|
|
|
let name = entry.querySelector(".serverhiderName");
|
|
|
|
|
name.innerText = info.name || "";
|
|
|
|
|
name.parentElement.insertBefore(this.createCopyOfServer(info), name);
|
|
|
|
|
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-16 00:14:18 +01:00
|
|
|
|
createCopyOfServer (info) {
|
|
|
|
|
let serverCopy = info.div.cloneNode(true);
|
2019-04-24 11:46:29 +02:00
|
|
|
|
BDFDB.removeEles(serverCopy.querySelectorAll(BDFDB.dotCNC.guildpill + BDFDB.dotCNC.guildbadgewrapper + "mask"));
|
|
|
|
|
serverCopy.style.setProperty("margin", "0");
|
|
|
|
|
serverCopy.style.setProperty("width", "48px");
|
|
|
|
|
serverCopy.style.setProperty("height", "48px");
|
2019-05-24 15:21:16 +02:00
|
|
|
|
serverCopy.style.setProperty("overflow", "hidden");
|
|
|
|
|
serverCopy.style.setProperty("border-radius", "50%");
|
|
|
|
|
serverCopy.querySelector("foreignObject").removeAttribute("mask");
|
2019-01-16 00:14:18 +01:00
|
|
|
|
BDFDB.toggleEles(serverCopy, true);
|
|
|
|
|
serverCopy.addEventListener("click", e => {
|
2019-02-22 20:35:27 +01:00
|
|
|
|
BDFDB.stopEvent(e);
|
2019-01-16 00:14:18 +01:00
|
|
|
|
info.div.querySelector("a").click();
|
|
|
|
|
});
|
|
|
|
|
serverCopy.addEventListener("contextmenu", e => {BDFDB.openGuildContextMenu(info.div, e);});
|
2019-01-05 01:22:16 +01:00
|
|
|
|
return serverCopy;
|
2019-01-05 01:01:34 +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-03-08 13:16:58 +01: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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Sve",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Alle",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Alle",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Todo",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Tout",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Tutto",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Alle",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Alle",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Wszystkie",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Todo",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Kaikki",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "All",
|
|
|
|
|
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",
|
|
|
|
|
btn_ok_text: "Okey",
|
|
|
|
|
btn_all_text: "Her",
|
|
|
|
|
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ů",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "Vše",
|
|
|
|
|
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: "Управление на списъка със сървъри",
|
|
|
|
|
btn_ok_text: "Добре",
|
|
|
|
|
btn_all_text: "Bсичко",
|
|
|
|
|
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: "Управление списком серверов",
|
|
|
|
|
btn_ok_text: "ОК",
|
|
|
|
|
btn_all_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: "Управління списком серверів",
|
|
|
|
|
btn_ok_text: "Добре",
|
|
|
|
|
btn_all_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: "サーバリストの管理",
|
|
|
|
|
btn_ok_text: "はい",
|
|
|
|
|
btn_all_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: "管理服务器列表",
|
|
|
|
|
btn_ok_text: "好",
|
|
|
|
|
btn_all_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: "서버 목록 관리",
|
|
|
|
|
btn_ok_text: "승인",
|
|
|
|
|
btn_all_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",
|
|
|
|
|
btn_ok_text: "OK",
|
|
|
|
|
btn_all_text: "All",
|
|
|
|
|
context_serverhider_text: "Server Visibility",
|
|
|
|
|
submenu_hideserver_text: "Hide Server",
|
|
|
|
|
submenu_openhidemenu_text: "Manage Serverlist"
|
2018-10-11 10:21:26 +02:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|