From 5f57e78ea0089287aad81d851c6cb95a8d9d2ad2 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Sat, 27 Apr 2019 08:48:35 +0200 Subject: [PATCH] stuff --- .../ReadAllNotificationsButton.plugin.js | 24 +++++++++++++------ Themes/BasicBackground/BasicBackground.css | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js index 5797b06b4b..0e7beb1b3c 100644 --- a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js +++ b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js @@ -3,7 +3,7 @@ class ReadAllNotificationsButton { getName () {return "ReadAllNotificationsButton";} - getVersion () {return "1.4.6";} + getVersion () {return "1.4.7";} getAuthor () {return "DevilBro";} @@ -11,7 +11,7 @@ class ReadAllNotificationsButton { initConstructor () { this.changelog = { - "fixed":[["New Classes","Fixed the plugin for the new class update"]] + "fixed":[["Button above home button","Fixed the issue where the read all button would sometimes appear above the home button"]] }; this.patchModules = { @@ -149,10 +149,10 @@ class ReadAllNotificationsButton { processGuilds (instance, wrapper) { BDFDB.removeEles(".RANbutton-frame"); - let guildseparator = wrapper.querySelector(BDFDB.dotCN.guildseparator); - if (guildseparator) { + let insertnode = this.getInsertNode(); + if (insertnode) { let ranbutton = BDFDB.htmlToElement(this.RANbuttonMarkup); - guildseparator.parentElement.parentElement.insertBefore(ranbutton, guildseparator.parentElement); + insertnode.parentElement.insertBefore(ranbutton, insertnode); ranbutton.addEventListener("click", () => { let settings = BDFDB.getAllData(this, "settings"); if (settings.includeGuilds) BDFDB.markGuildAsRead(settings.includeMuted ? BDFDB.readServerList() : BDFDB.readUnreadServerList()); @@ -180,8 +180,8 @@ class ReadAllNotificationsButton { processDirectMessage (instance, wrapper, methodnames) { let ranbutton = document.querySelector(".RANbutton-frame"); - let guildseparator = wrapper.parentElement.parentElement.querySelector(BDFDB.dotCN.guildseparator); - if (ranbutton && guildseparator) guildseparator.parentElement.parentElement.insertBefore(ranbutton, guildseparator.parentElement); + let insertnode = this.getInsertNode(); + if (ranbutton && insertnode) insertnode.parentElement.insertBefore(ranbutton, insertnode); } processRecentMentions (instance, wrapper) { @@ -206,6 +206,16 @@ class ReadAllNotificationsButton { } } + getInsertNode () { + let homebutton = BDFDB.getParentEle(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCN.homebuttonicon)); + let nextsibling = homebutton.nextElementSibling, insertnode = null; + while (nextsibling && insertnode == null) { + if (nextsibling.querySelector(`${BDFDB.dotCN.guildseparator}:not(.folderseparator)`)) insertnode = nextsibling; + nextsibling = nextsibling.nextElementSibling + } + return insertnode; + } + setLabelsByLanguage () { switch (BDFDB.getDiscordLanguage().id) { case "hr": //croatian diff --git a/Themes/BasicBackground/BasicBackground.css b/Themes/BasicBackground/BasicBackground.css index b3482085ef..d9299b2011 100644 --- a/Themes/BasicBackground/BasicBackground.css +++ b/Themes/BasicBackground/BasicBackground.css @@ -740,7 +740,7 @@ img[src="/assets/bfffd518c76d3f6bc5e96eb52e4ae2cf.svg"], .searchFilter-2ESiM3, .searchAnswer-3Dz2-q, .progressBar-3u8FBM, -.aka-1mqp34, +.akaBadge-1M-1Gw, .item-26Dhrx[style*="background-color: rgb(114, 137, 218)"], .valueChecked-m-4IJZ:not([style*="background-color: rgba(255, 255, 255, 0.3)"]), .channel-2QD9_O.selected-1HYmZZ a,