This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
51 lines (48 loc) · 1.54 KB
/
index.js
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
const { React, getModule } = require("powercord/webpack");
const { Plugin } = require("powercord/entities");
const { inject, uninject } = require("powercord/injector");
const { findInReactTree } = require("powercord/util");
const ChannelTextAreaContainer = getModule(
(m) =>
m.type &&
m.type.render &&
m.type.render.displayName === "ChannelTextAreaContainer",
false
);
const { open } = require("powercord/modal");
const GeneratorModal = require("./components/GeneratorModal");
const Button = require("./components/Button");
module.exports = class SafeEmbedGenerator extends Plugin {
async startPlugin() {
inject(
"safe-embed-generator-button",
ChannelTextAreaContainer.type,
"render",
(args, res) => {
const props = findInReactTree(
res,
(r) => r && r.className && r.className.indexOf("buttons-") == 0
);
props.children.unshift(
React.createElement(
"div",
{
className: "safe-embed-generator-button",
onClick: () => open(() => React.createElement(GeneratorModal)),
},
React.createElement(Button)
)
);
return res;
}
);
ChannelTextAreaContainer.type.render.displayName =
"ChannelTextAreaContainer";
}
pluginWillUnload() {
uninject("safe-embed-generator-button");
document
.querySelectorAll(".safe-embed-generator-button")
.forEach((e) => (e.style.display = "none"));
}
};