From 6f229873822e2cc46d1a695659a13d5e667fd1e5 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 9 Jul 2021 20:49:23 +0200 Subject: [PATCH] stuff --- .../MessageUtilities.plugin.js | 19 +- Plugins/README.md | 2 +- Plugins/RevealAllSpoilersOption/README.md | 4 +- .../RevealAllSpoilersOption.plugin.js | 180 ++++-------------- 4 files changed, 39 insertions(+), 166 deletions(-) diff --git a/Plugins/MessageUtilities/MessageUtilities.plugin.js b/Plugins/MessageUtilities/MessageUtilities.plugin.js index b2ffe0b6f5..53a146dc55 100644 --- a/Plugins/MessageUtilities/MessageUtilities.plugin.js +++ b/Plugins/MessageUtilities/MessageUtilities.plugin.js @@ -2,7 +2,7 @@ * @name MessageUtilities * @author DevilBro * @authorId 278543574059057154 - * @version 1.9.0 + * @version 1.9.1 * @description Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.) * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,13 +17,8 @@ module.exports = (_ => { "info": { "name": "MessageUtilities", "author": "DevilBro", - "version": "1.9.0", + "version": "1.9.1", "description": "Adds several Quick Actions for Messages (Delete, Edit, Pin, etc.)" - }, - "changeLog": { - "fixed": { - "Reply": "Works again" - } } }; @@ -100,8 +95,7 @@ module.exports = (_ => { "Copy_Link": {name: "Copy Message Link", func: this.doCopyLink, value: {click: 0, keycombo: [17,81]} }, "__Quote_Message": {name: "Quote Message", func: this.doQuote, value: {click: 0, keycombo: [17,87]}, plugin: "CustomQuoter"}, "__Note_Message": {name: "Note Message", func: this.doNote, value: {click: 0, keycombo: [16]}, plugin: "PersonalPins"}, - "__Translate_Message": {name: "Translate Message", func: this.doTranslate, value: {click: 0, keycombo: [20]}, plugin: "GoogleTranslateOption"}, - "__Reveal_Spoilers": {name: "Reveal All Spoilers", func: this.doReveal, value: {click: 0, keycombo: [17,74]}, plugin: "RevealAllSpoilersOption"} + "__Translate_Message": {name: "Translate Message", func: this.doTranslate, value: {click: 0, keycombo: [20]}, plugin: "GoogleTranslateOption"} } }; @@ -317,6 +311,7 @@ module.exports = (_ => { } onClick (event, message) { + if (BDFDB.DOMUtils.getParent(BDFDB.dotCNC.messagebuttons + BDFDB.dotCN.spoilerhidden, event.target)) return; let type = event.type; if (!firedEvents.includes(type)) { firedEvents.push(type); @@ -459,12 +454,6 @@ module.exports = (_ => { if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel); } } - - doReveal ({messageDiv, message}, action, event) { - if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) { - BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv); - } - } formatToast (string) { return typeof string == "string" ? (string.endsWith(".") || string.endsWith("!") ? string.slice(0, -1) : string) : ""; diff --git a/Plugins/README.md b/Plugins/README.md index 8786057470..2c624ca256 100644 --- a/Plugins/README.md +++ b/Plugins/README.md @@ -46,7 +46,7 @@ - [Read All Notifications Button](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ReadAllNotificationsButton) - Adds a Clear Button to the Server List and the Mentions Popout - [Remove Blocked Messages](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveBlockedMessages) - Removes blocked Messages/Users - [Remove Nicknames](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveNicknames) - Replaces Nicknames with Accountnames - - [Reveal All Spoilers Option](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RevealAllSpoilersOption) - Allows you to reveal all Spoilers within a Message + - [Reveal All Spoilers Option](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RevealAllSpoilersOption) - Allows you to reveal all Spoilers within a Message/Status by holding the Ctrl Key and clicking a Spoiler - [Send Large Messages](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SendLargeMessages) - Allows you to enter larger Messages, which will automatically split into several smaller Messages - [Server Counter](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerCounter) - Adds a Server Counter to the Server List - [Server Details](https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerDetails) - Shows Server Details in the Server List Tooltip diff --git a/Plugins/RevealAllSpoilersOption/README.md b/Plugins/RevealAllSpoilersOption/README.md index df70ccfa19..3097c4c8fd 100644 --- a/Plugins/RevealAllSpoilersOption/README.md +++ b/Plugins/RevealAllSpoilersOption/README.md @@ -12,7 +12,7 @@ [patreon-badge]: https://img.shields.io/badge/Patreon-%23F96854.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAdhwAAHYcBj+XxZQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAGBSURBVFiF7Za9ThtBFEbPBUpERWMwCorfJjY4aVLxBFHCKyCl4hWQUqVMBULmbfiRCNACqSJsDsXakjHGO8Y7ovFXrmbmO3NnZ74bqrzUeUR8HPP9mdQ60AZawCZQBwK4BC6ADnAUEZeTFhmnsxLjdfVAfXhl/rB66h/1QyUAalu9TzAe1Z26NROAutvf0VvVU7+/CUD9PKP5MMT2VADqhvqvAvOB7tQ1gIXXznpEP4HlxLEpWgH2AEInX0OLv/cUWKwQAKALbKZU4EsGc4AloJ0C8CmD+UDNFIBGRoBGCkAtI8B66i3IpccUgJuMANcpAKcZAc5SAE4yAnRSAA6BXgbzLnBUChARF8DvDAC/IuIqNYzqFYfRrVqDxDCKiL/AV6o5ikdgJyJuBrsrrcBQJX44W0/QVb+NLpoM0B/f6pdwWt2qL3NlWoD+nFV1X/2fYPxg0cCOfdJL+4ESkBqwDTQpQmuNoi2/onjAOsBxRFxPWmTqClSp9w6jOcAcYA7AE1OMk5ulhBZCAAAAAElFTkSuQmCC [patreon-link]: https://patreon.com/MircoWittrien -Allows you to reveal all Spoilers within a Message +Allows you to reveal all Spoilers within a Message/Status by holding the Ctrl Key and clicking a Spoiler -![screenshot1](https://mwittrien.github.io/BetterDiscordAddons/Plugins/RevealAllSpoilersOption/_res/screenshot1.png) \ No newline at end of file +![cover](https://mwittrien.github.io/BetterDiscordAddons/Plugins/RevealAllSpoilersOption/_res/cover.png) \ No newline at end of file diff --git a/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js b/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js index b1ab36969f..e53db0a37f 100644 --- a/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js +++ b/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js @@ -2,8 +2,8 @@ * @name RevealAllSpoilersOption * @author DevilBro * @authorId 278543574059057154 - * @version 1.0.5 - * @description Allows you to reveal all Spoilers within a Message + * @version 1.0.6 + * @description Allows you to reveal all Spoilers within a Message/Status by holding the Ctrl Key and clicking a Spoiler * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien * @patreon https://www.patreon.com/MircoWittrien @@ -17,8 +17,14 @@ module.exports = (_ => { "info": { "name": "RevealAllSpoilersOption", "author": "DevilBro", - "version": "1.0.5", - "description": "Allows you to reveal all Spoilers within a Message" + "version": "1.0.6", + "description": "Allows you to reveal all Spoilers within a Message/Status by holding the Ctrl Key and clicking a Spoiler" + }, + "changeLog": { + "improved": { + "Behaviour": "You no longer need to right click a message and press reveal all, simply hold Ctrl and click a Spoiler", + "About Me": "Also works on About Mes" + } } }; @@ -69,152 +75,30 @@ module.exports = (_ => { } } : (([Plugin, BDFDB]) => { return class RevealAllSpoilersOption extends Plugin { - onLoad () {} - - onStart () {} - - onStop () {} - - onMessageContextMenu (e) { - if (e.instance.props.message && e.instance.props.target) { - let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, e.instance.props.target); - if (!messageDiv || !messageDiv.querySelector(BDFDB.dotCN.spoilerhidden)) return; - let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null; - let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true}); - children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.reveal_all, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "reveal-all"), - hint: hint && (_ => { - return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, { - hint: hint - }); - }), - action: _ => { - this.revealAllSpoilers(messageDiv); - } - }) - })); - } + onLoad () { + this.patchedModules = { + after: { + Spoiler: "render" + } + }; } - - revealAllSpoilers (target) { - let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, target); - if (!messageDiv) return; - for (let spoiler of messageDiv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click(); + + onStart () { + BDFDB.PatchUtils.forceAllUpdates(this); } - - setLabelsByLanguage () { - switch (BDFDB.LanguageUtils.getLanguage().id) { - case "bg": // Bulgarian - return { - reveal_all: "Разкрийте всички спойлери" - }; - case "da": // Danish - return { - reveal_all: "Afslør alle spoilere" - }; - case "de": // German - return { - reveal_all: "Zeige alle Spoiler" - }; - case "el": // Greek - return { - reveal_all: "Αποκαλύψτε όλα τα Spoilers" - }; - case "es": // Spanish - return { - reveal_all: "Revelar todos los spoilers" - }; - case "fi": // Finnish - return { - reveal_all: "Paljasta kaikki spoilerit" - }; - case "fr": // French - return { - reveal_all: "Révéler tous les spoilers" - }; - case "hr": // Croatian - return { - reveal_all: "Otkrijte sve spojlere" - }; - case "hu": // Hungarian - return { - reveal_all: "Feltárja az összes spoilert" - }; - case "it": // Italian - return { - reveal_all: "Rivela tutti gli spoiler" - }; - case "ja": // Japanese - return { - reveal_all: "すべてのネタバレを明らかにする" - }; - case "ko": // Korean - return { - reveal_all: "모든 스포일러 공개" - }; - case "lt": // Lithuanian - return { - reveal_all: "Atskleiskite visus spoilerius" - }; - case "nl": // Dutch - return { - reveal_all: "Onthul alle spoilers" - }; - case "no": // Norwegian - return { - reveal_all: "Avslør alle spoilere" - }; - case "pl": // Polish - return { - reveal_all: "Odkryj wszystkie spoilery" - }; - case "pt-BR": // Portuguese (Brazil) - return { - reveal_all: "Revelar todos os spoilers" - }; - case "ro": // Romanian - return { - reveal_all: "Dezvăluie toate spoilerele" - }; - case "ru": // Russian - return { - reveal_all: "Показать все спойлеры" - }; - case "sv": // Swedish - return { - reveal_all: "Avslöja alla spoilers" - }; - case "th": // Thai - return { - reveal_all: "เปิดเผยสปอยเลอร์ทั้งหมด" - }; - case "tr": // Turkish - return { - reveal_all: "Tüm Spoilerleri Göster" - }; - case "uk": // Ukrainian - return { - reveal_all: "Розкрийте всі спойлери" - }; - case "vi": // Vietnamese - return { - reveal_all: "Tiết lộ tất cả Spoilers" - }; - case "zh-CN": // Chinese (China) - return { - reveal_all: "显示所有剧透" - }; - case "zh-TW": // Chinese (Taiwan) - return { - reveal_all: "顯示所有劇透" - }; - default: // English - return { - reveal_all: "Reveal all Spoilers" - }; - } + + onStop () { + BDFDB.PatchUtils.forceAllUpdates(this); + } + + processSpoiler (e) { + BDFDB.PatchUtils.patch(this, e.instance, "revealSpoiler", {after: e2 => { + if (e2.methodArguments[0].ctrlKey) { + BDFDB.ListenerUtils.stopEvent(e2.methodArguments[0]); + let parent = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.message + BDFDB.dotCN.userpopoutaboutmebody, e2.methodArguments[0].target); + if (parent) for (let spoiler of parent.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click(); + } + }}, {force: true, noCache: true}); } }; })(window.BDFDB_Global.PluginUtils.buildPlugin(config));