From 5ca704cc20f8eb1f710ff424162a3122b3cb90fb Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 14 Jun 2019 11:13:15 +0200 Subject: [PATCH] stuff --- Plugins/PluginRepo/PluginRepo.plugin.js | 9 ++++++--- Plugins/ThemeRepo/ThemeRepo.plugin.js | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Plugins/PluginRepo/PluginRepo.plugin.js b/Plugins/PluginRepo/PluginRepo.plugin.js index de4c904ec4..d1d209a899 100644 --- a/Plugins/PluginRepo/PluginRepo.plugin.js +++ b/Plugins/PluginRepo/PluginRepo.plugin.js @@ -627,7 +627,7 @@ class PluginRepo { result = result.replace(/[\r\t]/g, ""); BDFDB.saveData("urlbase64", btoa(result), this, "newentriesdata"); this.loadedPlugins = {}; - this.grabbedPlugins = result.split("\n"); + this.grabbedPlugins = result.split("\n").filter(n => n); this.foundPlugins = this.grabbedPlugins.concat(ownlist); this.loading = {is:true, timeout:setTimeout(() => { clearTimeout(this.loading.timeout); @@ -781,7 +781,10 @@ class PluginRepo { callback(); },600000); frame.messageReceived = e => { - if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { + if (!document.contains(frame)) { + window.removeEventListener("message", frame.messageReceived); + } + else if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { switch (e.data.reason) { case "OnLoad": frame.contentWindow.postMessage({origin:"PluginRepo",reason:"OnLoad"},"*"); @@ -897,7 +900,7 @@ class PluginRepo { let filename = data.url.split("/").pop(); require("fs").unlink(require("path").join(BDFDB.getPluginsFolder(), filename), (error) => { if (error) BDFDB.showToast(`Unable to delete Plugin "${filename}".`, {type:"danger"}); - else BDFDB.showToast(`Successfully deleted Plugin "${filename}".`, {type:"success"}); + else BDFDB.showToast(`Successfully deleted Plugin "${filename}".`); }); } diff --git a/Plugins/ThemeRepo/ThemeRepo.plugin.js b/Plugins/ThemeRepo/ThemeRepo.plugin.js index 1ca9c940ca..88c67ed51e 100644 --- a/Plugins/ThemeRepo/ThemeRepo.plugin.js +++ b/Plugins/ThemeRepo/ThemeRepo.plugin.js @@ -266,7 +266,7 @@ class ThemeRepo { top: 0 !important; } iframe.discordPreview ~ ${BDFDB.dotCNS.appmount + BDFDB.dotCN.titlebar}, - iframe.discordPreview ~ ${BDFDB.dotCNS.appmount + BDFDB.dotCN.app} { + iframe.discordPreview ~ ${BDFDB.dotCNS.appmount + BDFDB.dotCN.app} > *:not(.toasts):not(.bd-toasts) { opacity: 0 !important; visibility: hidden !important; } @@ -482,7 +482,11 @@ class ThemeRepo { }; var messageReceived = e => { - if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { + if (!document.contains(frame)) { + document.removeEventListener("keyup", keyPressed); + window.removeEventListener("message", messageReceived); + } + else if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { switch (e.data.reason) { case "OnLoad": var username = BDFDB.myData.username; @@ -752,7 +756,7 @@ class ThemeRepo { body = body.replace(/[\r\t]/g, ""); BDFDB.saveData("urlbase64", btoa(body), this, "newentriesdata"); this.loadedThemes = {}; - this.grabbedThemes = body.split("\n"); + this.grabbedThemes = body.split("\n").filter(n => n); request("https://github.com/NFLD99/Better-Discord", (error2, response2, body2) => { if (!error2 && body2) { NFLDreplace = /\/NFLD99\/Better-Discord\/tree\/master\/Themes_[^"]+">([^<]+)/i.exec(body2); @@ -911,7 +915,7 @@ class ThemeRepo { let filename = data.requesturl.split("/").pop(); require("fs").unlink(require("path").join(BDFDB.getThemesFolder(), filename), (error) => { if (error) BDFDB.showToast(`Unable to delete Theme "${filename}".`, {type:"danger"}); - else BDFDB.showToast(`Successfully deleted Theme "${filename}".`, {type:"success"}); + else BDFDB.showToast(`Successfully deleted Theme "${filename}".`); }); }