This repository was archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
86 lines (70 loc) · 2.31 KB
/
renderer.js
File metadata and controls
86 lines (70 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import Actions from "./components/actions.js";
import {createElement, setElementSymbol} from "./react-utils.js";
import TreeSearcher from "./treesearcher.js";
import tooltip from "./components/tooltip.js";
const styles = /*inline-css*/`
.splash-controls {
position: absolute;
bottom: 10px;
left: 5px;
}
.splash-controls * {
-webkit-app-region: no-drag;
cursor: pointer;
}
.splash-close-button {
position: fixed;
top: 8px;
right: 3px;
cursor: pointer;
}
.splash-control-button, .splash-close-button {
background: transparent;
border: none;
color: #ddd;
font-weight: bolder;
font-size: 12px;
cursor: pointer;
}
` + tooltip;
export default new class BetterSplash {
get config() {return window.BetterSplash.getConfig();}
start() {
if (typeof DiscordSplash === "undefined") return;
this.injectCSS();
const root = document.getElementById("splash-mount");
const Splash = new TreeSearcher(root, "react-vdom")
.walk("_reactRootContainer", "_internalRoot", "current")
.find((e) => e?.type?.displayName === "Splash")
.value();
setElementSymbol(
new TreeSearcher(Splash, "react")
.walk("type", "prototype", "render")
.call({state: {update: {status: ""}}})
.walk("$$typeof")
.value()
);
if (this.config.PAUSE_ON_START) window.BetterSplash.show();
this.patchSplash(Splash.type);
Splash.stateNode.forceUpdate();
}
patchSplash(Splash) {
Splash.prototype.render = new Proxy(Splash.prototype.render, {
apply(original, _this, args) {
const ret = original.apply(_this, args);
const root = ret?.props?.children;
if (!root) return ret;
ret.props.children = [root, createElement(Actions, {appState: _this.state.update.status, key: "controls"})];
return ret;
}
});
}
injectCSS() {
document.head.appendChild(Object.assign(document.createElement("style"), {
id: "better-splash-css",
textContent: styles
}));
}
stop() {
}
}