diff --git a/Plugins/PluginRepo/PluginRepo.plugin.js b/Plugins/PluginRepo/PluginRepo.plugin.js index fcd9b673bc..c026e73684 100644 --- a/Plugins/PluginRepo/PluginRepo.plugin.js +++ b/Plugins/PluginRepo/PluginRepo.plugin.js @@ -3,7 +3,7 @@ class PluginRepo { getName () {return "PluginRepo";} - getVersion () {return "1.8.6";} + getVersion () {return "1.8.7";} getAuthor () {return "DevilBro";} @@ -11,7 +11,7 @@ class PluginRepo { constructor () { this.changelog = { - "fixed":[["Small bug fixes","Just some small bug fixes"]] + "improved":[["Preview","Now also uses Modules to grab classnames"]] }; this.patchModules = { @@ -773,7 +773,7 @@ class PluginRepo { else if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { switch (e.data.reason) { case "OnLoad": - frame.contentWindow.postMessage({origin:"PluginRepo",reason:"OnLoad"},"*"); + frame.contentWindow.postMessage({origin:"PluginRepo",reason:"OnLoad",classes:JSON.stringify(BDFDB.DiscordClasses),classmodules:JSON.stringify(BDFDB.DiscordClassModules)},"*"); callback(); break; } diff --git a/Plugins/ThemeRepo/ThemeRepo.plugin.js b/Plugins/ThemeRepo/ThemeRepo.plugin.js index 13833fe1d1..3f5143c212 100644 --- a/Plugins/ThemeRepo/ThemeRepo.plugin.js +++ b/Plugins/ThemeRepo/ThemeRepo.plugin.js @@ -3,7 +3,7 @@ class ThemeRepo { getName () {return "ThemeRepo";} - getVersion () {return "1.8.7";} + getVersion () {return "1.8.8";} getAuthor () {return "DevilBro";} @@ -11,10 +11,7 @@ class ThemeRepo { constructor () { this.changelog = { - "added":[["Theme Generator","A new tab was added, that lets you generate your own custom themes"]], - "added":[["Preview","Hovering out of the themerepo now hides it and the backdrop to more swiftly let you take a look at the theme preview"]], - "improved":[["Ctrl","Pressing Ctrl while inside a generator input no longer hides the modal"]], - "fixed":[["Theme Fixer","Theme Fixer CSS was fixed for the newest changes"]] + "improved":[["Preview","Now also uses Modules to grab classnames"]] }; this.patchModules = { @@ -510,7 +507,7 @@ class ThemeRepo { nativecss = nativecss && nativecss.href ? nativecss.href : null; var titlebar = document.querySelector(BDFDB.dotCN.titlebar); titlebar = titlebar ? titlebar.outerHTML : null; - frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"OnLoad",username,id,discriminator,avatar,nativecss,html:document.documentElement.className,titlebar},"*"); + frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"OnLoad",classes:JSON.stringify(BDFDB.DiscordClasses),classmodules:JSON.stringify(BDFDB.DiscordClassModules),username,id,discriminator,avatar,nativecss,html:document.documentElement.className,titlebar},"*"); 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},"*"); break; diff --git a/Plugins/ThemeRepo/res/DiscordPreview.html b/Plugins/ThemeRepo/res/DiscordPreview.html index 985a7b809e..98482562f3 100644 --- a/Plugins/ThemeRepo/res/DiscordPreview.html +++ b/Plugins/ThemeRepo/res/DiscordPreview.html @@ -1047,9 +1047,9 @@
- - - + + +
Voice Connected
diff --git a/Plugins/ThemeRepo/res/DiscordPreview.js b/Plugins/ThemeRepo/res/DiscordPreview.js index 23717a53af..8e88f29244 100644 --- a/Plugins/ThemeRepo/res/DiscordPreview.js +++ b/Plugins/ThemeRepo/res/DiscordPreview.js @@ -12,6 +12,17 @@ window.onmessage = function (e) { switch (e.data.reason) { case "OnLoad": document.body.innerHTML = document.body.innerHTML.replace(/\t|\n|\r/g, ""); + if (e.data.classes) window.DiscordClasses = JSON.parse(e.data.classes); + if (e.data.classmodules) window.DiscordClassModules = JSON.parse(e.data.classmodules); + if (window.DiscordClasses != undefined && window.DiscordClassModules != undefined)) { + var oldhtml = h.split('REPLACE_CLASS_'); + var newhtml = oldhtml.shift(); + for (let html of oldhtml) { + let reg = /([A-z_]+)(.+)/.exec(html); + newhtml += BDFDB.disCN[reg[1]] + reg[2] + } + document.body.innerHTML = newhtml; + } if (e.data.username) { document.body.innerHTML = document.body.innerHTML.replace(/REPLACE_USERNAMESMALL/gi, e.data.username.toLowerCase()); document.body.innerHTML = document.body.innerHTML.replace(/REPLACE_USERNAME/gi, e.data.username); @@ -28,7 +39,6 @@ window.onmessage = function (e) { } if (e.data.html) document.documentElement.className = e.data.html; if (e.data.titlebar) document.querySelector(".preview-titlebar").outerHTML = e.data.titlebar; - document.body.firstElementChild.style.removeProperty("display"); break; case "Eval": window.evalResult = null; @@ -102,6 +112,32 @@ window.WebModulesFindByProperties = function (properties) { window.WebModulesFindByName = function (name) { return WebModulesFind(module => module.displayName === name) || ""; }; +window.disCN = new Proxy({}, { + get: function (list, item) { + return window.getDiscordClass(item).replace('#', ''); + } +}); +window.getDiscordClass = function (item) { + var classname = "Preview_undefined"; + if (window.DiscordClasses === undefined || window.DiscordClassModules === undefined) return classname; + else if (window.DiscordClasses[item] === undefined) { + console.warn(`%c[Preview]%c`, 'color:#3a71c1; font-weight:700;', '', item + ' not found in window.DiscordClasses'); + return classname; + } + else if (!Array.isArray(window.DiscordClasses[item]) || window.DiscordClasses[item].length != 2) { + console.warn(`%c[Preview]%c`, 'color:#3a71c1; font-weight:700;', '', item + ' is not an Array of Length 2 in window.DiscordClasses'); + return classname; + } + else if (window.DiscordClassModules[window.DiscordClasses[item][0]] === undefined) { + console.warn(`%c[Preview]%c`, 'color:#3a71c1; font-weight:700;', '', window.DiscordClasses[item][0] + ' not found in DiscordClassModules'); + return classname; + } + else if (window.DiscordClassModules[window.DiscordClasses[item][0]][window.DiscordClasses[item][1]] === undefined) { + console.warn(`%c[Preview]%c`, 'color:#3a71c1; font-weight:700;', '', window.DiscordClasses[item][1] + ' not found in ' + window.DiscordClasses[item][0] + ' in DiscordClassModules'); + return classname; + } + else return classname = window.DiscordClassModules[window.DiscordClasses[item][0]][window.DiscordClasses[item][1]]; +}; window.BDV2 = {}; window.BDV2.react = window.React; window.BDV2.reactDom = window.ReactDOM;