Update DiscordPreview.js

This commit is contained in:
Mirco Wittrien 2019-01-22 13:16:06 +01:00
parent a8c95db8eb
commit 600de7e83d
1 changed files with 9 additions and 5 deletions

View File

@ -35,11 +35,15 @@ window.onmessage = function (e) {
}
break;
case "DarkLight":
if (e.data.checked) {
document.body.innerHTML = document.body.innerHTML.replace(new RegExp("theme-dark", "g"), "theme-light");
}
else {
document.body.innerHTML = document.body.innerHTML.replace(new RegExp("theme-light", "g"), "theme-dark");
if (e.data.checked) document.body.innerHTML = document.body.innerHTML.replace(new RegExp(e.data.dark, "g"), e.data.light);
else document.body.innerHTML = document.body.innerHTML.replace(new RegExp(e.data.light, "g"), e.data.dark);
break;
case "Normalize":
var oldhtml = document.body.innerHTML.split(/'class:"'|"/g);
var newhtml = oldhtml.shift();;
for (let html of oldhtml) {
html = html.split('"');
newhtml += (e.data.checked ? html[0].replace(/([A-z0-9]+?)-([A-z0-9_-]{6})(["| ])/g, "$1-$2 da-$1$3") : html[0].split(" ").filter(n => n.indexOf("da-") != 0).join(" ")) + html[1];
}
break;
}