Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2021-05-27 18:28:28 +02:00
parent cb4abf3457
commit ea89659223
1 changed files with 6 additions and 2 deletions

View File

@ -7813,8 +7813,9 @@ module.exports = (_ => {
InternalBDFDB._processAvatarRender = function (user, avatar) { InternalBDFDB._processAvatarRender = function (user, avatar) {
if (BDFDB.ReactUtils.isValidElement(avatar) && BDFDB.ObjectUtils.is(user) && (avatar.props.className || "").indexOf(BDFDB.disCN.bdfdbbadgeavatar) == -1) { if (BDFDB.ReactUtils.isValidElement(avatar) && BDFDB.ObjectUtils.is(user) && (avatar.props.className || "").indexOf(BDFDB.disCN.bdfdbbadgeavatar) == -1) {
avatar.props[InternalData.userIdAttribute] = user.id; avatar.props[InternalData.userIdAttribute] = user.id;
let role = "", note = "", className = BDFDB.DOMUtils.formatClassName((avatar.props.className || "").replace(BDFDB.disCN.avatar, "")), addBadge = InternalBDFDB.settings.general.showSupportBadges; let role = "", note = "", link, className = BDFDB.DOMUtils.formatClassName((avatar.props.className || "").replace(BDFDB.disCN.avatar, "")), addBadge = InternalBDFDB.settings.general.showSupportBadges;
if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) { if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) {
link = "https://www.patreon.com/MircoWittrien";
role = BDFDB_Patrons[user.id].text || (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text; role = BDFDB_Patrons[user.id].text || (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text;
note = BDFDB_Patrons[user.id].text && (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text; note = BDFDB_Patrons[user.id].text && (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text;
className = BDFDB.DOMUtils.formatClassName(className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, BDFDB.disCN[`bdfdbsupporter${BDFDB_Patrons[user.id].tier}`]); className = BDFDB.DOMUtils.formatClassName(className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, BDFDB.disCN[`bdfdbsupporter${BDFDB_Patrons[user.id].tier}`]);
@ -7839,6 +7840,7 @@ module.exports = (_ => {
if (addBadge) avatar.props.children.push(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, { if (addBadge) avatar.props.children.push(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
text: role, text: role,
note: note, note: note,
onClick: link ? (_ => BDFDB.DiscordUtils.openLink(link)) : (_ => {}),
children: BDFDB.ReactUtils.createElement("div", { children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.bdfdbbadge className: BDFDB.disCN.bdfdbbadge
}) })
@ -7852,8 +7854,9 @@ module.exports = (_ => {
if (wrapper) wrapper.setAttribute(InternalData.userIdAttribute, user.id); if (wrapper) wrapper.setAttribute(InternalData.userIdAttribute, user.id);
if (Node.prototype.isPrototypeOf(avatar) && (avatar.className || "").indexOf(BDFDB.disCN.bdfdbbadgeavatar) == -1) { if (Node.prototype.isPrototypeOf(avatar) && (avatar.className || "").indexOf(BDFDB.disCN.bdfdbbadgeavatar) == -1) {
avatar.setAttribute(InternalData.userIdAttribute, user.id); avatar.setAttribute(InternalData.userIdAttribute, user.id);
let role = "", note = "", addBadge = InternalBDFDB.settings.general.showSupportBadges; let role = "", note = "", link, addBadge = InternalBDFDB.settings.general.showSupportBadges;
if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) { if (BDFDB_Patrons[user.id] && BDFDB_Patrons[user.id].active) {
link = "https://www.patreon.com/MircoWittrien";
role = BDFDB_Patrons[user.id].text || (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text; role = BDFDB_Patrons[user.id].text || (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text;
note = BDFDB_Patrons[user.id].text && (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text; note = BDFDB_Patrons[user.id].text && (BDFDB_Patron_Tiers[BDFDB_Patrons[user.id].tier] || {}).text;
avatar.className = BDFDB.DOMUtils.formatClassName(avatar.className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, BDFDB.disCN[`bdfdbsupporter${BDFDB_Patrons[user.id].tier}`]); avatar.className = BDFDB.DOMUtils.formatClassName(avatar.className, addBadge && BDFDB.disCN.bdfdbhasbadge, BDFDB.disCN.bdfdbbadgeavatar, BDFDB.disCN.bdfdbsupporter, BDFDB.disCN[`bdfdbsupporter${BDFDB_Patrons[user.id].tier}`]);
@ -7866,6 +7869,7 @@ module.exports = (_ => {
if (addBadge && role && !avatar.querySelector(BDFDB.dotCN.bdfdbbadge)) { if (addBadge && role && !avatar.querySelector(BDFDB.dotCN.bdfdbbadge)) {
let badge = document.createElement("div"); let badge = document.createElement("div");
badge.className = BDFDB.disCN.bdfdbbadge; badge.className = BDFDB.disCN.bdfdbbadge;
if (link) badge.addEventListener("click", _ => BDFDB.DiscordUtils.openLink(link));
badge.addEventListener("mouseenter", _ => BDFDB.TooltipUtils.create(badge, role, {position: "top", note: note})); badge.addEventListener("mouseenter", _ => BDFDB.TooltipUtils.create(badge, role, {position: "top", note: note}));
avatar.appendChild(badge); avatar.appendChild(badge);
} }