aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/consoleShortcuts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/consoleShortcuts.ts')
-rw-r--r--src/plugins/consoleShortcuts.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/plugins/consoleShortcuts.ts b/src/plugins/consoleShortcuts.ts
index 0489c2c..24ab740 100644
--- a/src/plugins/consoleShortcuts.ts
+++ b/src/plugins/consoleShortcuts.ts
@@ -21,7 +21,8 @@ import { relaunch } from "@utils/native";
import definePlugin from "@utils/types";
import * as Webpack from "@webpack";
import { extract, filters, findAll, search } from "@webpack";
-import { React } from "@webpack/common";
+import { React, ReactDOM } from "@webpack/common";
+import type { ComponentType } from "react";
const WEB_ONLY = (f: string) => () => {
throw new Error(`'${f}' is Discord Desktop only.`);
@@ -59,6 +60,7 @@ export default definePlugin({
};
}
+ let fakeRenderWin: WeakRef<Window> | undefined;
return {
wp: Vencord.Webpack,
wpc: Webpack.wreq.c,
@@ -79,7 +81,15 @@ export default definePlugin({
Settings: Vencord.Settings,
Api: Vencord.Api,
reload: () => location.reload(),
- restart: IS_WEB ? WEB_ONLY("restart") : relaunch
+ restart: IS_WEB ? WEB_ONLY("restart") : relaunch,
+ fakeRender: (component: ComponentType, props: any) => {
+ const prevWin = fakeRenderWin?.deref();
+ const win = prevWin?.closed === false ? prevWin : window.open("about:blank", "Fake Render", "popup,width=500,height=500")!;
+ fakeRenderWin = new WeakRef(win);
+ win.focus();
+
+ ReactDOM.render(React.createElement(component, props), win.document.body);
+ }
};
},