This commit is contained in:
Mirco Wittrien 2019-10-09 14:45:23 +02:00
parent df019171ba
commit 7cd8f69a60
4 changed files with 46 additions and 13 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -1047,9 +1047,9 @@
<div class="REPLACE_CLASS_voicedetailsinner">
<div class="REPLACE_CLASS_voicedetailsstatus REPLACE_CLASS_voicedetailsqualityfine">
<svg class="REPLACE_CLASS_voicedetailsping" width="11" height="12" viewBox="0 0 11 12" aria-label="26 ms">
<rect class="active-2h1NLh" x="0" y="8" width="3" height="4" rx="1"></rect>
<rect class="active-2h1NLh" x="4" y="4" width="3" height="8" rx="1"></rect>
<rect class="active-2h1NLh" x="8" y="0" width="3" height="12" rx="1"></rect>
<rect class="REPLACE_CLASS_voicedetailsactive" x="0" y="8" width="3" height="4" rx="1"></rect>
<rect class="REPLACE_CLASS_voicedetailsactive" x="4" y="4" width="3" height="8" rx="1"></rect>
<rect class="REPLACE_CLASS_voicedetailsactive" x="8" y="0" width="3" height="12" rx="1"></rect>
</svg>
<div class="REPLACE_CLASS_voicedetailslabelwrapper">
<div class="size14-e6ZScH title-eS5yk3 REPLACE_CLASS_voicedetailsstatusconnected">Voice Connected</div>

View File

@ -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;