forked from yofukashino/BetterDiscordPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageHider.plugin.js
More file actions
220 lines (220 loc) · 8.31 KB
/
MessageHider.plugin.js
File metadata and controls
220 lines (220 loc) · 8.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/**
* @name MessageHider
* @author Ahlawat
* @authorId 887483349369765930
* @version 1.0.5
* @invite SgKSKyh9gY
* @description Get a option to hide a message by right clicking on it.
* @website https://tharki-god.github.io/
* @source https://github.com/Tharki-God/BetterDiscordPlugins
* @updateUrl https://raw.githubusercontent.com/Tharki-God/BetterDiscordPlugins/master/MessageHider.plugin.js
*/
/*@cc_on
@if (@_jscript)
// Offer to self-install for clueless users that try to run this directly.
var shell = WScript.CreateObject("WScript.Shell");
var fs = new ActiveXObject("Scripting.FileSystemObject");
var pathPlugins = shell.ExpandEnvironmentStrings("%APPDATA%\BetterDiscord\plugins");
var pathSelf = WScript.ScriptFullName;
// Put the user at ease by addressing them in the first person
shell.Popup("It looks like you've mistakenly tried to run me directly. \n(Don't do that!)", 0, "I'm a plugin for BetterDiscord", 0x30);
if (fs.GetParentFolderName(pathSelf) === fs.GetAbsolutePathName(pathPlugins)) {
shell.Popup("I'm in the correct folder already.", 0, "I'm already installed", 0x40);
} else if (!fs.FolderExists(pathPlugins)) {
shell.Popup("I can't find the BetterDiscord plugins folder.\nAre you sure it's even installed?", 0, "Can't install myself", 0x10);
} else if (shell.Popup("Should I copy myself to BetterDiscord's plugins folder for you?", 0, "Do you need some help?", 0x34) === 6) {
fs.CopyFile(pathSelf, fs.BuildPath(pathPlugins, fs.GetFileName(pathSelf)), true);
// Show the user where to put plugins in the future
shell.Exec("explorer " + pathPlugins);
shell.Popup("I'm installed!", 0, "Successfully installed", 0x40);
}
WScript.Quit();
@else@*/
module.exports = (_ => {
const config = {
info: {
name: "MessageHider",
authors: [
{
name: "Ahlawat",
discord_id: "887483349369765930",
github_username: "Tharki-God",
},
{
name: "Kirai",
discord_id: "872383230328832031",
github_username: "HiddenKirai",
},
],
version: "1.0.5",
description:
"Get a option to hide a message by right clicking on it.",
github: "https://github.com/Tharki-God/BetterDiscordPlugins",
github_raw:
"https://raw.githubusercontent.com/Tharki-God/BetterDiscordPlugins/master/MessageHider.plugin.js",
},
changelog: [
{
title: "v0.0.1",
items: [
"Idea in mind"
]
},
{
title: "v0.0.5",
items: [
"Base Model"
]
},
{
title: "Initial Release v1.0.0",
items: [
"This is the initial release of the plugin :)",
"Get those fake screen shot -O-"
]
},
{
title: "Bug Fix v1.0.1",
items: [
"Fixed settings not being saved"
]
},
{
title: "Bug Fix v1.0.2",
items: [
"Library Handler"
]
},
],
main: "MessageHider.plugin.js",
};
return !global.ZeresPluginLibrary
? class {
constructor() {
this._config = config;
}
getName() {
return config.info.name;
}
getAuthor() {
return config.info.authors.map((a) => a.name).join(", ");
}
getDescription() {
return config.info.description;
}
getVersion() {
return config.info.version;
}
load() {
try {
global.ZeresPluginLibrary.PluginUpdater.checkForUpdate(config.info.name, config.info.version, config.info.github_raw);
}
catch (err) {
console.error(this.getName(), "Plugin Updater could not be reached.", err);
}
BdApi.showConfirmationModal(
"Library Missing",
`The library plugin needed for ${config.info.name} is missing. Please click Download Now to install it.`,
{
confirmText: "Download Now",
cancelText: "Cancel",
onConfirm: () => {
require("request").get(
"https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js",
async (error, response, body) => {
if (error) {
return BdApi.showConfirmationModal("Error Downloading",
[
"Library plugin download failed. Manually install plugin library from the link below.",
BdApi.React.createElement("a", { href: "https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js", target: "_blank" }, "Plugin Link")
],
); }
await new Promise((r) =>
require("fs").writeFile(
require("path").join(
BdApi.Plugins.folder,
"0PluginLibrary.plugin.js"
),
body,
r
)
);
}
);
},
}
);
}
start() { }
stop() { }
}
: (([Plugin, Library]) => {
const {
Patcher,
WebpackModules,
ContextMenu,
Settings,
Toasts,
DiscordModules
} = Library;
const Hide = w => DiscordModules.React.createElement('svg', {
viewBox: '0 0 20 20',
width: w,
height: w
}, DiscordModules.React.createElement("g",{
transform: "scale(0.165)"}, DiscordModules.React.createElement('path', {
style: {
fill: 'currentColor'
},
d: 'M0.955,37.326c2.922-3.528,5.981-6.739,9.151-9.625C24.441,14.654,41.462,7.684,59.01,7.334 c6.561-0.131,13.185,0.665,19.757,2.416l-5.904,5.904c-4.581-0.916-9.168-1.324-13.714-1.233 c-15.811,0.316-31.215,6.657-44.262,18.533l0,0c-2.324,2.115-4.562,4.39-6.702,6.82c4.071,4.721,8.6,8.801,13.452,12.227 c2.988,2.111,6.097,3.973,9.296,5.586l-5.262,5.262c-2.782-1.504-5.494-3.184-8.12-5.039c-6.143-4.338-11.813-9.629-16.78-15.85 C-0.338,40.563-0.228,38.59,0.955,37.326L0.955,37.326L0.955,37.326z M96.03,0l5.893,5.893L28.119,79.699l-5.894-5.895L96.03,0 L96.03,0z M97.72,17.609c4.423,2.527,8.767,5.528,12.994,9.014c3.877,3.196,7.635,6.773,11.24,10.735 c1.163,1.277,1.22,3.171,0.226,4.507c-4.131,5.834-8.876,10.816-14.069,14.963C95.119,67.199,79.338,72.305,63.352,72.377 c-6.114,0.027-9.798-3.141-15.825-4.576l3.545-3.543c4.065,0.705,8.167,1.049,12.252,1.031c14.421-0.064,28.653-4.668,40.366-14.02 c3.998-3.191,7.706-6.939,11.028-11.254c-2.787-2.905-5.627-5.543-8.508-7.918c-4.455-3.673-9.042-6.759-13.707-9.273L97.72,17.609 L97.72,17.609z M61.44,18.143c2.664,0,5.216,0.481,7.576,1.359l-5.689,5.689c-0.619-0.079-1.248-0.119-1.886-0.119 c-4.081,0-7.775,1.654-10.449,4.328c-2.674,2.674-4.328,6.369-4.328,10.45c0,0.639,0.04,1.268,0.119,1.885l-5.689,5.691 c-0.879-2.359-1.359-4.912-1.359-7.576c0-5.995,2.43-11.42,6.358-15.349C50.02,20.572,55.446,18.143,61.44,18.143L61.44,18.143z M82.113,33.216c0.67,2.09,1.032,4.32,1.032,6.634c0,5.994-2.43,11.42-6.357,15.348c-3.929,3.928-9.355,6.357-15.348,6.357 c-2.313,0-4.542-0.361-6.633-1.033l5.914-5.914c0.238,0.012,0.478,0.018,0.719,0.018c4.081,0,7.775-1.652,10.449-4.326 s4.328-6.369,4.328-10.449c0-0.241-0.006-0.48-0.018-0.72L82.113,33.216L82.113,33.216z'
})));
return class MessageHider extends Plugin {
async onStart() {
this.showToast = BdApi.loadData(config.info.name, "showToast") ?? true;
const menu = await ContextMenu.getDiscordMenu("MessageContextMenu");
Patcher.after(
menu,
"default",
(_, [props], ret) => {
ret.props.children.splice(3, 0, ContextMenu.buildMenuItem({
name: 'Hide Message',
separate: false,
id: 'HideMessageContextMenu',
label: 'Hide Message',
color: 'colorDanger',
icon: ()=> Hide('20'),
action: () => {
const message = props.message;
document.getElementById(
`chat-messages-${message.id}`
).style.display = 'none';
if (this.showToast) {
Toasts.success(`Hiding Succesfull: Message sent ${message.author.username} at ${message.timestamp._d}`,
{ icon: `https://cdn.discordapp.com/attachments/889198641775001670/987919601386029136/unknown.png?size=4096`,
timeout: 5000,
type: 'info'
}
);
}
}
}, true));
}
);
}
onStop() {
Patcher.unpatchAll();
}
getSettingsPanel() {
return Settings.SettingPanel.build(this.saveSettings.bind(this),
new Settings.Switch("Popup/Toast", "Display message Hidden popup", this.showToast, (e) => {
this.showToast = e;
}))
}
saveSettings() {
BdApi.saveData(config.info.name, "showToast", this.showToast);
}
};
return plugin(Plugin, Library);
})(global.ZeresPluginLibrary.buildPlugin(config));
})();
/*@end@*/