From a3d97c9ffa66ff776a77d528dc75979b242c74c6 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sat, 29 Aug 2020 10:23:45 +0200 Subject: [PATCH] new plugin --- Plugins/PluginRepo/res/PluginList.txt | 1 + Plugins/README.md | 1 + Plugins/ServerCounter/README.md | 12 +++ Plugins/ServerCounter/ServerCounter.plugin.js | 85 +++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 Plugins/ServerCounter/README.md create mode 100644 Plugins/ServerCounter/ServerCounter.plugin.js diff --git a/Plugins/PluginRepo/res/PluginList.txt b/Plugins/PluginRepo/res/PluginList.txt index bc14838112..99ad5e2681 100644 --- a/Plugins/PluginRepo/res/PluginList.txt +++ b/Plugins/PluginRepo/res/PluginList.txt @@ -85,6 +85,7 @@ https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/R https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RemoveNicknames/RemoveNicknames.plugin.js https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SendLargeMessages/SendLargeMessages.plugin.js +https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerCounter/ServerCounter.plugin.js https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerFolders/ServerFolders.plugin.js https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerHider/ServerHider.plugin.js https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js diff --git a/Plugins/README.md b/Plugins/README.md index 9004d2aeed..d827c6fc26 100644 --- a/Plugins/README.md +++ b/Plugins/README.md @@ -44,6 +44,7 @@ - [Remove Nicknames](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveNicknames) - Replace all nicknames with the actual accountnames. - [Reveal All Spoilers Option](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RevealAllSpoilersOption) - Adds an entry to the message contextmenu to reveal all spoilers within a messageblock. - [Send Large Messages](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SendLargeMessages) - Opens a popout when your message is too large, which allows you to automatically send the message in several smaller messages. + - [Server Counter](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerCounter) - Adds a server counter to the server list. - [Server Hider](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerHider) - Adds two options on your server context menu to hide servers in your server list. - [Server Folders](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerFolders) - Patches Discords native Folders in a way to open Servers within a Folder in a new bar to the right. Also adds a bunch of new features to more easily organize, customize and manage your Folders. - [Show Hidden Channels](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels) - Displays all hidden channels that can't be accessed due to role restrictions in a new category. diff --git a/Plugins/ServerCounter/README.md b/Plugins/ServerCounter/README.md new file mode 100644 index 0000000000..0385aaa591 --- /dev/null +++ b/Plugins/ServerCounter/README.md @@ -0,0 +1,12 @@ +# Server Counter - [![Downlad][download-badge]][download-link] [![Paypal][paypal-badge]][paypal-link] [![Patreon][patreon-badge]][patreon-link] + +[download-badge]: https://img.shields.io/badge/Download-Plugin-brightgreen.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADGGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjaY2BgnuDo4uTKJMDAUFBUUuQe5BgZERmlwH6egY2BmYGBgYGBITG5uMAxIMCHgYGBIS8/L5UBFTAyMHy7xsDIwMDAcFnX0cXJlYE0wJpcUFTCwMBwgIGBwSgltTiZgYHhCwMDQ3p5SUEJAwNjDAMDg0hSdkEJAwNjAQMDg0h2SJAzAwNjCwMDE09JakUJAwMDg3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DuJbsxQrER+YYrXaI2D8EZyAEfangj2Fq0NrnBWry8YI5yb7rkRbBrDAK7X9NevlAYCL7Kns79iQKcunOU0+iO0fuSzV1QyUNjkU2b9wS66qm2nt8L3Q/oO7Gk3tWO2InzPtv3isU9RP9jqxmR8LMKsqdPVqFoC8qiDM/HiAcFUQZ34IYDr0VUGW+QEfK8BkVZBmfqkAWVWQZ37JAOA+n/nEtnh/wGd8JWP81Nt0P0r8Wu4ADvAHAOq2fsaP4N8BvFXi/ZoB3FYCcJMNKDbQw9Kc7YdoYfDzB+6xjUuM5mY+wsXYHvgeABIzsPkSOM/lAAAAAElFTkSuQmCC&style=flat +[download-link]: https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerCounter/ServerCounter.plugin.js + +[paypal-badge]: https://img.shields.io/badge/Paypal-Donate!-%23003087.svg?logo=paypal&style=flat +[paypal-link]: https://paypal.me/MircoWittrien + +[patreon-badge]: https://img.shields.io/badge/Patreon-Support!-%23F96854.svg?logo=patreon&style=flat +[patreon-link]: https://patreon.com/MircoWittrien + +Adds a server counter to the server list. diff --git a/Plugins/ServerCounter/ServerCounter.plugin.js b/Plugins/ServerCounter/ServerCounter.plugin.js new file mode 100644 index 0000000000..befe9e91a4 --- /dev/null +++ b/Plugins/ServerCounter/ServerCounter.plugin.js @@ -0,0 +1,85 @@ +//META{"name":"ServerCounter","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerCounter","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerCounter/ServerCounter.plugin.js"}*// + +var ServerCounter = (_ => { + return class ServerCounter { + getName () {return "ServerCounter";} + + getVersion () {return "1.0.0";} + + getAuthor () {return "DevilBro";} + + getDescription () {return "Adds a server counter to the server list.";} + + constructor () { + this.patchedModules = { + after: { + Guilds: "render" + } + }; + } + + // Legacy + load () { + if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this); + } + + start () { + if (!window.BDFDB) window.BDFDB = {myPlugins:{}}; + if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this; + let 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.min.js"); + libraryScript.setAttribute("date", performance.now()); + libraryScript.addEventListener("load", _ => {this.initialize();}); + document.head.appendChild(libraryScript); + } + else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize(); + this.startTimeout = setTimeout(_ => { + try {return this.initialize();} + catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);} + }, 30000); + } + + initialize () { + if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { + if (this.started) return; + BDFDB.PluginUtils.init(this); + + BDFDB.ModuleUtils.forceAllUpdates(this); + } + else { + console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!'); + } + } + + stop () { + if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { + this.stopping = true; + + BDFDB.ModuleUtils.forceAllUpdates(this); + + BDFDB.PluginUtils.clear(this); + } + } + + + // Begin of own functions + + processGuilds (e) { + let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ConnectedUnreadDMs"}); + if (index > -1) children.splice(index, 0, BDFDB.ReactUtils.createElement("div", { + className: BDFDB.disCN.guildouter, + children: BDFDB.ReactUtils.createElement("div", { + className: BDFDB.disCNS.guildslabel + BDFDB.disCN._servercounterservercount, + children: `servers - ${BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds().length}` + }) + })); + } + } +})(); + +module.exports = ServerCounter; \ No newline at end of file