Plugin
ShowConnections
Shows the connected Accounts of a User in the UserPopout
Installation: Datei herunterladen und in deinen BetterDiscord-Ordner legen —
%appdata%\\BetterDiscord\\plugins
(Windows) bzw. über Discord: Einstellungen → Plugins → Plugin-Ordner öffnen.
ShowConnections.plugin.js · 280 Zeilen · 12.6 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
FILE META START
name: ShowConnections.plugin.js
version: 0.0.10
description: Multi-surface admin, cloud, bot host, login, and secure chat server.
lastModified: 2026-05-04T20:22:59.655Z
checksum: edc714123b1cf6022788e9a2109ccc490c7e28673d8221d60dce00e4ff0ad87a
FILE META END
*/
/**
* @name ShowConnections
* @author HeadX
* @authorId 808385710700494919
* @description Shows the connected Accounts of a User in the UserPopout
* @version 1.3.3
* @invite J6wTJJ5fp
* @website https://headcraft.cloud/better-discord
* @source https://headcraft.cloud/better-discord/ShowConnections.plugin.js
* @updateUrl https://headcraft.cloud/better-discord/ShowConnections.plugin.js
*/
module.exports = (_ => {
const changeLog = {
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
constructor (meta) {for (let key in meta) this[key] = meta[key];}
getName () {return this.name;}
getAuthor () {return this.author;}
getVersion () {return this.version;}
getDescription () {return `The Library Plugin needed for ${this.name} is missing. Open the Plugin Settings to download it. \n\n${this.description}`;}
downloadLibrary () {
BdApi.Net.fetch("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js").then(r => {
if (!r || r.status != 200) throw new Error();
else return r.text();
}).then(b => {
if (!b) throw new Error();
else return require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => BdApi.UI.showToast("Finished downloading BDFDB Library", {type: "success"}));
}).catch(error => {
BdApi.UI.alert("Error", "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library");
});
}
load () {
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
if (!window.BDFDB_Global.downloadModal) {
window.BDFDB_Global.downloadModal = true;
BdApi.UI.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
confirmText: "Download Now",
cancelText: "Cancel",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {
delete window.BDFDB_Global.downloadModal;
this.downloadLibrary();
}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
}
start () {this.load();}
stop () {}
getSettingsPanel () {
let template = document.createElement("template");
template.innerHTML = `<div style="color: var(--text-strong); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${this.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
return template.content.firstElementChild;
}
} : (([Plugin, BDFDB]) => {
var _this;
var loadedUsers, requestedUsers, queuedInstances;
const UserConnectionsComponents = class UserConnections extends BdApi.React.Component {
render() {
if (!loadedUsers[this.props.user.id] && !requestedUsers[this.props.user.id]) {
requestedUsers[this.props.user.id] = true;
queuedInstances[this.props.user.id] = [].concat(queuedInstances[this.props.user.id]).filter(n => n);
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(this.props.user.id);
}
if (!loadedUsers[this.props.user.id]) {
if (queuedInstances[this.props.user.id].indexOf(this) == -1) queuedInstances[this.props.user.id].push(this);
return null;
}
let connections = loadedUsers[this.props.user.id].filter(c => _this.settings.connections[c.type]);
if (!connections.length) return null;
let isLightTheme = (!this.props.theme || this.props.theme == "light") && BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
return BDFDB.ReactUtils.createElement("section", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.userprofilesection, BDFDB.disCN._showconnectionsconnectionswrapper),
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._showconnectionsconnections,
children: connections.map(c => {
let provider = BDFDB.LibraryModules.ConnectionProviderUtils.get(c.type);
let url = _this.settings.general.openWebpage && provider.getPlatformUserUrl && provider.getPlatformUserUrl(c);
let metadata = [];
if (_this.settings.general.showDetails && provider.hasMetadata && c.metadata) {
if (c.metadata.created_at) metadata.push(BDFDB.ReactUtils.createElement("span", {children: BDFDB.LanguageUtils.LanguageStringsFormat("MEMBER_SINCE_PLACEHOLDER", (new Date(c.metadata.created_at)).toLocaleDateString("default", {year: "numeric", month: "long", day: "numeric"}))}));
}
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: `${provider.name}: ${c.name}`,
note: metadata && metadata.length ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
children: metadata
}): null,
tooltipConfig: {backgroundColor: _this.settings.general.useColoredTooltips && BDFDB.ColorUtils.change(provider.color, -0.3), color: !_this.settings.general.useColoredTooltips || !provider.color ? "primary" : null},
children: BDFDB.ReactUtils.createElement(!url ? "div" : BDFDB.LibraryComponents.Anchor, Object.assign(!url ? {} : {
href: url
}, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._showconnectionsconnection, url && BDFDB.disCN.cursorpointer),
onContextMenu: event => {
BDFDB.ContextMenuUtils.open(_this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LibraryStringsFormat("copy", BDFDB.LanguageUtils.LanguageStrings.USERNAME),
id: BDFDB.ContextMenuUtils.createItemId(_this.name, "copy-name"),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(c.name)
}),
url && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LibraryStringsFormat("copy", BDFDB.LanguageUtils.LanguageStrings.COPY_LINK),
id: BDFDB.ContextMenuUtils.createItemId(_this.name, "copy-url"),
action: _ => BDFDB.LibraryModules.WindowUtils.copy(url)
})
]
}));
},
children: [
BDFDB.ReactUtils.createElement("img", {
className: BDFDB.disCN._showconnectionsicon,
alt: BDFDB.LanguageUtils.LanguageStringsFormat("PLACEHOLDER_LOGO", provider.name),
src: provider.icon[this.props.popoutColor ? (BDFDB.ColorUtils.isBright(this.props.popoutColor) ? "lightSVG" : "darkSVG") : (_this.settings.general.useColoredIcons ? (isLightTheme ? "lightSVG" : "darkSVG") : "whiteSVG")]
}),
_this.settings.general.showVerifiedBadge && c.verified && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.VERIFIED_CONNECTION,
tooltipConfig: {color: "brand", type: "bottom"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FlowerStar, {
className: BDFDB.disCN._showconnectionsverifiedbadge,
size: "50%",
color: isLightTheme ? BDFDB.DiscordConstants.Colors.PRIMARY_200 : BDFDB.DiscordConstants.Colors.PRIMARY,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
name: BDFDB.LibraryComponents.SvgIcon.Names.CHECKMARK,
width: "70%",
height: "70%",
color: isLightTheme ? BDFDB.DiscordConstants.Colors.PRIMARY_500 : BDFDB.DiscordConstants.Colors.WHITE
})
})
})
]
}))
});
})
})
});
}
};
return class ShowConnections extends Plugin {
onLoad () {
_this = this;
loadedUsers = {};
requestedUsers = {};
queuedInstances = {};
this.patchPriority = 9;
this.modulePatches = {
after: [
"UserHeaderUsername"
]
};
this.defaults = {
general: {
useColoredIcons: {value: true, description: "Uses colored Version of the Icons"},
useColoredTooltips: {value: true, description: "Uses colored Version of the Tooltips"},
showDetails: {value: true, description: "Shows Details of Connection on hover"},
showVerifiedBadge: {value: true, description: "Shows the Badge for verified Connections"},
openWebpage: {value: true, description: "Opens the Connection Page when clicking the Icon"}
},
connections: {}
};
for (let connection of BDFDB.LibraryModules.ConnectionProviderUtils.filter(n => n)) this.defaults.connections[connection.type] = Object.assign({}, connection, {value: true});
this.css = `
${BDFDB.dotCN._showconnectionsconnectionswrapper} {
order: 999;
}
${BDFDB.dotCN._showconnectionsconnections} {
display: flex;
flex-wrap: wrap;
}
${BDFDB.dotCN._showconnectionsconnection} {
position: relative;
width: 28px;
height: 28px;
margin: 4px 10px 6px 0;
}
${BDFDB.dotCN._showconnectionsicon} {
margin: -15% 0 0 -15%;
width: 130%;
height: 130%;
}
${BDFDB.dotCN._showconnectionsverifiedbadge} {
position: absolute;
bottom: -10%;
right: -10%;
}
`;
}
onStart () {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dispatch", {after: e => {
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == "USER_PROFILE_FETCH_SUCCESS") {
let userProfile = e.methodArguments[0].userProfile || e.methodArguments[0];
if (userProfile.user && userProfile.connected_accounts) {
delete requestedUsers[userProfile.user.id];
loadedUsers[userProfile.user.id] = userProfile.connected_accounts;
BDFDB.ReactUtils.forceUpdate(queuedInstances[userProfile.user.id]);
delete queuedInstances[userProfile.user.id];
}
}
}});
}
onStop () {}
getSettingsPanel (collapseStates = {}) {
let settingsPanel;
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
collapseStates: collapseStates,
children: _ => {
let settingsItems = [];
for (let key in this.defaults.general) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: this,
keys: ["general", key],
label: this.defaults.general[key].description,
value: this.settings.general[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
title: "Display Connections:",
children: Object.keys(this.defaults.connections).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: this,
keys: ["connections", key],
label: this.defaults.connections[key].name,
value: this.settings.connections[key],
labelChildren: [
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.lightSVG}),
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.whiteSVG})
]
}))
}));
return settingsItems;
}
});
}
processUserHeaderUsername (e) {
let themeType = BDFDB.ObjectUtils.get(e.instance, "props.tags.props.themeType");
if (themeType != "SIDEBAR" && themeType != "POPOUT" || e.instance.props.className) return;
let user = e.instance.props.user || BDFDB.LibraryStores.UserStore.getUser(e.instance.props.userId);
if (!user || user.isNonUserBot()) return;
e.returnvalue = [e.returnvalue].flat(10);
e.returnvalue.push(BDFDB.ReactUtils.createElement(UserConnectionsComponents, {
user: user,
popoutColor: BDFDB.ObjectUtils.get(e.instance, "props.tags.props.displayProfile.themeColors.1"),
theme: e.instance.props.theme
}, true));
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
})();