//META{"name":"BadgesEverywhere","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/BadgesEverywhere","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js"}*//
class BadgesEverywhere {
getName () {return "BadgesEverywhere";}
getVersion () {return "1.3.2";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays Badges (Nitro, HypeSquad, etc...) in the chat/memberlist/userpopout. Thanks for Zerebos' help.";}
initConstructor () {
this.changelog = {
"improved":[["Guild Boost","Changed the general guild boost badge in a way that it's displayed everywhere in all servers and added the option to add the badge for the boosting of the current server"]],
"fixed":[["Message Username","Fixed the issue that moved the message username when a badge was appended"],["Badges","Some badges didn't get added properly"]]
};
this.patchModules = {
"NameTag":"componentDidMount",
"MessageUsername":"componentDidMount",
"StandardSidebarView":"componentWillUnmount"
};
this.css = `
${BDFDB.dotCNS.message + BDFDB.dotCN.messageheadercozy} {
padding-top: 0;
}
${BDFDB.dotCNC.userpopoutheadertagnonickname + BDFDB.dotCNC.userpopoutheadernamewrapper + BDFDB.dotCN.messageheadercozymeta} > span:first-child {
display: inline-flex;
}
.BE-badge {
position: relative;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
display: inline-flex;
align-items: center;
justify-content: center;
height: 17px !important;
margin: 0 2px !important;
}
.BE-badge.BE-badge-list:not(.BE-badge-CurrentGuildBoost) {
top: 1px !important;
}
.BE-badge.BE-badge-popout:not(.BE-badge-CurrentGuildBoost) {
top: 3px !important;
}
.BE-badge.BE-badge-list.BE-badge-CurrentGuildBoost {
top: -2px !important;
}
.BE-badge.BE-badge-chat.BE-badge-CurrentGuildBoost {
top: -3px !important;
}
.BE-badge:not(.BE-badge-settings):first-of-type {
margin-left: 5px !important;
}
.BE-badge:not(.BE-badge-settings):last-of-type {
margin-right: 5px !important;
}
${BDFDB.dotCN.userprofiletopsectionplaying} .BE-badge.BE-badge-CurrentGuildBoost svg {
color: white !important;
}
.BE-badge.BE-badge-Staff {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-Partner {width:22px !important; min-width:22px !important;}
.BE-badge.BE-badge-HypeSquad {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-BugHunter {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-HypeSquadBravery {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-HypeSquadBrilliance {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-HypeSquadBalance {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-EarlySupporter {width:24px !important; min-width:24px !important;}
.BE-badge.BE-badge-Nitro {width:21px !important; min-width:21px !important;}
.BE-badge.BE-badge-NitroGuildBoost {width:17px !important; min-width:17px !important;}
.BE-badge.BE-badge-CurrentGuildBoost {width:14px !important; min-width:14px !important;}
.BE-badge.BE-badge-settings {width:30px !important;min-width:30px !important;}
${BDFDB.dotCNS.member + BDFDB.dotCN.memberpremiumicon}:not(.BE-badge-CurrentGuildBoost-inner) {display: none;}`;
this.requestedusers = {};
this.loadedusers = {};
this.defaults = {
settings: {
showInPopout: {value:true, description:"Show Badge in User Popout."},
showInChat: {value:true, description:"Show Badge in Chat Window."},
showInMemberList: {value:true, description:"Show Badge in Member List."},
useColoredVersion: {value:true, description:"Use colored version of the Badges for Chat and Members."},
showNitroDate: {value:true, description:"Show the subscription date for Nitro/Boost Badges"}
},
badges: {
"STAFF": {value:true, id:"Staff", name:"STAFF_BADGE_TOOLTIP", selector:"profileBadgeStaff"},
"PARTNER": {value:true, id:"Partner", name:"PARTNER_BADGE_TOOLTIP", selector:"profileBadgePartner"},
"HYPESQUAD": {value:true, id:"HypeSquad", name:"HYPESQUAD_BADGE_TOOLTIP", selector:"profileBadgeHypesquad"},
"BUG_HUNTER": {value:true, id:"BugHunter", name:"BUG_HUNTER_BADGE_TOOLTIP", selector:"profileBadgeBugHunter"},
"MFA_SMS": {value:false, id:null, name:null, selector:false},
"PREMIUM_PROMO_DISMISSED": {value:false, id:null, name:null, selector:false},
"HYPESQUAD_ONLINE_HOUSE_1": {value:true, id:"HypeSquadBravery", name:"HypeSquad Bravery", selector:"profileBadgeHypeSquadOnlineHouse1"},
"HYPESQUAD_ONLINE_HOUSE_2": {value:true, id:"HypeSquadBrilliance", name:"HypeSquad Brilliance", selector:"profileBadgeHypeSquadOnlineHouse2"},
"HYPESQUAD_ONLINE_HOUSE_3": {value:true, id:"HypeSquadBalance", name:"HypeSquad Balance", selector:"profileBadgeHypeSquadOnlineHouse3"},
"PREMIUM_EARLY_SUPPORTER": {value:true, id:"EarlySupporter", name:"EARLY_SUPPORTER_TOOLTIP", selector:"profileBadgeEarlySupporter"},
"NITRO": {value:true, id:"Nitro", name:"Nitro", selector:"profileBadgePremium"},
"GUILD_BOOST": {value:true, id:"NitroGuildBoost", name:"Nitro Guild Boost", selector:"profileGuildSubscriberlvl", types:[1,2,3,4]},
},
indicators: {
"CURRENT_GUILD_BOOST": {value:true, name:"Current Nitro Guild Boost", markup:`
`},
}
};
var UserFlags = BDFDB.WebModules.findByProperties("UserFlags").UserFlags;
for (let flagname in UserFlags) if (this.defaults.badges[flagname]) {
if (BDFDB.LanguageStringsCheck[this.defaults.badges[flagname].name]) this.defaults.badges[flagname].name = BDFDB.LanguageStrings[this.defaults.badges[flagname].name];
this.defaults.badges[UserFlags[flagname]] = this.defaults.badges[flagname];
delete this.defaults.badges[flagname];
}
this.nitroflag = Math.pow(2, Object.keys(UserFlags).length);
this.defaults.badges[this.nitroflag] = this.defaults.badges.NITRO;
delete this.defaults.badges.NITRO;
this.boostflag = Math.pow(2, Object.keys(UserFlags).length + 1);
this.defaults.badges[this.boostflag] = this.defaults.badges.GUILD_BOOST;
delete this.defaults.badges.GUILD_BOOST;
for (let flag in this.defaults.badges) if (!this.defaults.badges[flag].selector || isNaN(parseInt(flag))) delete this.defaults.badges[flag];
}
getSettingsPanel () {
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
var settings = BDFDB.getAllData(this, "settings");
var badges = BDFDB.getAllData(this, "badges");
var indicators = BDFDB.getAllData(this, "indicators");
var settingshtml = `
${this.name}
`;
for (let key in settings) {
settingshtml += `
${this.defaults.settings[key].description}
`;
}
settingshtml += `
Display Badges:
`;
for (let flag in badges) {
settingshtml += `
${this.defaults.badges[flag].name}
`;
if (Array.isArray(this.defaults.badges[flag].types)) for (let type of this.defaults.badges[flag].types) settingshtml += ``;
else settingshtml += ``;
settingshtml += ``
if (Array.isArray(this.defaults.badges[flag].types)) for (let type of this.defaults.badges[flag].types) settingshtml += ``;
else settingshtml += ``;
settingshtml += `
`;
}
for (let flag in indicators) {
settingshtml += `