From dfc94f1e9734d2d01fd4c59bf51d7e709dd20427 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Mon, 3 Feb 2020 10:38:26 +0100 Subject: [PATCH] new plugin --- Plugins/QuickMention/QuickMention.plugin.js | 78 +++++++++++++++++++++ Plugins/QuickMention/README.md | 12 ++++ 2 files changed, 90 insertions(+) create mode 100644 Plugins/QuickMention/QuickMention.plugin.js create mode 100644 Plugins/QuickMention/README.md diff --git a/Plugins/QuickMention/QuickMention.plugin.js b/Plugins/QuickMention/QuickMention.plugin.js new file mode 100644 index 0000000000..cd8b1533b2 --- /dev/null +++ b/Plugins/QuickMention/QuickMention.plugin.js @@ -0,0 +1,78 @@ +//META{"name":"QuickMention","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/QuickMention","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/QuickMention/QuickMention.plugin.js"}*// + +var QuickMention = (_ => { + return class QuickMention { + getName () {return "QuickMention";} + + getVersion () {return "1.0.0";} + + getAuthor () {return "DevilBro";} + + getDescription () {return "Adds a mention entry to the message option toolbar.";} + + //legacy + load () {} + + 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); + } + 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.PluginUtils.clear(this); + } + } + + + // begin of own functions + + onMessageOptionToolbar (e) { + if (e.instance.props.message.author.id != BDFDB.UserUtils.me.id && e.instance.props.message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT && BDFDB.UserUtils.can("SEND_MESSAGES")) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, { + key: "mention", + text: BDFDB.LanguageUtils.LanguageStrings.MENTION, + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, { + className: BDFDB.disCNS.messagetoolbarbutton, + onClick: _ => { + BDFDB.LibraryModules.DispatchUtils.ComponentDispatch.dispatchToLastSubscribed(BDFDB.DiscordConstants.ComponentActions.INSERT_TEXT, { + content: `<@!${e.instance.props.message.author.id}>` + }); + }, + children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { + className: BDFDB.disCNS.messagetoolbaricon, + nativeClass: true, + name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_AT + }) + }) + })); + } + } +})(); \ No newline at end of file diff --git a/Plugins/QuickMention/README.md b/Plugins/QuickMention/README.md new file mode 100644 index 0000000000..235669a51a --- /dev/null +++ b/Plugins/QuickMention/README.md @@ -0,0 +1,12 @@ +# Quick Mention - [![Downlad][download-badge]][download-link] [![Paypal][paypal-badge]][paypal-link] [![Patreon][patreon-badge]][patreon-link] + +[download-badge]: https://img.shields.io/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OJJ/9dX7SRe1LR68kXv13fc5Nm1t379TfU75/4mHeY7En+59lvhB5efB1/lv5dxc+NH0y/fzq64Lv4T8Ffp360/rP8f9/AA0ADzT6lvFdAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAF1SURBVHja7JihTgNBEIb/K1WkBtEEAsESBKEvgEKRAhLHOxAMfQ9cHwEMBoFA1/ACBEGgzbkmUAwI+BENubTs9WZmLz1CZtZd9v7/u9vMZGdAGFabA05Hn3sWrYQwRB9rwafreikbQN5LiV6qhorDARzAARzAARzAARzAARzAARygGOAQ6a+GLr9jmlwpDuJbsxQrER+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/QuickMention/QuickMention.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 mention entry to the message option toolbar.