diff --git a/Plugins/PluginRepo/PluginRepo.plugin.js b/Plugins/PluginRepo/PluginRepo.plugin.js index b427577c3a..3e9e121374 100644 --- a/Plugins/PluginRepo/PluginRepo.plugin.js +++ b/Plugins/PluginRepo/PluginRepo.plugin.js @@ -604,7 +604,7 @@ class PluginRepo { BDFDB.removeEles("iframe.discordSandbox",".pluginrepo-loadingicon"); var settings = BDFDB.loadAllData(this, "settings"); var getPluginInfo, createFrame, runInFrame; - var frame, framerunning = false, framequeue = [], outdated = 0, newentries = 0, i = 0; + var frame, framekey = Math.round(Math.random()*10000000000000000), framerunning = false, framequeue = [], outdated = 0, newentries = 0, i = 0; var tags = ["getName", "getVersion", "getAuthor", "getDescription"]; var seps = ["\"", "\'", "\`"]; var newentriesdata = BDFDB.loadAllData(this, "newentriesdata"), ownlist = BDFDB.loadData("ownlist", this, "ownlist") || []; @@ -763,10 +763,10 @@ class PluginRepo { callback(); },600000); frame.messageReceived = e => { - if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { + if (typeof e.data === "object" && e.data.origin == "DiscordPreview" && e.data.framekey == framekey) { switch (e.data.reason) { case "OnLoad": - frame.contentWindow.postMessage({origin:"PluginRepo",reason:"OnLoad"},"*"); + frame.contentWindow.postMessage({origin:"PluginRepo",reason:"OnLoad",framekey},"*"); callback(); break; } @@ -799,7 +799,7 @@ class PluginRepo { runInFrame(); }; var evalResultReceived = e => { - if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { + if (typeof e.data === "object" && e.data.origin == "DiscordPreview" && e.data.framekey == framekey) { switch (e.data.reason) { case "EvalResult": window.removeEventListener("message", evalResultReceived); @@ -809,7 +809,7 @@ class PluginRepo { } }; window.addEventListener("message", evalResultReceived); - frame.contentWindow.postMessage({origin:"PluginRepo",reason:"Eval",jsstring:` + frame.contentWindow.postMessage({origin:"PluginRepo",reason:"Eval",framekey,jsstring:` try { ${body} var p = new ${name}(); diff --git a/Plugins/ThemeRepo/ThemeRepo.plugin.js b/Plugins/ThemeRepo/ThemeRepo.plugin.js index ef62fb22d8..3dd6958589 100644 --- a/Plugins/ThemeRepo/ThemeRepo.plugin.js +++ b/Plugins/ThemeRepo/ThemeRepo.plugin.js @@ -484,9 +484,9 @@ class ThemeRepo { var avatar = BDFDB.getUserAvatar(); var nativecss = document.querySelector("head link[rel='stylesheet'][integrity]"); nativecss = nativecss && nativecss.href ? nativecss.href : null; - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"OnLoad",username,id,discriminator,avatar,nativecss},"*"); - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"DarkLight",checked:darklightinput.checked,light:BDFDB.disCN.themelight,dark:BDFDB.disCN.themedark},"*"); - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"Normalize",checked:normalizeinput.checked},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"OnLoad",framekey,username,id,discriminator,avatar,nativecss},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"DarkLight",framekey,checked:darklightinput.checked,light:BDFDB.disCN.themelight,dark:BDFDB.disCN.themedark},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"Normalize",framekey,checked:normalizeinput.checked},"*"); break; case "KeyUp": keyPressed(e.data); @@ -499,6 +499,7 @@ class ThemeRepo { window.addEventListener("message", messageReceived); var frame = BDFDB.htmlToElement(this.frameMarkup); + var framekey = Math.round(Math.random()*10000000000000000); var themeRepoModal = BDFDB.htmlToElement(this.themeRepoModalMarkup); var hiddenSettings = BDFDB.loadAllData(this, "hidden"); var darklightinput = themeRepoModal.querySelector("#input-darklight"); @@ -527,17 +528,17 @@ class ThemeRepo { } darklightinput.addEventListener("change", e => { - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"DarkLight",checked:darklightinput.checked,light:BDFDB.disCN.themelight,dark:BDFDB.disCN.themedark},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"DarkLight",framekey,checked:darklightinput.checked,light:BDFDB.disCN.themelight,dark:BDFDB.disCN.themedark},"*"); }); normalizeinput.addEventListener("change", e => { - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"Normalize",checked:normalizeinput.checked},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"Normalize",framekey,checked:normalizeinput.checked},"*"); }); customcssinput.addEventListener("change", e => { var customCSS = document.querySelector("style#customcss"); - if (customCSS && customCSS.innerText.length > 0) frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"CustomCSS",checked:customcssinput.checked,css:customCSS.innerText},"*"); + if (customCSS && customCSS.innerText.length > 0) frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"CustomCSS",framekey,checked:customcssinput.checked,css:customCSS.innerText},"*"); }); themefixerinput.addEventListener("change", e => { - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"ThemeFixer",checked:themefixerinput.checked,css:this.themeFixerCSS},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"ThemeFixer",framekey,checked:themefixerinput.checked,css:this.themeFixerCSS},"*"); }); themeRepoModal.querySelector("#download-themefixer").addEventListener("click", e => { this.createThemeFile("ThemeFixer.theme.css", `//META{"name":"ThemeFixer","description":"ThemeFixerCSS for transparent themes","author":"DevilBro","version":"1.0.1"}*//\n\n` + this.themeFixerCSS);