From 15fd0fccdd9a15f8beeaec80dc81ed85f109d6f9 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Tue, 15 Mar 2022 21:19:09 +0100 Subject: [PATCH] Update ThemeSettings.plugin.js --- Plugins/ThemeSettings/ThemeSettings.plugin.js | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Plugins/ThemeSettings/ThemeSettings.plugin.js b/Plugins/ThemeSettings/ThemeSettings.plugin.js index 330d17d512..a57a02cc24 100644 --- a/Plugins/ThemeSettings/ThemeSettings.plugin.js +++ b/Plugins/ThemeSettings/ThemeSettings.plugin.js @@ -2,7 +2,7 @@ * @name ThemeSettings * @author DevilBro * @authorId 278543574059057154 - * @version 1.3.3 + * @version 1.3.4 * @description Allows you to change Theme Variables within Discord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,13 +17,8 @@ module.exports = (_ => { "info": { "name": "ThemeSettings", "author": "DevilBro", - "version": "1.3.3", + "version": "1.3.4", "description": "Allows you to change Theme Variables within Discord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page" - }, - "changeLog": { - "added": { - "Reset": "Added a Button to reset all Values back to the Value that was used when you opened the Settings" - } } }; @@ -79,30 +74,30 @@ module.exports = (_ => { } onStart () { - this.addListObserver(document.querySelector(`${BDFDB.dotCN.layer}[aria-label="${BDFDB.DiscordConstants.Layers.USER_SETTINGS}"]`)); + for (let settingsView of document.querySelectorAll(BDFDB.dotCN.layer + BDFDB.dotCN.settingswindowstandardsidebarview)) this.addListObserver(BDFDB.DOMUtils.getParent(BDFDB.dotCN.layer, settingsView)); BDFDB.ReactUtils.forceUpdate(this); } onStop () { - BDFDB.DOMUtils.remove(".theme-settings-button"); + BDFDB.DOMUtils.remove(BDFDB.dotCN._themesettingsbutton); } processSettingsView (e) { - if (e.node && e.node.parentElement && e.node.parentElement.getAttribute("aria-label") == BDFDB.DiscordConstants.Layers.USER_SETTINGS) this.addListObserver(e.node.parentElement); + this.addListObserver(BDFDB.DOMUtils.getParent(BDFDB.dotCN.layer, e.node)); } addListObserver (layer) { if (!layer) return; - BDFDB.ObserverUtils.connect(this, layer, {name: "cardObserver", instance: new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => { + BDFDB.ObserverUtils.connect(this, layer, {name: "cardObserver", instance: new MutationObserver(changes => changes.forEach(change => change.addedNodes.forEach(node => { if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) this.appendSettingsButton(node); if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child); - });}});})}, {childList: true, subtree: true}); + })))}, {childList: true, subtree: true}); for (let child of layer.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child); } appendSettingsButton (card) { - if (card.querySelector(".theme-settings-button")) return; + if (card.querySelector(BDFDB.dotCN._themesettingsbutton)) return; let addon = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props.addon"); if (addon && !addon.plugin && !addon.instance && addon.css) { let css = addon.css.replace(/\r/g, ""); @@ -121,7 +116,7 @@ module.exports = (_ => { if (imports.length || vars.length) { let footerControls = card.querySelector(BDFDB.dotCNS._repofooter + BDFDB.dotCN._repocontrols); let settingsButton = document.createElement("button"); - settingsButton.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton, "theme-settings-button"); + settingsButton.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton, BDFDB.disCN._themesettingsbutton); settingsButton.appendChild(BDFDB.DOMUtils.create(``)); footerControls.insertBefore(settingsButton, footerControls.firstElementChild); settingsButton.addEventListener("click", _ => {