Update DiscordPreview.js
This commit is contained in:
parent
4a57e89c1a
commit
0f918ad27d
|
@ -3,18 +3,26 @@
|
||||||
|
|
||||||
window.global = window;
|
window.global = window;
|
||||||
|
|
||||||
|
window.respondToParent = function (data = {}) {
|
||||||
|
if (window.parent && typeof window.parent.postMessage == "function") window.parent.postMessage(data, "*");
|
||||||
|
else if (window.hostId && window.hostName) {
|
||||||
|
let ipcRenderer = (require("electron") || {}).ipcRenderer;
|
||||||
|
if (ipcRenderer && typeof ipcRenderer.sendTo == "function") ipcRenderer.sendTo(window.hostId, window.hostName, data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
window.parent.postMessage({
|
window.respondToParent({
|
||||||
origin: "DiscordPreview",
|
origin: "DiscordPreview",
|
||||||
reason: "OnLoad"
|
reason: "OnLoad"
|
||||||
}, "*");
|
});
|
||||||
};
|
};
|
||||||
window.onkeyup = function (e) {
|
window.onkeyup = function (e) {
|
||||||
window.parent.postMessage({
|
window.respondToParent({
|
||||||
origin: "DiscordPreview",
|
origin: "DiscordPreview",
|
||||||
reason: "KeyUp",
|
reason: "KeyUp",
|
||||||
which: e.which
|
which: e.which
|
||||||
} ,"*");
|
});
|
||||||
};
|
};
|
||||||
window.onmessage = function (e) {
|
window.onmessage = function (e) {
|
||||||
if (typeof e.data === "object" && (e.data.origin == "PluginRepo" || e.data.origin == "ThemeRepo")) {
|
if (typeof e.data === "object" && (e.data.origin == "PluginRepo" || e.data.origin == "ThemeRepo")) {
|
||||||
|
@ -64,11 +72,11 @@
|
||||||
case "Eval":
|
case "Eval":
|
||||||
window.evalResult = null;
|
window.evalResult = null;
|
||||||
if (e.data.jsstring) window.eval(`(_ => {${e.data.jsstring}})()`);
|
if (e.data.jsstring) window.eval(`(_ => {${e.data.jsstring}})()`);
|
||||||
window.parent.postMessage({
|
window.respondToParent({
|
||||||
origin: "DiscordPreview",
|
origin: "DiscordPreview",
|
||||||
reason: "EvalResult",
|
reason: "EvalResult",
|
||||||
result: window.evalResult
|
result: window.evalResult
|
||||||
}, "*");
|
});
|
||||||
break;
|
break;
|
||||||
case "NewTheme":
|
case "NewTheme":
|
||||||
case "CustomCSS":
|
case "CustomCSS":
|
||||||
|
@ -125,11 +133,11 @@
|
||||||
else return className = DiscordClassModules[DiscordClasses[item][0]][DiscordClasses[item][1]];
|
else return className = DiscordClassModules[DiscordClasses[item][0]][DiscordClasses[item][1]];
|
||||||
};
|
};
|
||||||
|
|
||||||
window.require = function () {
|
if (typeof !window.require != "function") window.require = function () {
|
||||||
return _ => {};
|
return _ => {};
|
||||||
};
|
};
|
||||||
|
|
||||||
window.getString = function (obj) {
|
if (typeof !window.getString != "function") window.getString = function (obj) {
|
||||||
let string = "";
|
let string = "";
|
||||||
if (typeof obj == "string") string = obj;
|
if (typeof obj == "string") string = obj;
|
||||||
else if (obj && obj.props) {
|
else if (obj && obj.props) {
|
||||||
|
@ -139,7 +147,7 @@
|
||||||
return string;
|
return string;
|
||||||
};
|
};
|
||||||
|
|
||||||
window.webpackJsonp = function () {
|
if (typeof !window.webpackJsonp != "function") window.webpackJsonp = function () {
|
||||||
return {
|
return {
|
||||||
default: {
|
default: {
|
||||||
m: {},
|
m: {},
|
||||||
|
@ -147,6 +155,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
let WebModulesFind = function (filter) {
|
let WebModulesFind = function (filter) {
|
||||||
const id = "PluginRepo-WebModules";
|
const id = "PluginRepo-WebModules";
|
||||||
const req = typeof(window.webpackJsonp) == "function" ? window.webpackJsonp([], {[id]: (module, exports, req) => exports.default = req}, [id]).default : window.webpackJsonp.push([[], {[id]: (module, exports, req) => module.exports = req}, [[id]]]);
|
const req = typeof(window.webpackJsonp) == "function" ? window.webpackJsonp([], {[id]: (module, exports, req) => exports.default = req}, [id]).default : window.webpackJsonp.push([[], {[id]: (module, exports, req) => module.exports = req}, [[id]]]);
|
||||||
|
|
Loading…
Reference in New Issue