local lib

This commit is contained in:
Mirco Wittrien 2020-09-19 20:49:33 +02:00
parent b614303e41
commit a619af5fdc
55 changed files with 22411 additions and 23975 deletions

View File

@ -1,318 +1,265 @@
//META{"name":"BadgesEverywhere","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/BadgesEverywhere","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js"}*//
var BadgesEverywhere = (_ => {
var badgeClasses, requestedUsers = {}, loadedUsers = {}, requestQueue = {queue:[], timeout:null, id:null}, cacheTimeout;
var nitroflag, boostflag;
var settings = {}, badges = {}, indicators = {};
const miniTypes = ["list", "chat"];
return class BadgesEverywhere {
getName () {return "BadgesEverywhere";}
getVersion () {return "1.6.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays Badges (Nitro, HypeSquad, etc...) in the chat/memberlist/userpopout.";}
constructor () {
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default",
UserPopout: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "BadgesEverywhere",
"author": "DevilBro",
"version": "1.6.0",
"description": "Displays Badges (Nitro, HypeSquad, etc...) in the chat/memberlist/userpopout."
}
initConstructor () {
this.css = `
${BDFDB.dotCN._badgeseverywherebadgeschat} {
display: inline-flex;
position: relative;
top: 2px;
}
${BDFDB.dotCN._badgeseverywheremini} {
margin-left: 5px;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCNS.messageusername} + ${BDFDB.dotCN._badgeseverywherebadges},
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagetimestampseparator} + ${BDFDB.dotCN._badgeseverywherebadges} {
margin-left: 0;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messageusername} ~ ${BDFDB.dotCN._badgeseverywherebadges} {
margin-right: .25rem;
text-indent: 0;
}
${BDFDB.dotCN._badgeseverywherebadgesinner} {
display: inline-grid;
grid-auto-flow: column;
grid-gap: 6px;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywherebadgesinner} {
grid-gap: 4px;
}
${BDFDB.dotCN._badgeseverywherebadge} {
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
${BDFDB.dotCN._badgeseverywhereindicator} {
display: flex;
align-items: center;
justify-content: center;
}
${BDFDB.dotCN._badgeseverywhereindicatorinner} {
position: static !important;
margin: 0 !important;
}
${BDFDB.dotCN._badgeseverywherebadge} {
height: 17px !important;
}
${BDFDB.dotCN._badgeseverywheresize17} {
width: 17px !important; min-width: 17px !important;
}
${BDFDB.dotCN._badgeseverywheresize21} {
width: 21px !important; min-width: 21px !important;
}
${BDFDB.dotCN._badgeseverywheresize22} {
width: 22px !important; min-width: 22px !important;
}
${BDFDB.dotCN._badgeseverywheresize24} {
width: 24px !important; min-width: 24px !important;
}
${BDFDB.dotCN._badgeseverywhereindicator} {
height: 14px !important; min-height: 14px !important; width: 14px !important; min-width: 14px !important;
}
${BDFDB.dotCN._badgeseverywhereindicatorinner} {
height: inherit !important; min-height: inherit !important; width: inherit !important; min-width: inherit !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywherebadge} {
height: 14px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize17} {
width: 14px !important; min-width: 14px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize21} {
width: 18px !important; min-width: 18px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize22} {
width: 18px !important; min-width: 18px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize24} {
width: 19px !important; min-width: 19px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywhereindicator} {
height: 12px !important; min-height: 12px !important; width: 12px !important; min-width: 12px !important;
}
#app-mount ${BDFDB.dotCNS._badgeseverywherebadgessettings + BDFDB.dotCN._badgeseverywherebadge} {
width: 30px !important; min-width: 30px !important;
}
${BDFDB.dotCNS.userprofiletopsectionplaying + BDFDB.dotCN._badgeseverywherebadge} svg {
color: unset !important;
}
${BDFDB.dotCNS.member + BDFDB.dotCN.memberpremiumicon + BDFDB.notCN._badgeseverywhereindicatorinner} {display: none;}
`;
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",
icon: "profileBadgeStaff",
size: 17
},
"PARTNER": {
value: true,
id: "Partner",
name: "PARTNER_BADGE_TOOLTIP",
icon: "profileBadgePartner",
size: 22
},
"HYPESQUAD": {
value: true,
id: "HypeSquad",
name: "HYPESQUAD_BADGE_TOOLTIP",
icon: "profileBadgeHypesquad",
size: 17
},
"BUG_HUNTER_LEVEL_1": {
value: true,
id: "BugHunter1",
name: "BUG_HUNTER_BADGE_TOOLTIP",
icon: "profileBadgeBugHunterLevel1",
size: 17,
suffix: "Level 1"
},
"BUG_HUNTER_LEVEL_2": {
value: true,
id: "BugHunter2",
name: "BUG_HUNTER_BADGE_TOOLTIP",
icon: "profileBadgeBugHunterLevel2",
size: 17,
suffix: "Level 2"
},
"VERIFIED_DEVELOPER": {
value: true,
id: "VerifiedDeveloper",
name: "VERIFIED_DEVELOPER_BADGE_TOOLTIP",
icon: "profileBadgeVerifiedDeveloper",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_1": {
value: true,
id: "HypeSquad1",
name: "HypeSquad Bravery",
icon: "profileBadgeHypeSquadOnlineHouse1",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_2": {
value: true,
id: "HypeSquad2",
name: "HypeSquad Brilliance",
icon: "profileBadgeHypeSquadOnlineHouse2",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_3": {
value: true,
id: "HypeSquad3",
name: "HypeSquad Balance",
icon: "profileBadgeHypeSquadOnlineHouse3",
size: 17
},
"PREMIUM_EARLY_SUPPORTER": {
value: true,
id: "EarlySupporter",
name: "EARLY_SUPPORTER_TOOLTIP",
icon: "profileBadgeEarlySupporter",
size: 24
},
"NITRO": {
value: true,
id: "Nitro",
name: "Nitro",
icon: "profileBadgePremium",
size: 21
},
"GUILD_BOOST": {
value: true,
id: "NitroGuildBoost",
name: "Nitro Guild Boost",
icon: "profileGuildSubscriberlvl",
size: 17,
types: [1,2,3,4,5,6,7,8,9]
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var badgeClasses, requestedUsers = {}, loadedUsers = {}, requestQueue = {queue:[], timeout:null, id:null}, cacheTimeout;
var nitroFlag, boostFlag;
var settings = {}, badges = {}, indicators = {};
const miniTypes = ["list", "chat"];
return class BadgesEverywhere extends Plugin {
onLoad() {
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default",
UserPopout: "render"
}
},
indicators: {
"CURRENT_GUILD_BOOST": {
value: true,
id: "CurrentGuildBoost",
name: "Current Nitro Guild Boost",
inner: `<svg name="PremiumGuildSubscriberBadge" class="${BDFDB.disCNS.memberpremiumicon + BDFDB.disCN.membericon}" aria-hidden="false" width="24" height="24" viewBox="0 0 8 12"><path d="M4 0L0 4V8L4 12L8 8V4L4 0ZM7 7.59L4 10.59L1 7.59V4.41L4 1.41L7 4.41V7.59Z" fill="currentColor"></path><path d="M2 4.83V7.17L4 9.17L6 7.17V4.83L4 2.83L2 4.83Z" fill="currentColor"></path></svg>`
};
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",
icon: "profileBadgeStaff",
size: 17
},
"PARTNER": {
value: true,
id: "Partner",
"name": "PARTNER_BADGE_TOOLTIP",
icon: "profileBadgePartner",
size: 22
},
"HYPESQUAD": {
value: true,
id: "HypeSquad",
"name": "HYPESQUAD_BADGE_TOOLTIP",
icon: "profileBadgeHypesquad",
size: 17
},
"BUG_HUNTER_LEVEL_1": {
value: true,
id: "BugHunter1",
"name": "BUG_HUNTER_BADGE_TOOLTIP",
icon: "profileBadgeBugHunterLevel1",
size: 17,
suffix: "Level 1"
},
"BUG_HUNTER_LEVEL_2": {
value: true,
id: "BugHunter2",
"name": "BUG_HUNTER_BADGE_TOOLTIP",
icon: "profileBadgeBugHunterLevel2",
size: 17,
suffix: "Level 2"
},
"VERIFIED_DEVELOPER": {
value: true,
id: "VerifiedDeveloper",
"name": "VERIFIED_DEVELOPER_BADGE_TOOLTIP",
icon: "profileBadgeVerifiedDeveloper",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_1": {
value: true,
id: "HypeSquad1",
"name": "HypeSquad Bravery",
icon: "profileBadgeHypeSquadOnlineHouse1",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_2": {
value: true,
id: "HypeSquad2",
"name": "HypeSquad Brilliance",
icon: "profileBadgeHypeSquadOnlineHouse2",
size: 17
},
"HYPESQUAD_ONLINE_HOUSE_3": {
value: true,
id: "HypeSquad3",
"name": "HypeSquad Balance",
icon: "profileBadgeHypeSquadOnlineHouse3",
size: 17
},
"PREMIUM_EARLY_SUPPORTER": {
value: true,
id: "EarlySupporter",
"name": "EARLY_SUPPORTER_TOOLTIP",
icon: "profileBadgeEarlySupporter",
size: 24
},
"NITRO": {
value: true,
id: "Nitro",
"name": "Nitro",
icon: "profileBadgePremium",
size: 21
},
"GUILD_BOOST": {
value: true,
id: "NitroGuildBoost",
"name": "Nitro Guild Boost",
icon: "profileGuildSubscriberlvl",
size: 17,
types: [1,2,3,4,5,6,7,8,9]
}
},
indicators: {
"CURRENT_GUILD_BOOST": {
value: true,
id: "CurrentGuildBoost",
"name": "Current Nitro Guild Boost",
inner: `<svg name="PremiumGuildSubscriberBadge" class="${BDFDB.disCNS.memberpremiumicon + BDFDB.disCN.membericon}" aria-hidden="false" width="24" height="24" viewBox="0 0 8 12"><path d="M4 0L0 4V8L4 12L8 8V4L4 0ZM7 7.59L4 10.59L1 7.59V4.41L4 1.41L7 4.41V7.59Z" fill="currentColor"></path><path d="M2 4.83V7.17L4 9.17L6 7.17V4.83L4 2.83L2 4.83Z" fill="currentColor"></path></svg>`
},
}
};
this.css = `
${BDFDB.dotCN._badgeseverywherebadgeschat} {
display: inline-flex;
position: relative;
top: 2px;
}
${BDFDB.dotCN._badgeseverywheremini} {
margin-left: 5px;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCNS.messageusername} + ${BDFDB.dotCN._badgeseverywherebadges},
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagetimestampseparator} + ${BDFDB.dotCN._badgeseverywherebadges} {
margin-left: 0;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messageusername} ~ ${BDFDB.dotCN._badgeseverywherebadges} {
margin-right: .25rem;
text-indent: 0;
}
${BDFDB.dotCN._badgeseverywherebadgesinner} {
display: inline-grid;
grid-auto-flow: column;
grid-gap: 6px;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywherebadgesinner} {
grid-gap: 4px;
}
${BDFDB.dotCN._badgeseverywherebadge} {
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
${BDFDB.dotCN._badgeseverywhereindicator} {
display: flex;
align-items: center;
justify-content: center;
}
${BDFDB.dotCN._badgeseverywhereindicatorinner} {
position: static !important;
margin: 0 !important;
}
${BDFDB.dotCN._badgeseverywherebadge} {
height: 17px !important;
}
${BDFDB.dotCN._badgeseverywheresize17} {
width: 17px !important; min-width: 17px !important;
}
${BDFDB.dotCN._badgeseverywheresize21} {
width: 21px !important; min-width: 21px !important;
}
${BDFDB.dotCN._badgeseverywheresize22} {
width: 22px !important; min-width: 22px !important;
}
${BDFDB.dotCN._badgeseverywheresize24} {
width: 24px !important; min-width: 24px !important;
}
${BDFDB.dotCN._badgeseverywhereindicator} {
height: 14px !important; min-height: 14px !important; width: 14px !important; min-width: 14px !important;
}
${BDFDB.dotCN._badgeseverywhereindicatorinner} {
height: inherit !important; min-height: inherit !important; width: inherit !important; min-width: inherit !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywherebadge} {
height: 14px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize17} {
width: 14px !important; min-width: 14px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize21} {
width: 18px !important; min-width: 18px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize22} {
width: 18px !important; min-width: 18px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywheresize24} {
width: 19px !important; min-width: 19px !important;
}
${BDFDB.dotCNS._badgeseverywheremini + BDFDB.dotCN._badgeseverywhereindicator} {
height: 12px !important; min-height: 12px !important; width: 12px !important; min-width: 12px !important;
}
#app-mount ${BDFDB.dotCNS._badgeseverywherebadgessettings + BDFDB.dotCN._badgeseverywherebadge} {
width: 30px !important; min-width: 30px !important;
}
${BDFDB.dotCNS.userprofiletopsectionplaying + BDFDB.dotCN._badgeseverywherebadge} svg {
color: unset !important;
}
${BDFDB.dotCNS.member + BDFDB.dotCN.memberpremiumicon + BDFDB.notCN._badgeseverywhereindicatorinner} {display: none;}
`;
for (let flagName in BDFDB.DiscordConstants.UserFlags) if (this.defaults.badges[flagName]) {
if (BDFDB.LanguageUtils.LanguageStringsCheck[this.defaults.badges[flagName].name]) this.defaults.badges[flagName].name = BDFDB.LanguageUtils.LanguageStrings[this.defaults.badges[flagName].name];
this.defaults.badges[BDFDB.DiscordConstants.UserFlags[flagName]] = this.defaults.badges[flagName];
delete this.defaults.badges[flagName];
}
};
for (let flagname in BDFDB.DiscordConstants.UserFlags) if (this.defaults.badges[flagname]) {
if (BDFDB.LanguageUtils.LanguageStringsCheck[this.defaults.badges[flagname].name]) this.defaults.badges[flagname].name = BDFDB.LanguageUtils.LanguageStrings[this.defaults.badges[flagname].name];
this.defaults.badges[BDFDB.DiscordConstants.UserFlags[flagname]] = this.defaults.badges[flagname];
delete this.defaults.badges[flagname];
nitroFlag = Math.max(...BDFDB.ObjectUtils.toArray(BDFDB.DiscordConstants.UserFlags)) * 2;
this.defaults.badges[nitroFlag] = this.defaults.badges.NITRO;
delete this.defaults.badges.NITRO;
boostFlag = nitroFlag * 2;
this.defaults.badges[boostFlag] = this.defaults.badges.GUILD_BOOST;
delete this.defaults.badges.GUILD_BOOST;
for (let flag in this.defaults.badges) if (!this.defaults.badges[flag].icon || isNaN(parseInt(flag))) delete this.defaults.badges[flag];
}
nitroflag = Math.max(...BDFDB.ObjectUtils.toArray(BDFDB.DiscordConstants.UserFlags)) * 2;
this.defaults.badges[nitroflag] = this.defaults.badges.NITRO;
delete this.defaults.badges.NITRO;
boostflag = nitroflag * 2;
this.defaults.badges[boostflag] = this.defaults.badges.GUILD_BOOST;
delete this.defaults.badges.GUILD_BOOST;
for (let flag in this.defaults.badges) if (!this.defaults.badges[flag].icon || isNaN(parseInt(flag))) delete this.defaults.badges[flag];
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let badges = BDFDB.DataUtils.get(this, "badges");
let indicators = BDFDB.DataUtils.get(this, "indicators");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
for (let flag in badges) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["badges", flag],
label: this.defaults.badges[flag].name + (this.defaults.badges[flag].suffix ? ` ${this.defaults.badges[flag].suffix}` : ""),
value: badges[flag],
labelchildren: this.createSettingsBadges(flag)
}));
for (let flag in indicators) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["indicators", flag],
label: this.defaults.indicators[flag].name + (this.defaults.indicators[flag].suffix ? ` ${this.defaults.indicators[flag].suffix}` : ""),
value: indicators[flag],
labelchildren: this.createSettingsBadges(flag)
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Display Badges:",
first: settingsItems.length == 0,
last: true,
children: innerItems
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onStart() {
badgeClasses = BDFDB.ModuleUtils.findByProperties("profileBadgeStaff", "profileBadgePremium");
requestedUsers = {}, loadedUsers = {};
@ -331,9 +278,9 @@ var BadgesEverywhere = (_ => {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dispatch", {after: e => {
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == BDFDB.DiscordConstants.ActionTypes.USER_PROFILE_MODAL_FETCH_SUCCESS && e.methodArguments[0].user) {
let userCopy = Object.assign({}, e.methodArguments[0].user);
if (e.methodArguments[0].premium_since) userCopy.flags += nitroflag;
if (e.methodArguments[0].premium_since) userCopy.flags += nitroFlag;
userCopy.premium_since = e.methodArguments[0].premium_since;
if (e.methodArguments[0].premium_guild_since) userCopy.flags += boostflag;
if (e.methodArguments[0].premium_guild_since) userCopy.flags += boostFlag;
userCopy.premium_guild_since = e.methodArguments[0].premium_guild_since;
loadedUsers[e.methodArguments[0].user.id] = BDFDB.ObjectUtils.extract(userCopy, "flags", "premium_since", "premium_guild_since");
loadedUsers[e.methodArguments[0].user.id].date = (new Date()).getTime();
@ -351,152 +298,179 @@ var BadgesEverywhere = (_ => {
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.TimeUtils.clear(requestQueue.timeout);
this.forceUpdateAll();
}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [], innerItems = [];
BDFDB.PluginUtils.clear(this);
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
for (let flag in badges) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["badges", flag],
label: this.defaults.badges[flag].name + (this.defaults.badges[flag].suffix ? ` ${this.defaults.badges[flag].suffix}` : ""),
value: badges[flag],
labelchildren: this.createSettingsBadges(flag)
}));
for (let flag in indicators) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["indicators", flag],
label: this.defaults.indicators[flag].name + (this.defaults.indicators[flag].suffix ? ` ${this.defaults.indicators[flag].suffix}` : ""),
value: indicators[flag],
labelchildren: this.createSettingsBadges(flag)
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Display Badges:",
first: settingsItems.length == 0,
last: true,
children: innerItems
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processMemberListItem (e) {
if (e.instance.props.user && settings.showInMemberList) {
this.injectBadges(e.instance, BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "list");
}
}
processMessageHeader (e) {
if (e.instance.props.message && settings.showInChat) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) this.injectBadges(e.instance, children, e.instance.props.message.author, "chat");
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.showInPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectBadges(e.instance, children, e.instance.props.user, "popout", e.instance.props.activity && e.instance.props.activity.type != BDFDB.DiscordConstants.ActivityTypes.CUSTOM_STATUS);
}
}
injectBadges (instance, children, user, type, colored) {
if (!BDFDB.ArrayUtils.is(children) || !user || user.bot) return;
if (loadedUsers[user.id] && ((new Date()).getTime() - loadedUsers[user.id].date < 1000*60*60*24*7)) children.push(this.createBadges(user, type, colored));
else if (!BDFDB.ArrayUtils.is(requestedUsers[user.id])) {
requestedUsers[user.id] = [instance];
requestQueue.queue.push(user.id);
this.runQueue();
}
else requestedUsers[user.id].push(instance);
}
runQueue () {
if (!requestQueue.id) {
let id = requestQueue.queue.shift();
if (id) {
requestQueue.id = id;
BDFDB.TimeUtils.clear(requestQueue.timeout);
requestQueue.timeout = BDFDB.TimeUtils.timeout(_ => {
requestQueue.id = null;
this.runQueue();
}, 30000);
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(id);
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
}
createWrapper (renderedBadges, type, uncolored) {
let colorWrapper = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<span class="${uncolored ? BDFDB.disCN.userprofiletopsectionplaying : BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;"></span>`));
colorWrapper.props.children = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._badgeseverywherebadgesinner,
children: renderedBadges
});
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywherebadges, BDFDB.disCN[`_badgeseverywherebadges${type}`], miniTypes.includes(type) && BDFDB.disCN._badgeseverywheremini),
children: colorWrapper
});
}
createBadges (user, type, uncolored) {
let renderedBadges = [];
for (let flag in badges) if ((loadedUsers[user.id].flags | flag) == loadedUsers[user.id].flags && badges[flag]) {
renderedBadges.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, flag) : null, type, flag, flag == boostflag ? BDFDB.LibraryModules.GuildBoostUtils.getUserLevel(loadedUsers[user.id].premium_guild_since) : null));
}
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), user.id);
if (indicators.CURRENT_GUILD_BOOST && member && member.premiumSince) {
renderedBadges.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, "CURRENT_GUILD_BOOST") : null, type, "CURRENT_GUILD_BOOST"));
}
if (!renderedBadges.length) return null;
else return this.createWrapper(renderedBadges, type, uncolored == undefined ? !settings.useColoredVersion : uncolored);
}
createBadge (timestring, type, flag, rank) {
let data = this.defaults.badges[flag] || this.defaults.indicators[flag];
if (!data) return null;
let inner = data.inner && BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(data.inner));
if (inner) inner.props.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywhereindicatorinner, inner.props.className);
else inner = null;
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: timestring || (data.name + (data.suffix ? ` ${data.suffix}` : "") + (rank ? ` Level ${rank}` : "")),
tooltipConfig: {style: "white-space: nowrap; max-width: unset;"},
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywherebadge, data.inner && BDFDB.disCN._badgeseverywhereindicator, data.icon && badgeClasses[data.icon + (rank || "")], data.size && BDFDB.disCN[`_badgeseverywheresize${data.size}`]),
badgeId: data.id,
children: inner
})
});
}
getTimeString (id, flag) {
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), id);
if (flag == nitroflag) return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_BADGE_TOOLTIP", new Date(loadedUsers[id].premium_since));
else if (flag == boostflag) return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(loadedUsers[id].premium_guild_since));
else if (member && flag == "CURRENT_GUILD_BOOST") return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(member.premiumSince));
return null;
}
createSettingsBadges (flag) {
let data = this.defaults.badges[flag] || this.defaults.indicators[flag];
if (!data) return null;
let eles = null;
if (Array.isArray(data.types)) {
let renderedBadges = [];
for (let rank of data.types) renderedBadges.push(this.createBadge(null, "settings", flag, rank));
eles = BDFDB.ReactUtils.createElement("div", {children: [this.createWrapper(renderedBadges, "settings", false), BDFDB.ReactUtils.createElement("br"), this.createWrapper(renderedBadges, "settings", true)]});
}
else {
let badge = this.createBadge(null, "settings", flag);
eles = [this.createWrapper(badge, "settings", false), this.createWrapper(badge, "settings", true)];
}
return eles;
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
badges = BDFDB.DataUtils.get(this, "badges");
indicators = BDFDB.DataUtils.get(this, "indicators");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
})();
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
badges = BDFDB.DataUtils.get(this, "badges");
indicators = BDFDB.DataUtils.get(this, "indicators");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
module.exports = BadgesEverywhere;
processMemberListItem (e) {
if (e.instance.props.user && settings.showInMemberList) {
this.injectBadges(e.instance, BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "list");
}
}
processMessageHeader (e) {
if (e.instance.props.message && settings.showInChat) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) this.injectBadges(e.instance, children, e.instance.props.message.author, "chat");
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.showInPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectBadges(e.instance, children, e.instance.props.user, "popout", e.instance.props.activity && e.instance.props.activity.type != BDFDB.DiscordConstants.ActivityTypes.CUSTOM_STATUS);
}
}
injectBadges (instance, children, user, type, colored) {
if (!BDFDB.ArrayUtils.is(children) || !user || user.bot) return;
if (loadedUsers[user.id] && ((new Date()).getTime() - loadedUsers[user.id].date < 1000*60*60*24*7)) children.push(this.createBadges(user, type, colored));
else if (!BDFDB.ArrayUtils.is(requestedUsers[user.id])) {
requestedUsers[user.id] = [instance];
requestQueue.queue.push(user.id);
this.runQueue();
}
else requestedUsers[user.id].push(instance);
}
runQueue () {
if (!requestQueue.id) {
let id = requestQueue.queue.shift();
if (id) {
requestQueue.id = id;
BDFDB.TimeUtils.clear(requestQueue.timeout);
requestQueue.timeout = BDFDB.TimeUtils.timeout(_ => {
requestQueue.id = null;
this.runQueue();
}, 30000);
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(id);
}
}
}
createWrapper (renderedBadges, type, uncolored) {
let colorWrapper = BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<span class="${uncolored ? BDFDB.disCN.userprofiletopsectionplaying : BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;"></span>`));
colorWrapper.props.children = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._badgeseverywherebadgesinner,
children: renderedBadges
});
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywherebadges, BDFDB.disCN[`_badgeseverywherebadges${type}`], miniTypes.includes(type) && BDFDB.disCN._badgeseverywheremini),
children: colorWrapper
});
}
createBadges (user, type, uncolored) {
let renderedBadges = [];
for (let flag in badges) if ((loadedUsers[user.id].flags | flag) == loadedUsers[user.id].flags && badges[flag]) {
renderedBadges.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, flag) : null, type, flag, flag == boostFlag ? BDFDB.LibraryModules.GuildBoostUtils.getUserLevel(loadedUsers[user.id].premium_guild_since) : null));
}
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), user.id);
if (indicators.CURRENT_GUILD_BOOST && member && member.premiumSince) {
renderedBadges.push(this.createBadge(settings.showNitroDate ? this.getTimeString(user.id, "CURRENT_GUILD_BOOST") : null, type, "CURRENT_GUILD_BOOST"));
}
if (!renderedBadges.length) return null;
else return this.createWrapper(renderedBadges, type, uncolored == undefined ? !settings.useColoredVersion : uncolored);
}
createBadge (timestring, type, flag, rank) {
let data = this.defaults.badges[flag] || this.defaults.indicators[flag];
if (!data) return null;
let inner = data.inner && BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(data.inner));
if (inner) inner.props.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywhereindicatorinner, inner.props.className);
else inner = null;
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: timestring || (data.name + (data.suffix ? ` ${data.suffix}` : "") + (rank ? ` Level ${rank}` : "")),
tooltipConfig: {style: "white-space: nowrap; max-width: unset;"},
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._badgeseverywherebadge, data.inner && BDFDB.disCN._badgeseverywhereindicator, data.icon && badgeClasses[data.icon + (rank || "")], data.size && BDFDB.disCN[`_badgeseverywheresize${data.size}`]),
badgeId: data.id,
children: inner
})
});
}
getTimeString (id, flag) {
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), id);
if (flag == nitroFlag) return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_BADGE_TOOLTIP", new Date(loadedUsers[id].premium_since));
else if (flag == boostFlag) return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(loadedUsers[id].premium_guild_since));
else if (member && flag == "CURRENT_GUILD_BOOST") return BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(member.premiumSince));
return null;
}
createSettingsBadges (flag) {
let data = this.defaults.badges[flag] || this.defaults.indicators[flag];
if (!data) return null;
let eles = null;
if (Array.isArray(data.types)) {
let renderedBadges = [];
for (let rank of data.types) renderedBadges.push(this.createBadge(null, "settings", flag, rank));
eles = BDFDB.ReactUtils.createElement("div", {children: [this.createWrapper(renderedBadges, "settings", false), BDFDB.ReactUtils.createElement("br"), this.createWrapper(renderedBadges, "settings", true)]});
}
else {
let badge = this.createBadge(null, "settings", flag);
eles = [this.createWrapper(badge, "settings", false), this.createWrapper(badge, "settings", true)];
}
return eles;
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,333 +1,316 @@
//META{"name":"BetterFriendList","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/BetterFriendList","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterFriendList/BetterFriendList.plugin.js"}*//
var BetterFriendList = (_ => {
var rerenderTimeout, sortKey, sortReversed, searchQuery, searchTimeout;
var settings = {};
const placeHolderId = "PLACEHOLDER_BETTERFRIENDLIST";
const statusSortOrder = {
online: 0,
streaming: 1,
idle: 2,
dnd: 3,
offline: 4,
invisible: 5,
unknown: 6
module.exports = (_ => {
const config = {
"info": {
"name": "BetterFriendList",
"author": "DevilBro",
"version": "1.2.9",
"description": "Adds extra controls to the friends page, like sort by name/status, search and all/request/blocked amount."
},
"changeLog": {
"progress": {
"New Features & Name": "Name was changed from BetterFriendCount to BetterFriendList and new features were added"
},
"fixed": {
"Empty Search": "Empty search no longer stops the friend list from being displayed"
},
"improved": {
"Settings": "You can now disable the single features of this plugin"
},
"added": {
"Mutual Servers": "Mutual servers are now displayed in the friend list again"
}
}
};
return class BetterFriendList {
getName () {return "BetterFriendList";}
getVersion () {return "1.2.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds extra controls to the friends page, like sort by name/status, search and all/request/blocked amount.";}
initConstructor () {
sortKey = null;
sortReversed = false;
searchQuery = "";
this.css = `
${BDFDB.dotCN.peoplewrapper} > * {
justify-content: unset;
}
${BDFDB.dotCNS.peoplewrapper + BDFDB.dotCN.userinfo} {
flex: 1 1 auto;
}
${BDFDB.dotCN._betterfriendlistmutualguilds} {
margin-left: 13px;
width: 200px;
}
${BDFDB.dotCN._betterfriendlisttitle} {
width: 200px;
}
${BDFDB.dotCN._betterfriendlistnamecell} {
width: 150px;
}
`;
this.defaults = {
settings: {
addTotalAmount: {value:true, description:"Add total amount for all/requested/blocked"},
addSortOptions: {value:true, description:"Add sort options"},
addSearchbar: {value:true, description:"Add searchbar"},
addMutualGuild: {value:true, description:"Add mutual servers in friend list"}
}
};
}
constructor () {
this.changelog = {
"progress":[["New Features & Name","Name was changed from BetterFriendCount to BetterFriendList and new features were added"]],
"fixed":[["Empty Search","Empty search no longer stops the friend list from being displayed"]],
"improved":[["Settings","You can now disable the single features of this plugin"]],
"added":[["Mutual Servers","Mutual servers are now displayed in the friend list again"]]
};
this.patchedModules = {
before: {
PeopleListSectionedLazy: "default",
},
after: {
TabBar: "render",
PeopleListSectionedLazy: "default",
FriendRow: "render",
PendingRow: "default",
BlockedRow: "render",
PeopleListItem: ["render", "componentWillMount","componentWillUnmount"]
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processTabBar (e) {
if (settings.addTotalAmount && e.returnvalue.props.children) for (let checkChild of e.returnvalue.props.children) if (checkChild && checkChild.props.id == "ADD_FRIEND") {
let relationships = BDFDB.LibraryModules.FriendUtils.getRelationships(), relationshipCount = {};
for (let type in BDFDB.DiscordConstants.RelationshipTypes) relationshipCount[type] = 0;
for (let id in relationships) relationshipCount[relationships[id]]++;
for (let child of e.returnvalue.props.children) if (child && child.props.id != "ADD_FRIEND") {
let newChildren = [child.props.children].flat().filter(child => BDFDB.ObjectUtils.get(child, "type.displayName") != "NumberBadge");
switch (child.props.id) {
case "ALL":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.FRIEND]));
break;
case "ONLINE":
newChildren.push(this.createBadge(BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount()));
break;
case "PENDING":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_INCOMING]));
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_OUTGOING]));
break;
case "BLOCKED":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.BLOCKED]));
break;
}
child.props.children = newChildren;
}
break;
}
}
processPeopleListSectionedLazy (e) {
if (sortKey || searchQuery) {
e.instance.props.statusSections = [].concat(e.instance.props.statusSections).map(section => {
let newSection = [].concat(section);
if (searchQuery) {
let usedSearchQuery = searchQuery.toLowerCase();
newSection = newSection.filter(user => user && typeof user.usernameLower == "string" && user.usernameLower.indexOf(usedSearchQuery) > -1);
}
if (sortKey) {
newSection = BDFDB.ArrayUtils.keySort(newSection.map(user => Object.assign({}, user, {statusIndex: statusSortOrder[user.status]})), sortKey);
if (sortReversed) newSection.reverse();
}
if (!newSection.length) {
let placeholder = new BDFDB.DiscordObjects.User({
id: placeHolderId,
username: placeHolderId
});
if (placeholder) newSection.push(new BDFDB.DiscordObjects.Relationship({
activities: [],
applicationStream: null,
isMobile: false,
key: placeHolderId,
mutualGuilds: [],
mutualGuildsLength: 0,
status: "offline",
type: BDFDB.DiscordConstants.RelationshipTypes.NONE,
user: placeholder,
usernameLower: placeholder.usernameNormalized
}));
}
return newSection;
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
let getSectionTitle = e.instance.props.getSectionTitle;
e.instance.props.getSectionTitle = (...args) => {
let users = e.instance.props.statusSections.flat(10);
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._betterfriendlisttitle,
children: getSectionTitle(...args).replace(users.length, users.filter(u => u && u.key != placeHolderId).length)
}),
settings.addSortOptions && [
{key: "usernameLower", label: BDFDB.LanguageUtils.LanguageStrings.FRIENDS_COLUMN_NAME},
{key: "statusIndex", label: BDFDB.LanguageUtils.LanguageStrings.FRIENDS_COLUMN_STATUS}
].filter(n => n).map(data => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.tableheadercellwrapper, BDFDB.disCN.tableheadercell, BDFDB.disCN._betterfriendlistnamecell, sortKey == data.key && BDFDB.disCN.tableheadercellsorted, BDFDB.disCN.tableheadercellclickable),
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.tableheadercellcontent,
children: [
data.label,
sortKey == data.key && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.tableheadersorticon,
name: BDFDB.LibraryComponents.SvgIcon.Names[sortReversed ? "ARROW_UP" : "ARROW_DOWN"]
})
].filter(n => n)
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var rerenderTimeout, sortKey, sortReversed, searchQuery, searchTimeout;
var settings = {};
const placeHolderId = "PLACEHOLDER_BETTERFRIENDLIST";
const statusSortOrder = {
online: 0,
streaming: 1,
idle: 2,
dnd: 3,
offline: 4,
invisible: 5,
unknown: 6
};
return class BetterFriendList extends Plugin {
onLoad() {
this.defaults = {
settings: {
addTotalAmount: {value:true, description:"Add total amount for all/requested/blocked"},
addSortOptions: {value:true, description:"Add sort options"},
addSearchbar: {value:true, description:"Add searchbar"},
addMutualGuild: {value:true, description:"Add mutual servers in friend list"}
}
};
this.patchedModules = {
before: {
PeopleListSectionedLazy: "default",
},
after: {
TabBar: "render",
PeopleListSectionedLazy: "default",
FriendRow: "render",
PendingRow: "default",
BlockedRow: "render",
PeopleListItem: ["render", "componentDidMount","componentWillUnmount"]
}
};
this.css = `
${BDFDB.dotCN.peoplewrapper} > * {
justify-content: unset;
}
${BDFDB.dotCNS.peoplewrapper + BDFDB.dotCN.userinfo} {
flex: 1 1 auto;
}
${BDFDB.dotCN._betterfriendlistmutualguilds} {
margin-left: 13px;
width: 200px;
}
${BDFDB.dotCN._betterfriendlisttitle} {
width: 200px;
}
${BDFDB.dotCN._betterfriendlistnamecell} {
width: 150px;
}
`;
}
onStart() {
sortKey = null;
sortReversed = false;
searchQuery = "";
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
this.rerenderList();
}
processTabBar (e) {
if (settings.addTotalAmount && e.returnvalue.props.children) for (let checkChild of e.returnvalue.props.children) if (checkChild && checkChild.props.id == "ADD_FRIEND") {
let relationships = BDFDB.LibraryModules.FriendUtils.getRelationships(), relationshipCount = {};
for (let type in BDFDB.DiscordConstants.RelationshipTypes) relationshipCount[type] = 0;
for (let id in relationships) relationshipCount[relationships[id]]++;
for (let child of e.returnvalue.props.children) if (child && child.props.id != "ADD_FRIEND") {
let newChildren = [child.props.children].flat().filter(child => BDFDB.ObjectUtils.get(child, "type.displayName") != "NumberBadge");
switch (child.props.id) {
case "ALL":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.FRIEND]));
break;
case "ONLINE":
newChildren.push(this.createBadge(BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount()));
break;
case "PENDING":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_INCOMING]));
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_OUTGOING]));
break;
case "BLOCKED":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.BLOCKED]));
break;
}
child.props.children = newChildren;
}
break;
}
}
processPeopleListSectionedLazy (e) {
if (sortKey || searchQuery) {
e.instance.props.statusSections = [].concat(e.instance.props.statusSections).map(section => {
let newSection = [].concat(section);
if (searchQuery) {
let usedSearchQuery = searchQuery.toLowerCase();
newSection = newSection.filter(user => user && typeof user.usernameLower == "string" && user.usernameLower.indexOf(usedSearchQuery) > -1);
}
if (sortKey) {
newSection = BDFDB.ArrayUtils.keySort(newSection.map(user => Object.assign({}, user, {statusIndex: statusSortOrder[user.status]})), sortKey);
if (sortReversed) newSection.reverse();
}
if (!newSection.length) {
let placeholder = new BDFDB.DiscordObjects.User({
id: placeHolderId,
username: placeHolderId
});
if (placeholder) newSection.push(new BDFDB.DiscordObjects.Relationship({
activities: [],
applicationStream: null,
isMobile: false,
key: placeHolderId,
mutualGuilds: [],
mutualGuildsLength: 0,
status: "offline",
type: BDFDB.DiscordConstants.RelationshipTypes.NONE,
user: placeholder,
usernameLower: placeholder.usernameNormalized
}));
}
return newSection;
});
}
let getSectionTitle = e.instance.props.getSectionTitle;
e.instance.props.getSectionTitle = (...args) => {
let users = e.instance.props.statusSections.flat(10);
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._betterfriendlisttitle,
children: getSectionTitle(...args).replace(users.length, users.filter(u => u && u.key != placeHolderId).length)
}),
onClick: event => {
if (sortKey == data.key) {
if (!sortReversed) sortReversed = true;
settings.addSortOptions && [
{key: "usernameLower", label: BDFDB.LanguageUtils.LanguageStrings.FRIENDS_COLUMN_NAME},
{key: "statusIndex", label: BDFDB.LanguageUtils.LanguageStrings.FRIENDS_COLUMN_STATUS}
].filter(n => n).map(data => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.tableheadercellwrapper, BDFDB.disCN.tableheadercell, BDFDB.disCN._betterfriendlistnamecell, sortKey == data.key && BDFDB.disCN.tableheadercellsorted, BDFDB.disCN.tableheadercellclickable),
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.tableheadercellcontent,
children: [
data.label,
sortKey == data.key && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.tableheadersorticon,
name: BDFDB.LibraryComponents.SvgIcon.Names[sortReversed ? "ARROW_UP" : "ARROW_DOWN"]
})
].filter(n => n)
}),
onClick: event => {
if (sortKey == data.key) {
if (!sortReversed) sortReversed = true;
else {
sortKey = null;
sortReversed = false;
}
}
else {
sortKey = null;
sortKey = data.key;
sortReversed = false;
}
}
else {
sortKey = data.key;
sortReversed = false;
}
this.rerenderList();
}
})),
settings.addSearchbar && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
query: searchQuery,
onChange: value => {
BDFDB.TimeUtils.clear(searchTimeout);
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
searchQuery = value;
this.rerenderList();
}, 1000);
},
onClear: _ => {
searchQuery = "";
this.rerenderList();
}
})),
settings.addSearchbar && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
query: searchQuery,
onChange: value => {
BDFDB.TimeUtils.clear(searchTimeout);
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
searchQuery = value;
this.rerenderList();
}, 1000);
},
onClear: _ => {
searchQuery = "";
this.rerenderList();
}
})
})
})
].flat(10).filter(n => n)
});
};
}
processFriendRow (e) {
e.returnvalue.props.mutualGuilds = e.instance.props.mutualGuilds;
}
processPendingRow (e) {
this.processFriendRow(e);
}
processBlockedRow (e) {
this.processFriendRow(e);
}
processPeopleListItem (e) {
if (e.node) {
BDFDB.TimeUtils.clear(rerenderTimeout);
rerenderTimeout = BDFDB.TimeUtils.timeout(_ => {BDFDB.PatchUtils.forceAllUpdates(this, "TabBar");}, 1000);
].flat(10).filter(n => n)
});
};
}
else {
if (e.instance.props.user.id == placeHolderId) return null;
else if (settings.addMutualGuild && e.instance.props.mutualGuilds && e.instance.props.mutualGuilds.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "UserInfo"});
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildSummaryItem, {
className: BDFDB.disCN._betterfriendlistmutualguilds,
guilds: e.instance.props.mutualGuilds,
showTooltip: true,
max: 10
}, true));
processFriendRow (e) {
e.returnvalue.props.mutualGuilds = e.instance.props.mutualGuilds;
}
processPendingRow (e) {
this.processFriendRow(e);
}
processBlockedRow (e) {
this.processFriendRow(e);
}
processPeopleListItem (e) {
if (e.node) {
BDFDB.TimeUtils.clear(rerenderTimeout);
rerenderTimeout = BDFDB.TimeUtils.timeout(_ => {BDFDB.PatchUtils.forceAllUpdates(this, "TabBar");}, 1000);
}
else {
if (e.instance.props.user.id == placeHolderId) return null;
else if (settings.addMutualGuild && e.instance.props.mutualGuilds && e.instance.props.mutualGuilds.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "UserInfo"});
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildSummaryItem, {
className: BDFDB.disCN._betterfriendlistmutualguilds,
guilds: e.instance.props.mutualGuilds,
showTooltip: true,
max: 10
}, true));
}
}
}
}
createBadge (amount) {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, {
className: BDFDB.disCN.peoplesbadge,
count: amount,
style: {marginLeft: 6}
});
}
rerenderList () {
let selectedButton = document.querySelector(BDFDB.dotCNS.peoplestabbar + BDFDB.dotCN.settingsitemselected);
if (selectedButton) selectedButton.click();
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
this.rerenderList();
}
}
})();
module.exports = BetterFriendList;
createBadge (amount) {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, {
className: BDFDB.disCN.peoplesbadge,
count: amount,
style: {marginLeft: 6}
});
}
rerenderList () {
let selectedButton = document.querySelector(BDFDB.dotCNS.peoplestabbar + BDFDB.dotCN.settingsitemselected);
if (selectedButton) selectedButton.click();
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,95 +1,76 @@
//META{"name":"BetterNsfwTag","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/BetterNsfwTag","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterNsfwTag/BetterNsfwTag.plugin.js"}*//
var BetterNsfwTag = (_ => {
return class BetterNsfwTag {
getName () {return "BetterNsfwTag";}
getVersion () {return "1.2.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a more noticeable tag to NSFW channels.";}
constructor () {
this.changelog = {
"improved":[["Position","Tag was repositioned similar to the mentions badge"],["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
};
module.exports = (_ => {
const config = {
"info": {
"name": "BetterNsfwTag",
"author": "DevilBro",
"version": "1.2.4",
"description": "Adds a more noticeable tag to NSFW channels."
},
"changeLog": {
"improved": {
"Position": "Tag was repositioned similar to the mentions badge",
"New Library Structure & React": "Restructured my Library and switched to React rendering instead of DOM manipulation"
}
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class BetterNsfwTag extends Plugin {
onLoad() {
this.patchedModules = {
after: {
ChannelItem: "render"
}
};
}
this.patchedModules = {
after: {
ChannelItem: "render"
}
};
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processChannelItem (e) {
if (e.instance.props.channel && e.instance.props.channel.nsfw) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.channelchildren]]});
if (index > -1 && children[index].props && children[index].props.children) {
let [oldTagParent, oldTagIndex] = BDFDB.ReactUtils.findParent(children[index], {key: "NSFW-badge"});
if (oldTagIndex > -1) oldTagParent.splice(oldTagIndex, 1);
children[index].props.children.push(BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS._betternsfwtagtag + BDFDB.disCN.channelchildiconbase,
key: "NSFW-badge",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
style: {borderRadius: "3px"},
text: "NSFW"
})
}));
processChannelItem (e) {
if (e.instance.props.channel && e.instance.props.channel.nsfw) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.channelchildren]]});
if (index > -1 && children[index].props && children[index].props.children) {
let [oldTagParent, oldTagIndex] = BDFDB.ReactUtils.findParent(children[index], {key: "NSFW-badge"});
if (oldTagIndex > -1) oldTagParent.splice(oldTagIndex, 1);
children[index].props.children.push(BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS._betternsfwtagtag + BDFDB.disCN.channelchildiconbase,
key: "NSFW-badge",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
style: {borderRadius: "3px"},
text: "NSFW"
})
}));
}
}
}
}
}
})();
module.exports = BetterNsfwTag;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,201 +1,178 @@
//META{"name":"BetterSearchPage","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/BetterSearchPage","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterSearchPage/BetterSearchPage.plugin.js"}*//
var BetterSearchPage = (_ => {
var settings = {};
return class BetterSearchPage {
getName () {return "BetterSearchPage";}
getVersion () {return "1.1.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds some extra controls to the search results page.";}
constructor () {
this.patchedModules = {
after: {
SearchResultsInner: "default"
}
};
}
initConstructor () {
this.defaults = {
settings: {
addFirstLast: {value:true, description:"Adds a first and last page button."},
addJumpTo: {value:true, description:"Adds a jump to input field (press enter to jump)."},
cloneToTheTop: {value:true, description:"Clones the controls to the top of the results page."}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed (e) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processSearchResultsInner (e) {
if (e.instance.props.search) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name:"SearchPagination"});
if (index > -1) {
let currentPage = parseInt(Math.floor(e.instance.props.search.offset / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) + 1;
let maxPage = e.instance.props.search.totalResults > 5000 ? parseInt(Math.ceil(5000 / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) : parseInt(Math.ceil(e.instance.props.search.totalResults / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE));
let doJump = page => {
page = page < 1 ? 1 : (page > maxPage ? maxPage : page);
if (page < currentPage) BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(e.instance.props.searchId, (currentPage - page) * BDFDB.DiscordConstants.SEARCH_PAGE_SIZE);
else if (page > currentPage) BDFDB.LibraryModules.SearchPageUtils.searchNextPage(e.instance.props.searchId, (page - currentPage) * BDFDB.DiscordConstants.SEARCH_PAGE_SIZE);
};
let pagination = children[index].type(children[index].props);
if (!pagination) return;
if (currentPage >= maxPage) {
pagination.props.children[2].props.className = BDFDB.DOMUtils.formatClassName(pagination.props.children[2].props.className, BDFDB.disCN.searchresultspaginationdisabled);
pagination.props.children[2].props.onClick = _ => {};
}
pagination.props.children[0] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: "Previous",
children: pagination.props.children[0]
});
pagination.props.children[2] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: currentPage >= maxPage ? "Max Page is 200" : "Next",
tooltipConfig: {color: currentPage >= maxPage && BDFDB.LibraryComponents.TooltipContainer.Colors.RED},
children: pagination.props.children[2]
});
if (settings.addFirstLast) {
pagination.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LibraryStrings.first,
"aria-label": BDFDB.LanguageUtils.LibraryStrings.first,
onClick: _ => {if (currentPage != 1) doJump(1);},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.searchresultspaginationbutton, currentPage == 1 && BDFDB.disCN.searchresultspaginationdisabled, BDFDB.disCN.focusable),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.LEFT_DOUBLE_CARET
})
})
}));
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: currentPage >= maxPage ? "Max Page is 200" : BDFDB.LanguageUtils.LibraryStrings.last,
tooltipConfig: {color: currentPage >= maxPage && BDFDB.LibraryComponents.TooltipContainer.Colors.RED},
"aria-label": BDFDB.LanguageUtils.LibraryStrings.last,
onClick: _ => {if (currentPage != maxPage) doJump(maxPage);},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.searchresultspaginationbutton, currentPage >= maxPage && BDFDB.disCN.searchresultspaginationdisabled, BDFDB.disCN.focusable),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_DOUBLE_CARET
})
})
}));
}
if (settings.addJumpTo) {
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
key: "BSP-pagination-jumpinput",
type: "number",
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
value: currentPage,
min: 1,
max: maxPage,
onKeyDown: (event, instance) => {if (event.which == 13) doJump(instance.props.value);}
}));
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.JUMP,
"aria-label": BDFDB.LanguageUtils.LanguageStrings.JUMP,
onClick: (event, instance) => {
let jumpInput = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key:"BSP-pagination-jumpinput"});
if (jumpInput) doJump(jumpInput.props.value);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.searchresultspaginationbutton,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
style: {transform: "rotate(90deg"},
name: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_CARET
})
})
}));
}
children[index] = pagination;
if (settings.cloneToTheTop) children.unshift(pagination);
}
}
module.exports = (_ => {
const config = {
"info": {
"name": "BetterSearchPage",
"author": "DevilBro",
"version": "1.1.5",
"description": "Adds some extra controls to the search results page."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {};
return class BetterSearchPage extends Plugin {
onLoad() {
this.defaults = {
settings: {
addFirstLast: {value:true, description:"Adds a first and last page button."},
addJumpTo: {value:true, description:"Adds a jump to input field (press enter to jump)."},
cloneToTheTop: {value:true, description:"Clones the controls to the top of the results page."}
}
};
this.patchedModules = {
after: {
SearchResultsInner: "default"
}
};
}
BDFDB.PatchUtils.forceAllUpdates(this);
}
}
})();
onStart() {
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
module.exports = BetterSearchPage;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed (e) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processSearchResultsInner (e) {
if (e.instance.props.search) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name:"SearchPagination"});
if (index > -1) {
let currentPage = parseInt(Math.floor(e.instance.props.search.offset / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) + 1;
let maxPage = e.instance.props.search.totalResults > 5000 ? parseInt(Math.ceil(5000 / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE)) : parseInt(Math.ceil(e.instance.props.search.totalResults / BDFDB.DiscordConstants.SEARCH_PAGE_SIZE));
let doJump = page => {
page = page < 1 ? 1 : (page > maxPage ? maxPage : page);
if (page < currentPage) BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(e.instance.props.searchId, (currentPage - page) * BDFDB.DiscordConstants.SEARCH_PAGE_SIZE);
else if (page > currentPage) BDFDB.LibraryModules.SearchPageUtils.searchNextPage(e.instance.props.searchId, (page - currentPage) * BDFDB.DiscordConstants.SEARCH_PAGE_SIZE);
};
let pagination = children[index].type(children[index].props);
if (!pagination) return;
if (currentPage >= maxPage) {
pagination.props.children[2].props.className = BDFDB.DOMUtils.formatClassName(pagination.props.children[2].props.className, BDFDB.disCN.searchresultspaginationdisabled);
pagination.props.children[2].props.onClick = _ => {};
}
pagination.props.children[0] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: "Previous",
children: pagination.props.children[0]
});
pagination.props.children[2] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: currentPage >= maxPage ? "Max Page is 200" : "Next",
tooltipConfig: {color: currentPage >= maxPage && BDFDB.LibraryComponents.TooltipContainer.Colors.RED},
children: pagination.props.children[2]
});
if (settings.addFirstLast) {
pagination.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LibraryStrings.first,
"aria-label": BDFDB.LanguageUtils.LibraryStrings.first,
onClick: _ => {if (currentPage != 1) doJump(1);},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.searchresultspaginationbutton, currentPage == 1 && BDFDB.disCN.searchresultspaginationdisabled, BDFDB.disCN.focusable),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.LEFT_DOUBLE_CARET
})
})
}));
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: currentPage >= maxPage ? "Max Page is 200" : BDFDB.LanguageUtils.LibraryStrings.last,
tooltipConfig: {color: currentPage >= maxPage && BDFDB.LibraryComponents.TooltipContainer.Colors.RED},
"aria-label": BDFDB.LanguageUtils.LibraryStrings.last,
onClick: _ => {if (currentPage != maxPage) doJump(maxPage);},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.searchresultspaginationbutton, currentPage >= maxPage && BDFDB.disCN.searchresultspaginationdisabled, BDFDB.disCN.focusable),
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_DOUBLE_CARET
})
})
}));
}
if (settings.addJumpTo) {
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
key: "BSP-pagination-jumpinput",
type: "number",
size: BDFDB.LibraryComponents.TextInput.Sizes.MINI,
value: currentPage,
min: 1,
max: maxPage,
onKeyDown: (event, instance) => {if (event.which == 13) doJump(instance.props.value);}
}));
pagination.props.children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.JUMP,
"aria-label": BDFDB.LanguageUtils.LanguageStrings.JUMP,
onClick: (event, instance) => {
let jumpInput = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key:"BSP-pagination-jumpinput"});
if (jumpInput) doJump(jumpInput.props.value);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.searchresultspaginationbutton,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.searchresultspaginationicon,
style: {transform: "rotate(90deg"},
name: BDFDB.LibraryComponents.SvgIcon.Names.RIGHT_CARET
})
})
}));
}
children[index] = pagination;
if (settings.cloneToTheTop) children.unshift(pagination);
}
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,186 +1,165 @@
//META{"name":"CharCounter","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/CharCounter","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CharCounter/CharCounter.plugin.js"}*//
var CharCounter = (_ => {
const maxLenghts = {
normal: 2000,
edit: 2000,
form: 2000,
nick: 32,
customstatus: 128,
popoutnote: 256,
profilenote: 256
module.exports = (_ => {
const config = {
"info": {
"name": "CharCounter",
"author": "DevilBro",
"version": "1.4.9",
"description": "Adds a charcounter in the chat."
},
"changeLog": {
"added": {
"Custom Status": "Added counter to custom status input"
}
}
};
const typeMap = {
normal: "chat",
form: "upload"
};
return class CharCounter {
getName () {return "CharCounter";}
getVersion () {return "1.4.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a charcounter in the chat.";}
constructor () {
this.changelog = {
"added":[["Custom Status","Added counter to custom status input"]]
};
this.patchedModules = {
after: {
ChannelTextAreaContainer: "render",
Note: "render",
ChangeNickname: "render",
CustomStatusModal: "render"
}
};
}
initConstructor () {
this.css = `
${BDFDB.dotCN._charcountercounteradded} {
position: relative !important;
}
${BDFDB.dotCN._charcountercounter} {
display: block;
position: absolute;
z-index: 1000;
pointer-events: none;
font-size: 15px;
}
${BDFDB.dotCN._charcounterchatcounter} {
right: 0;
bottom: -1.3em;
}
${BDFDB.dotCN._charcountereditcounter} {
right: 0;
bottom: -1.3em;
}
${BDFDB.dotCN._charcounteruploadcounter} {
right: 0;
bottom: -1.0em;
}
${BDFDB.dotCN._charcounternickcounter} {
right: 0 !important;
top: 0 !important;
}
${BDFDB.dotCN._charcountercustomstatuscounter} {
right: 0 !important;
top: -1.5em;
}
${BDFDB.dotCN._charcounterpopoutnotecounter} {
right: 3px !important;
bottom: -8px !important;
font-size: 10px !important;
}
${BDFDB.dotCN._charcounterprofilenotecounter} {
right: 0 !important;
bottom: -10px !important;
font-size: 12px !important;
}
${BDFDB.dotCN.usernotetextarea}:not(:focus) ~ ${BDFDB.dotCN._charcountercounter} {
display: none;
}`;
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processChannelTextAreaContainer (e) {
let editorContainer = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ChannelEditorContainer"});
if (editorContainer && editorContainer.props.type && maxLenghts[editorContainer.props.type] && !editorContainer.props.disabled) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectCounter(e.returnvalue, e.returnvalue.props.children, editorContainer.props.type, BDFDB.dotCN.textarea, true);
}
}
processNote (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["TextAreaAutosize", "TextArea", "PlainTextArea"]});
if (index > -1) this.injectCounter(e.returnvalue, children, e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.usernotepopout) > -1 ? "popoutnote" : "profilenote", "textarea");
}
processChangeNickname (e) {
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "FormItem"});
if (formItem) {
let [children, index] = BDFDB.ReactUtils.findParent(formItem, {name: "TextInput"});
if (index > -1) this.injectCounter(formItem, children, "nick", BDFDB.dotCN.input);
}
}
processCustomStatusModal (e) {
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.emojiinputcontainer]]});
if (formItem) this.injectCounter(formItem, formItem.props.children, "customstatus", BDFDB.dotCN.input);
}
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
injectCounter (parent, children, type, refClass, parsing) {
if (!children) return;
parent.props.className = BDFDB.DOMUtils.formatClassName(parent.props.className, BDFDB.disCN._charcountercounteradded);
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CharCounter, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._charcountercounter, type && BDFDB.disCN[`_charcounter${typeMap[type] || type}counter`]),
refClass: refClass,
parsing: parsing,
max: maxLenghts[type],
onChange: instance => {
let node = BDFDB.ReactUtils.findDOMNode(instance);
let form = node && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, node);
if (form) {
let typing = form.querySelector(BDFDB.dotCN.typing);
if (typing) typing.style.setProperty("margin-right", `${BDFDB.DOMUtils.getWidth(node) + 10}px`);
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
const maxLenghts = {
normal: 2000,
edit: 2000,
form: 2000,
nick: 32,
customstatus: 128,
popoutnote: 256,
profilenote: 256
};
const typeMap = {
normal: "chat",
form: "upload"
};
return class CharCounter extends Plugin {
onLoad() {
this.patchedModules = {
after: {
ChannelTextAreaContainer: "render",
Note: "render",
ChangeNickname: "default",
CustomStatusModal: "render"
}
}
}));
}
}
})();
};
this.css = `
${BDFDB.dotCN._charcountercounteradded} {
position: relative !important;
}
${BDFDB.dotCN._charcountercounter} {
display: block;
position: absolute;
z-index: 1000;
pointer-events: none;
font-size: 15px;
}
${BDFDB.dotCN._charcounterchatcounter} {
right: 0;
bottom: -1.3em;
}
${BDFDB.dotCN._charcountereditcounter} {
right: 0;
bottom: -1.3em;
}
${BDFDB.dotCN._charcounteruploadcounter} {
right: 0;
bottom: -1.0em;
}
${BDFDB.dotCN._charcounternickcounter} {
right: 0 !important;
top: 0 !important;
}
${BDFDB.dotCN._charcountercustomstatuscounter} {
right: 0 !important;
top: -1.5em;
}
${BDFDB.dotCN._charcounterpopoutnotecounter} {
right: 3px !important;
bottom: -8px !important;
font-size: 10px !important;
}
${BDFDB.dotCN._charcounterprofilenotecounter} {
right: 0 !important;
bottom: -10px !important;
font-size: 12px !important;
}
${BDFDB.dotCN.usernotetextarea}:not(:focus) ~ ${BDFDB.dotCN._charcountercounter} {
display: none;
}
`;
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
module.exports = CharCounter;
processChannelTextAreaContainer (e) {
let editorContainer = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ChannelEditorContainer"});
if (editorContainer && editorContainer.props.type && maxLenghts[editorContainer.props.type] && !editorContainer.props.disabled) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectCounter(e.returnvalue, e.returnvalue.props.children, editorContainer.props.type, BDFDB.dotCN.textarea, true);
}
}
processNote (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["TextAreaAutosize", "TextArea", "PlainTextArea"]});
if (index > -1) this.injectCounter(e.returnvalue, children, e.instance.props.className && e.instance.props.className.indexOf(BDFDB.disCN.usernotepopout) > -1 ? "popoutnote" : "profilenote", "textarea");
}
processChangeNickname (e) {
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "FormItem"});
if (formItem) {
let [children, index] = BDFDB.ReactUtils.findParent(formItem, {name: "TextInput"});
if (index > -1) this.injectCounter(formItem, children, "nick", BDFDB.dotCN.input);
}
}
processCustomStatusModal (e) {
let formItem = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.emojiinputcontainer]]});
if (formItem) this.injectCounter(formItem, formItem.props.children, "customstatus", BDFDB.dotCN.input);
}
injectCounter (parent, children, type, refClass, parsing) {
if (!children) return;
parent.props.className = BDFDB.DOMUtils.formatClassName(parent.props.className, BDFDB.disCN._charcountercounteradded);
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CharCounter, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._charcountercounter, type && BDFDB.disCN[`_charcounter${typeMap[type] || type}counter`]),
refClass: refClass,
parsing: parsing,
max: maxLenghts[type],
onChange: instance => {
let node = BDFDB.ReactUtils.findDOMNode(instance);
let form = node && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, node);
if (form) {
let typing = form.querySelector(BDFDB.dotCN.typing);
if (typing) typing.style.setProperty("margin-right", `${BDFDB.DOMUtils.getWidth(node) + 10}px`);
}
}
}));
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,434 +1,392 @@
//META{"name":"CompleteTimestamps","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/CompleteTimestamps","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js"}*//
var CompleteTimestamps = (_ => {
var languages, currentMode;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class CompleteTimestamps {
getName () {return "CompleteTimestamps";}
getVersion () {return "1.4.8";}
getAuthor () {return "DevilBro";}
getDescription () {return "Replace all timestamps with complete timestamps.";}
constructor () {
this.changelog = {
"fixed":[["Compact","Fixed some issues with the timestamp in compact mode"]]
};
this.patchedModules = {
after: {
Message: "default",
MessageHeader: "default",
MessageContent: "type",
Embed: "render",
SystemMessage: "default"
}
};
}
initConstructor () {
this.defaults = {
settings: {
showInChat: {value:true, description:"Replace chat timestamp with complete timestamp"},
showInEmbed: {value:true, description:"Replace embed timestamp with complete timestamp"},
changeForChat: {value:true, description:"Change the time for the chat time tooltips"},
changeForEdit: {value:true, description:"Change the time for the edited time tooltips"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
timestampLang: {value:"$discord", description:"Timestamp Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: innerItems
}));
innerItems = [];
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in amounts) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: innerItems
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
module.exports = (_ => {
const config = {
"info": {
"name": "CompleteTimestamps",
"author": "DevilBro",
"version": "1.4.8",
"description": "Replace all timestamps with complete timestamps."
},
"changeLog": {
"fixed": {
"Compact": "Fixed some issues with the timestamp in compact mode"
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var languages, currentMode;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class CompleteTimestamps extends Plugin {
onLoad() {
this.defaults = {
settings: {
showInChat: {value:true, description:"Replace chat timestamp with complete timestamp"},
showInEmbed: {value:true, description:"Replace embed timestamp with complete timestamp"},
changeForChat: {value:true, description:"Change the time for the chat time tooltips"},
changeForEdit: {value:true, description:"Change the time for the edited time tooltips"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
timestampLang: {value:"$discord", description:"Timestamp Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
this.patchedModules = {
after: {
Message: "default",
MessageHeader: "default",
MessageContent: "type",
Embed: "render",
SystemMessage: "default"
}
};
}
onStart() {
languages = BDFDB.ObjectUtils.deepAssign({
own: {
name: "Own",
"name": "Own",
id: "own"
}
}, BDFDB.LanguageUtils.languages);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
this.forceUpdateAll();
BDFDB.DOMUtils.removeLocalStyle(this.name + "CompactCorrection");
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
currentMode = null;
this.forceUpdateAll();
}
}
processMessage (e) {
if (BDFDB.ObjectUtils.get(e, "instance.props.childrenHeader.type.type.displayName") == "MessageTimestamp" && settings.changeForChat) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: e.instance.props.childrenHeader.type});
if (index > -1) this.changeTimestamp(children, index, {child:false, tooltip:true});
}
}
processMessageHeader (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "MessageTimestamp"});
if (index > -1) {
this.changeTimestamp(children, index, {child:settings.showInChat, tooltip:settings.changeForChat});
this.setMaxWidth(children[index], e.instance.props.compact);
}
}
processMessageContent (e) {
if (e.instance.props.message.editedTimestamp && settings.changeForEdit) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SuffixEdited"});
if (index > -1) this.changeTimestamp(children, index, {child:false, tooltip:true});
}
}
processEmbed (e) {
if (e.instance.props.embed.timestamp && settings.showInEmbed) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.embedfootertext]]});
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i));
}
}
processSystemMessage (e) {
if (settings.showInChat) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.timestamp._i);
}
}
changeTimestamp (parent, index, change = {}) {
let type = parent[index].type && parent[index].type.type || parent[index].type;
if (typeof type != "function") return;
let stamp = type(parent[index].props), tooltipWrapper;
if (stamp.type.displayName == "Tooltip") tooltipWrapper = stamp;
else {
let [children, tooltipIndex] = BDFDB.ReactUtils.findParent(stamp, {name: "Tooltip"});
if (tooltipIndex > -1) tooltipWrapper = children[tooltipIndex];
}
if (tooltipWrapper) {
let timestamp = this.getTimestamp(languages[choices.timestampLang].id, parent[index].props.timestamp._i);
if (change.tooltip) {
tooltipWrapper.props.text = timestamp;
tooltipWrapper.props.delay = 0;
}
if (change.child && typeof tooltipWrapper.props.children == "function") {
tooltipWrapper.props.delay = 99999999999999999999;
let renderChildren = tooltipWrapper.props.children;
tooltipWrapper.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
if (BDFDB.ArrayUtils.is(renderedChildren.props.children)) renderedChildren.props.children[1] = timestamp;
else renderChildren.props.children = timestamp;
return renderedChildren;
};
}
}
parent[index] = stamp;
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
setMaxWidth (timestamp, compact) {
if (currentMode != compact) {
currentMode = compact;
if (timestamp.props.className && typeof timestamp.type == "string") {
let tempTimestamp = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN.messagecompact}"><${timestamp.type} class="${timestamp.props.className}" style="width: auto !important;">${this.getTimestamp(languages[choices.timestampLang].id, new Date(253402124399995))}</${timestamp.type}></div>`);
document.body.appendChild(tempTimestamp);
let width = BDFDB.DOMUtils.getRects(tempTimestamp.firstElementChild).width + 10;
tempTimestamp.remove();
BDFDB.DOMUtils.appendLocalStyle(this.name + "CompactCorrection", `
${BDFDB.dotCN.messagecompact + BDFDB.dotCN.messagewrapper} {
padding-left: ${44 + width}px;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagecontents} {
margin-left: -${44 + width}px;
padding-left: ${44 + width}px;
text-indent: calc(-${44 + width}px - -1rem);
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagetimestamp} {
width: ${width}px;
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
`);
}
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
currentMode = null;
this.forceUpdateAll();
}
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
processMessage (e) {
if (settings.changeForChat && BDFDB.ObjectUtils.get(e, "instance.props.childrenHeader.type.type.displayName") == "MessageTimestamp") {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: e.instance.props.childrenHeader.type});
if (index > -1) this.changeTimestamp(children, index, {child:false, tooltip:true});
}
}
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
})();
processMessageHeader (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "MessageTimestamp"});
if (index > -1) {
this.changeTimestamp(children, index, {child:settings.showInChat, tooltip:settings.changeForChat});
this.setMaxWidth(children[index], e.instance.props.compact);
}
}
processMessageContent (e) {
if (e.instance.props.message.editedTimestamp && settings.changeForEdit) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SuffixEdited"});
if (index > -1) this.changeTimestamp(children, index, {child:false, tooltip:true});
}
}
module.exports = CompleteTimestamps;
processEmbed (e) {
if (e.instance.props.embed.timestamp && settings.showInEmbed) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.embedfootertext]]});
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.splice(children[index].props.children.length - 1, 1, this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.embed.timestamp._i));
}
}
processSystemMessage (e) {
if (settings.showInChat) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "time"});
if (index > -1) children[index].props.children = this.getTimestamp(languages[choices.timestampLang].id, e.instance.props.timestamp._i);
}
}
changeTimestamp (parent, index, change = {}) {
let type = parent[index].type && parent[index].type.type || parent[index].type;
if (typeof type != "function") return;
let stamp = type(parent[index].props), tooltipWrapper;
if (stamp.type.displayName == "Tooltip") tooltipWrapper = stamp;
else {
let [children, tooltipIndex] = BDFDB.ReactUtils.findParent(stamp, {name: "Tooltip"});
if (tooltipIndex > -1) tooltipWrapper = children[tooltipIndex];
}
if (tooltipWrapper) {
let timestamp = this.getTimestamp(languages[choices.timestampLang].id, parent[index].props.timestamp._i);
if (change.tooltip) {
tooltipWrapper.props.text = timestamp;
tooltipWrapper.props.delay = 0;
}
if (change.child && typeof tooltipWrapper.props.children == "function") {
tooltipWrapper.props.delay = 99999999999999999999;
let renderChildren = tooltipWrapper.props.children;
tooltipWrapper.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
if (BDFDB.ArrayUtils.is(renderedChildren.props.children)) renderedChildren.props.children[1] = timestamp;
else renderChildren.props.children = timestamp;
return renderedChildren;
};
}
}
parent[index] = stamp;
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
setMaxWidth (timestamp, compact) {
if (currentMode != compact) {
currentMode = compact;
if (timestamp.props.className && typeof timestamp.type == "string") {
let tempTimestamp = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN.messagecompact}"><${timestamp.type} class="${timestamp.props.className}" style="width: auto !important;">${this.getTimestamp(languages[choices.timestampLang].id, new Date(253402124399995))}</${timestamp.type}></div>`);
document.body.appendChild(tempTimestamp);
let width = BDFDB.DOMUtils.getRects(tempTimestamp.firstElementChild).width + 10;
tempTimestamp.remove();
BDFDB.DOMUtils.appendLocalStyle(this.name + "CompactCorrection", `
${BDFDB.dotCN.messagecompact + BDFDB.dotCN.messagewrapper} {
padding-left: ${44 + width}px;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagecontents} {
margin-left: -${44 + width}px;
padding-left: ${44 + width}px;
text-indent: calc(-${44 + width}px - -1rem);
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCN.messagetimestamp} {
width: ${width}px;
}
`);
}
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,166 +1,145 @@
//META{"name":"CopyRawMessage","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/CopyRawMessage","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CopyRawMessage/CopyRawMessage.plugin.js"}*//
var CopyRawMessage = (_ => {
var settings = {};
module.exports = (_ => {
const config = {
"info": {
"name": "CopyRawMessage",
"author": "DevilBro",
"version": "1.1.1",
"description": "Adds a entry in the contextmenu when you right click a message that allows you to copy the raw contents of a message."
},
"changeLog": {
"improved": {
"Only copy selection": "Selecting a part of a message/embed and clicking copy raw will now only copy the selected part (including formating symbols like ~, _ and ` etc., can be disabled"
}
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {};
return class CopyRawMessage {
getName () {return "CopyRawMessage";}
return class CopyRawMessage extends Plugin {
onLoad() {
this.defaults = {
settings: {
copyOnlySelected: {value:true, description:"Only copy selected text of a message"}
}
};
}
onStart() {
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
getVersion () {return "1.1.1";}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a entry in the contextmenu when you right click a message that allows you to copy the raw contents of a message.";}
constructor () {
this.changelog = {
"improved":[["Only copy selection","Selecting a part of a message/embed and clicking copy raw will now only copy the selected part (including formating symbols like ~, _ and ` etc., can be disabled"]]
};
}
initConstructor () {
this.defaults = {
settings: {
copyOnlySelected: {value:true, description:"Only copy selected text of a message"}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
onMessageContextMenu (e) {
if (e.instance.props.message) {
let content = e.instance.props.message.content;
let messageString = [e.instance.props.message.content, BDFDB.ArrayUtils.is(e.instance.props.message.attachments) && e.instance.props.message.attachments.map(n => n.url)].flat(10).filter(n => n).join("\n");
let selectedText = settings.copyOnlySelected && document.getSelection().toString().trim();
if (selectedText) messageString = BDFDB.StringUtils.extractSelection(messageString, selectedText);
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedData = e.instance.props.message.embeds[embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1];
let embedString = embedData && [embedData.rawTitle, embedData.rawDescription, BDFDB.ArrayUtils.is(embedData.fields) && embedData.fields.map(n => [n.rawName, n.rawValue]), BDFDB.ObjectUtils.is(embedData.image) && embedData.image.url, BDFDB.ObjectUtils.is(embedData.footer) && embedData.footer.text].flat(10).filter(n => n).join("\n");
if (selectedText) embedString = BDFDB.StringUtils.extractSelection(embedString, selectedText);
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null;
let entries = [
messageString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-message"),
hint: hint && (_ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
}),
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:messageString});
}
}),
embedString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw Embed)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed"),
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:embedString});
}
})
].filter(n => n);
if (entries.length) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: entries
}));
}
}
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
onMessageContextMenu (e) {
if (e.instance.props.message) {
let content = e.instance.props.message.content;
let messageString = [e.instance.props.message.content, BDFDB.ArrayUtils.is(e.instance.props.message.attachments) && e.instance.props.message.attachments.map(n => n.url)].flat(10).filter(n => n).join("\n");
let selectedText = settings.copyOnlySelected && document.getSelection().toString().trim();
if (selectedText) messageString = BDFDB.StringUtils.extractSelection(messageString, selectedText);
let embed = BDFDB.DOMUtils.getParent(BDFDB.dotCN.embedwrapper, e.instance.props.target);
let embedData = e.instance.props.message.embeds[embed ? Array.from(embed.parentElement.querySelectorAll(BDFDB.dotCN.embedwrapper)).indexOf(embed) : -1];
let embedString = embedData && [embedData.rawTitle, embedData.rawDescription, BDFDB.ArrayUtils.is(embedData.fields) && embedData.fields.map(n => [n.rawName, n.rawValue]), BDFDB.ObjectUtils.is(embedData.image) && embedData.image.url, BDFDB.ObjectUtils.is(embedData.footer) && embedData.footer.text].flat(10).filter(n => n).join("\n");
if (selectedText) embedString = BDFDB.StringUtils.extractSelection(embedString, selectedText);
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("Copy_Raw") : null;
let entries = [
messageString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
onMessageOptionContextMenu (e) {
if (e.instance.props.message && e.instance.props.message.content) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"});
children.splice(index + 1, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-message"),
hint: hint && (_ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
icon: _ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.menuicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
});
}),
},
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:messageString});
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});
}
}),
embedString && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw Embed)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-embed"),
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:embedString});
}
})
].filter(n => n);
if (entries.length) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: entries
}));
}
}
}
onMessageOptionContextMenu (e) {
if (e.instance.props.message && e.instance.props.message.content) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"});
children.splice(index + 1, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "copy-message"),
icon: _ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.menuicon,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT
});
},
action: _ => {
BDFDB.LibraryRequires.electron.clipboard.write({text:e.instance.props.message.content});
}
}));
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
}
}
})();
module.exports = CopyRawMessage;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,453 +1,410 @@
//META{"name":"CreationDate","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/CreationDate","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CreationDate/CreationDate.plugin.js"}*//
var CreationDate = (_ => {
var languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class CreationDate {
getName () {return "CreationDate";}
getVersion () {return "1.3.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays the Creation Date of an Account in the UserPopout and UserModal.";}
constructor () {
this.changelog = {
"added":[["Settings","Added upper limit for $daysago, option to hide the default timestamp text and new year short form placeholder"]]
};
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
}
initConstructor () {
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Created on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
creationDateLang: {value:"$discord", description:"Creation Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: innerItems
}));
innerItems = [];
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in amounts) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: innerItems
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
dividertop: true,
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
});
})
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
module.exports = (_ => {
const config = {
"info": {
"name": "CreationDate",
"author": "DevilBro",
"version": "1.3.9",
"description": "Displays the Creation Date of an Account in the UserPopout and UserModal."
},
"changeLog": {
"added": {
"Settings": "Added upper limit for $daysago, option to hide the default timestamp text and new year short form placeholder"
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class CreationDate extends Plugin {
onLoad() {
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Created on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
creationDateLang: {value:"$discord", description:"Creation Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
}
onStart() {
languages = BDFDB.ObjectUtils.deepAssign({
own: {
name: "Own",
"name": "Own",
id: "own"
}
}, BDFDB.LanguageUtils.languages);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(children, 2, e.instance.props.user);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(children, 1, children[index].props.user);
return renderedChildren;
};
}
}
injectDate (children, index, user) {
let timestamp = this.getTimestamp(languages[choices.creationDateLang].id, user.createdAt);
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.createdat_text.replace("{{time}}", timestamp) : timestamp
}));
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
createdat_text: "Izrađen {{time}}"
};
case "da": //danish
return {
createdat_text: "Oprettet den {{time}}"
};
case "de": //german
return {
createdat_text: "Erstellt am {{time}}"
};
case "es": //spanish
return {
createdat_text: "Creado el {{time}}"
};
case "fr": //french
return {
createdat_text: "Créé le {{time}}"
};
case "it": //italian
return {
createdat_text: "Creato il {{time}}"
};
case "nl": //dutch
return {
createdat_text: "Gemaakt op {{time}}"
};
case "no": //norwegian
return {
createdat_text: "Opprettet på {{time}}"
};
case "pl": //polish
return {
createdat_text: "Utworzono {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
createdat_text: "Criado em {{time}}"
};
case "fi": //finnish
return {
createdat_text: "Luotu {{time}}"
};
case "sv": //swedish
return {
createdat_text: "Skapat den {{time}}"
};
case "tr": //turkish
return {
createdat_text: "Oluşturma tarihi {{time}}"
};
case "cs": //czech
return {
createdat_text: "Vytvořeno dne {{time}}"
};
case "bg": //bulgarian
return {
createdat_text: "Създадена на {{time}}"
};
case "ru": //russian
return {
createdat_text: "Создан {{time}}"
};
case "uk": //ukrainian
return {
createdat_text: "Створено {{time}}"
};
case "ja": //japanese
return {
createdat_text: "{{time}} に登録"
};
case "zh-TW": //chinese (traditional)
return {
createdat_text: "創建於 {{time}}"
};
case "ko": //korean
return {
createdat_text: "{{time}} 생성 일"
};
default: //default: english
return {
createdat_text: "Created on {{time}}"
};
onStop() {
this.forceUpdateAll();
}
}
}
})();
module.exports = CreationDate;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(children, 2, e.instance.props.user);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(children, 1, children[index].props.user);
return renderedChildren;
};
}
}
injectDate (children, index, user) {
let timestamp = this.getTimestamp(languages[choices.creationDateLang].id, user.createdAt);
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._creationdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.createdat_text.replace("{{time}}", timestamp) : timestamp
}));
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
createdat_text: "Izrađen {{time}}"
};
case "da": //danish
return {
createdat_text: "Oprettet den {{time}}"
};
case "de": //german
return {
createdat_text: "Erstellt am {{time}}"
};
case "es": //spanish
return {
createdat_text: "Creado el {{time}}"
};
case "fr": //french
return {
createdat_text: "Créé le {{time}}"
};
case "it": //italian
return {
createdat_text: "Creato il {{time}}"
};
case "nl": //dutch
return {
createdat_text: "Gemaakt op {{time}}"
};
case "no": //norwegian
return {
createdat_text: "Opprettet på {{time}}"
};
case "pl": //polish
return {
createdat_text: "Utworzono {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
createdat_text: "Criado em {{time}}"
};
case "fi": //finnish
return {
createdat_text: "Luotu {{time}}"
};
case "sv": //swedish
return {
createdat_text: "Skapat den {{time}}"
};
case "tr": //turkish
return {
createdat_text: "Oluşturma tarihi {{time}}"
};
case "cs": //czech
return {
createdat_text: "Vytvořeno dne {{time}}"
};
case "bg": //bulgarian
return {
createdat_text: "Създадена на {{time}}"
};
case "ru": //russian
return {
createdat_text: "Создан {{time}}"
};
case "uk": //ukrainian
return {
createdat_text: "Створено {{time}}"
};
case "ja": //japanese
return {
createdat_text: "{{time}} に登録"
};
case "zh-TW": //chinese (traditional)
return {
createdat_text: "創建於 {{time}}"
};
case "ko": //korean
return {
createdat_text: "{{time}} 생성 일"
};
default: //default: english
return {
createdat_text: "Created on {{time}}"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,383 +1,348 @@
//META{"name":"CustomQuoter","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/CustomQuoter","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CustomQuoter/CustomQuoter.plugin.js"}*//
var CustomQuoter = (_ => {
var _this;
var settings = {}, formats = {}, format = null;
const PreviewMessageComponent = class PreviewMessage extends BdApi.React.Component {
render() {
let spoofChannel = new BDFDB.DiscordObjects.Channel({
id: "126223823845647771",
guild_id: "850725684241078788",
name: "Test Channel"
});
let spoofQuotedMessage = new BDFDB.DiscordObjects.Message({
id: "562432230424221059",
author: new BDFDB.DiscordObjects.User({
id: "230422432565221049",
username: "Quoted User"
}),
channel_id: spoofChannel.id,
content: "This is a test message\nto showcase what the quote would look like"
});
let spoofMessage = new BDFDB.DiscordObjects.Message({
author: new BDFDB.DiscordObjects.User({
id: "222242304256531049",
username: "Test User"
}),
channel_id: spoofChannel.id,
content: _this.parseQuote(spoofQuotedMessage, spoofChannel, this.props.format)
});
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessageGroup, {
className: BDFDB.disCNS.message + BDFDB.disCN.messagecozymessage,
message: spoofMessage,
channel: spoofChannel
});
module.exports = (_ => {
const config = {
"info": {
"name": "CustomQuoter",
"author": "DevilBro",
"version": "1.1.5",
"description": "Let's you customize the output of the native quote feature of Discord."
}
};
return class CustomQuoter {
getName () {return "CustomQuoter";}
getVersion () {return "1.1.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Let's you customize the output of the native quote feature of Discord.";}
initConstructor () {
_this = this;
this.defaults = {
settings: {
quoteOnlySelected: {value:true, description:"Only insert selected text in a quoted message"},
ignoreMentionInDM: {value:true, description:"Do not add a mention in DM channels"},
forceZeros: {value:false, description:"Force leading Zeros"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
formats = Object.assign({"Standard": "$quote $mention"}, BDFDB.DataUtils.load(this, "formats"));
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
}
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: innerItems
}));
innerItems = [];
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom8,
align: BDFDB.LibraryComponents.Flex.Align.END,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: "Name:",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
className: "input-newquote input-name",
value: "",
placeholder: "Formatname"
})
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: "Quote:",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
className: "input-newquote input-quote",
value: "",
placeholder: "Quote"
})
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
style: {marginBottom: 1},
onClick: _ => {
for (let input of settingsPanel.querySelectorAll(".input-newquote " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new quote.", {type:"danger"});
let key = settingsPanel.querySelector(".input-name " + BDFDB.dotCN.input).value.trim();
let quote = settingsPanel.querySelector(".input-quote " + BDFDB.dotCN.input).value.trim();
if (formats[key]) return BDFDB.NotificationUtils.toast("A quote with the choosen name already exists. Please choose another name.", {type:"danger"});
else {
formats[key] = quote;
BDFDB.DataUtils.save(formats, this, "formats");
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
}
},
children: BDFDB.LanguageUtils.LanguageStrings.ADD
})
]
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom20
}));
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Card, {
cardId: key,
noRemove: key == "Standard",
onRemove: _ => {
delete formats[key];
BDFDB.DataUtils.save(formats, this, "formats");
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: key + ":",
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key: "PREVIEW_MESSAGE_" + key.replace(/\s/g, "_")}));
}
}),
BDFDB.ReactUtils.createElement(PreviewMessageComponent, {
key: "PREVIEW_MESSAGE_" + key.replace(/\s/g, "_"),
format: key
})
]
})
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Formats",
collapseStates: collapseStates,
children: innerItems
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$quote will be replaced with the quoted message content",
"$rawQuote will be replaced with the raw quoted message content",
"$mention will be replaced with a mention of the message author",
"$link will be replaced with a discord direct link pointing to the message",
"$authorId will be replaced with the ID of the message author",
"$authorName will be replaced with the nickname or username of the message author",
"$authorAccount will be replaced with the accountname of the message author (username#discriminator)",
"$channel will be replaced with a mention of the channel (ignored for DMs)",
"$channelId will be replaced with the ID of the channel",
"$channelName will be replaced with the Name of the channel",
"$serverId will be replaced with the ID of the server",
"$serverName will be replaced with the name of the server",
"$hour will be replaced with the quote hour",
"$minute will be replaced with the quote minutes",
"$second will be replaced with the quote seconds",
"$msecond will be replaced with the quote milliseconds",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the quote year",
"$month will be replaced with the quote month",
"$day will be replaced with the quote day",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language"
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var _this;
var settings = {}, formats = {}, format = null;
const PreviewMessageComponent = class PreviewMessage extends BdApi.React.Component {
render() {
let spoofChannel = new BDFDB.DiscordObjects.Channel({
id: "126223823845647771",
guild_id: "850725684241078788",
"name": "Test Channel"
});
let spoofQuotedMessage = new BDFDB.DiscordObjects.Message({
id: "562432230424221059",
author: new BDFDB.DiscordObjects.User({
id: "230422432565221049",
username: "Quoted User"
}),
channel_id: spoofChannel.id,
content: "This is a test message\nto showcase what the quote would look like"
});
let spoofMessage = new BDFDB.DiscordObjects.Message({
author: new BDFDB.DiscordObjects.User({
id: "222242304256531049",
username: "Test User"
}),
channel_id: spoofChannel.id,
content: _this.parseQuote(spoofQuotedMessage, spoofChannel, this.props.format)
});
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MessageGroup, {
className: BDFDB.disCNS.message + BDFDB.disCN.messagecozymessage,
message: spoofMessage,
channel: spoofChannel
});
}
};
return class CustomQuoter extends Plugin {
onLoad() {
_this = this;
this.defaults = {
settings: {
quoteOnlySelected: {value:true, description:"Only insert selected text in a quoted message"},
ignoreMentionInDM: {value:true, description:"Do not add a mention in DM channels"},
forceZeros: {value:false, description:"Force leading Zeros"}
}
};
}
onStart() {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.QuoteUtils, "createQuotedText", {instead: e => {
return this.parseQuote(e.methodArguments[0], e.methodArguments[1]);
}});
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
onStop() {}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) {
let item = null, action = (choice, copy) => {
format = choice;
if (copy || !BDFDB.LibraryModules.QuoteUtils.canQuote(e.instance.props.message, e.instance.props.channel)) {
BDFDB.LibraryRequires.electron.clipboard.write({text:this.parseQuote(e.instance.props.message, e.instance.props.channel)});
BDFDB.NotificationUtils.toast("Quote has been copied to clipboard.", {type:"success"});
}
else BDFDB.LibraryModules.MessageManageUtils.quoteMessage(e.instance.props.channel, e.instance.props.message);
format = null;
};
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "quote"});
if (index > -1) {
item = children[index];
item.props.action = event => {action(null, event.shiftKey);};
}
else {
item = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.QUOTE,
id: "quote",
action: _ => {action(null, event.shiftKey);}
});
let [unreadChildren, unreadIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"});
unreadChildren.splice(unreadIndex > -1 ? unreadIndex - 1 : unreadChildren.length, 0, item);
}
let addedFormats = BDFDB.ObjectUtils.exclude(formats, "Standard");
if (!BDFDB.ObjectUtils.isEmpty(addedFormats)) item.props.children = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: Object.keys(addedFormats).map(key => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: key,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "added-quote", key),
action: event => {action(key, event.shiftKey);}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
}
}))
});
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Formats",
collapseStates: collapseStates,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom8,
align: BDFDB.LibraryComponents.Flex.Align.END,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: "Name:",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
className: "input-newquote input-name",
value: "",
placeholder: "Formatname"
})
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: "Quote:",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
className: "input-newquote input-quote",
value: "",
placeholder: "Quote"
})
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
style: {marginBottom: 1},
onClick: _ => {
for (let input of settingsPanel.querySelectorAll(".input-newquote " + BDFDB.dotCN.input)) if (!input.value || input.value.length == 0 || input.value.trim().length == 0) return BDFDB.NotificationUtils.toast("Fill out all fields to add a new quote.", {type:"danger"});
let key = settingsPanel.querySelector(".input-name " + BDFDB.dotCN.input).value.trim();
let quote = settingsPanel.querySelector(".input-quote " + BDFDB.dotCN.input).value.trim();
if (formats[key]) return BDFDB.NotificationUtils.toast("A quote with the choosen name already exists. Please choose another name.", {type:"danger"});
else {
formats[key] = quote;
BDFDB.DataUtils.save(formats, this, "formats");
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
}
},
children: BDFDB.LanguageUtils.LanguageStrings.ADD
})
]
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom20
})
].concat(Object.keys(formats).map(key = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Card, {
cardId: key,
noRemove: key == "Standard",
onRemove: _ => {
delete formats[key];
BDFDB.DataUtils.save(formats, this, "formats");
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: key + ":",
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key: "PREVIEW_MESSAGE_" + key.replace(/\s/g, "_")}));
}
}),
BDFDB.ReactUtils.createElement(PreviewMessageComponent, {
key: "PREVIEW_MESSAGE_" + key.replace(/\s/g, "_"),
format: key
})
]
})
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$quote will be replaced with the quoted message content",
"$rawQuote will be replaced with the raw quoted message content",
"$mention will be replaced with a mention of the message author",
"$link will be replaced with a discord direct link pointing to the message",
"$authorId will be replaced with the ID of the message author",
"$authorName will be replaced with the nickname or username of the message author",
"$authorAccount will be replaced with the accountname of the message author (username#discriminator)",
"$channel will be replaced with a mention of the channel (ignored for DMs)",
"$channelId will be replaced with the ID of the channel",
"$channelName will be replaced with the Name of the channel",
"$serverId will be replaced with the ID of the server",
"$serverName will be replaced with the name of the server",
"$hour will be replaced with the quote hour",
"$minute will be replaced with the quote minutes",
"$second will be replaced with the quote seconds",
"$msecond will be replaced with the quote milliseconds",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the quote year",
"$month will be replaced with the quote month",
"$day will be replaced with the quote day",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language"
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
}
parseQuote (message, channel, choice = format) {
let languageId = BDFDB.LanguageUtils.getLanguage().id;
let quoteFormat = formats[choice] || formats.Standard || "";
let guild = channel.guild_id ? (BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id) || {id: channel.guild_id, name: "Test Server"}) : {id: BDFDB.DiscordConstants.ME, name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES};
let member = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, message.author.id);
let timestamp = new Date(message.editedTimestamp || message.timestamp);
let hour = timestamp.getHours(), minute = timestamp.getMinutes(), second = timestamp.getSeconds(), msecond = timestamp.getMilliseconds(), day = timestamp.getDate(), month = timestamp.getMonth()+1, timemode = "";
if (quoteFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
let content = message.content;
let selectedText = settings.quoteOnlySelected && document.getSelection().toString().trim();
if (selectedText) content = BDFDB.StringUtils.extractSelection(content, selectedText);
if (content) {
content = content.replace(/(@everyone|@here)/g, "`$1`").replace(/``(@everyone|@here)``/g, "`$1`");
content = content.replace(/<@[!&]{0,1}([0-9]{10,})>/g, (string, match) => {
let user = BDFDB.LibraryModules.UserStore.getUser(match);
if (user) {
let userMember = channel.guild_id && BDFDB.LibraryModules.MemberStore.getMember(guild.id, match);
return `\`@${userMember && userMember.nick || user.username}\``;
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
formats = Object.assign({"Standard": "$quote $mention"}, BDFDB.DataUtils.load(this, "formats"));
}
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.channel) {
let item = null, action = (choice, copy) => {
format = choice;
if (copy || !BDFDB.LibraryModules.QuoteUtils.canQuote(e.instance.props.message, e.instance.props.channel)) {
BDFDB.LibraryRequires.electron.clipboard.write({text:this.parseQuote(e.instance.props.message, e.instance.props.channel)});
BDFDB.NotificationUtils.toast("Quote has been copied to clipboard.", {type:"success"});
}
else BDFDB.LibraryModules.MessageManageUtils.quoteMessage(e.instance.props.channel, e.instance.props.message);
format = null;
};
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "quote"});
if (index > -1) {
item = children[index];
item.props.action = event => {action(null, event.shiftKey);};
}
else if (channel.guild_id && guild.roles[match] && guild.roles[match].name) return `\`${guild.roles[match].name.indexOf("@") == 0 ? "" : "@"}${guild.roles[match].name}\``;
return string;
});
else {
item = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.QUOTE,
id: "quote",
action: _ => {action(null, event.shiftKey);}
});
let [unreadChildren, unreadIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "mark-unread"});
unreadChildren.splice(unreadIndex > -1 ? unreadIndex - 1 : unreadChildren.length, 0, item);
}
let addedFormats = BDFDB.ObjectUtils.exclude(formats, "Standard");
if (!BDFDB.ObjectUtils.isEmpty(addedFormats)) item.props.children = BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: Object.keys(addedFormats).map(key => BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: key,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "added-quote", key),
action: event => {action(key, event.shiftKey);}
}))
});
}
}
let unquotedLines = content.split("\n").filter(line => !line.startsWith("> "));
let quotedLines = unquotedLines.slice(unquotedLines.findIndex(line => line.trim().length > 0)).map(line => "> " + line + "\n").join("");
return BDFDB.StringUtils.insertNRST(quoteFormat)
.replace("$mention", settings.ignoreMentionInDM && channel.isDM() ? "" : `<@!${message.author.id}>`)
.replace("$link", `<https://discordapp.com/channels/${guild.id}/${channel.id}/${message.id}>`)
.replace("$authorName", member && member.nick || message.author.username || "")
.replace("$authorAccount", `${message.author.username}#${message.author.discriminator}`)
.replace("$authorId", message.author.id || "")
.replace("$channelName", channel.name || "")
.replace("$channelId", channel.id || "")
.replace("$channel", channel.isDM() ? "" : `<#${channel.id}>`)
.replace("$serverId", guild.id || "")
.replace("$serverName", guild.name || "")
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace("$minute", minute < 10 ? "0" + minute : minute)
.replace("$second", second < 10 ? "0" + second : second)
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace("$timemode", timemode)
.replace("$weekdayL", timestamp.toLocaleDateString(languageId, {weekday: "long"}))
.replace("$weekdayS", timestamp.toLocaleDateString(languageId, {weekday: "short"}))
.replace("$monthnameL", timestamp.toLocaleDateString(languageId, {month: "long"}))
.replace("$monthnameS", timestamp.toLocaleDateString(languageId, {month: "short"}))
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
.replace("$year", timestamp.getFullYear())
.replace("$quote", quotedLines || "")
.replace("$rawQuote", unquotedLines.join("\n") || "")
.replace(/\$/g, "$$$$");
}
addLeadingZeros (timestring) {
let charArray = timestring.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
parseQuote (message, channel, choice = format) {
let languageId = BDFDB.LanguageUtils.getLanguage().id;
let quoteFormat = formats[choice] || formats.Standard || "";
let guild = channel.guild_id ? (BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id) || {id: channel.guild_id, name: "Test Server"}) : {id: BDFDB.DiscordConstants.ME, name: BDFDB.LanguageUtils.LanguageStrings.DIRECT_MESSAGES};
let member = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, message.author.id);
let timestamp = new Date(message.editedTimestamp || message.timestamp);
let hour = timestamp.getHours(), minute = timestamp.getMinutes(), second = timestamp.getSeconds(), msecond = timestamp.getMilliseconds(), day = timestamp.getDate(), month = timestamp.getMonth()+1, timemode = "";
if (quoteFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
let content = message.content;
let selectedText = settings.quoteOnlySelected && document.getSelection().toString().trim();
if (selectedText) content = BDFDB.StringUtils.extractSelection(content, selectedText);
if (content) {
content = content.replace(/(@everyone|@here)/g, "`$1`").replace(/``(@everyone|@here)``/g, "`$1`");
content = content.replace(/<@[!&]{0,1}([0-9]{10,})>/g, (string, match) => {
let user = BDFDB.LibraryModules.UserStore.getUser(match);
if (user) {
let userMember = channel.guild_id && BDFDB.LibraryModules.MemberStore.getMember(guild.id, match);
return `\`@${userMember && userMember.nick || user.username}\``;
}
else if (channel.guild_id && guild.roles[match] && guild.roles[match].name) return `\`${guild.roles[match].name.indexOf("@") == 0 ? "" : "@"}${guild.roles[match].name}\``;
return string;
});
}
let unquotedLines = content.split("\n").filter(line => !line.startsWith("> "));
let quotedLines = unquotedLines.slice(unquotedLines.findIndex(line => line.trim().length > 0)).map(line => "> " + line + "\n").join("");
return BDFDB.StringUtils.insertNRST(quoteFormat)
.replace("$mention", settings.ignoreMentionInDM && channel.isDM() ? "" : `<@!${message.author.id}>`)
.replace("$link", `<https://discordapp.com/channels/${guild.id}/${channel.id}/${message.id}>`)
.replace("$authorName", member && member.nick || message.author.username || "")
.replace("$authorAccount", `${message.author.username}#${message.author.discriminator}`)
.replace("$authorId", message.author.id || "")
.replace("$channelName", channel.name || "")
.replace("$channelId", channel.id || "")
.replace("$channel", channel.isDM() ? "" : `<#${channel.id}>`)
.replace("$serverId", guild.id || "")
.replace("$serverName", guild.name || "")
.replace("$hour", settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace("$minute", minute < 10 ? "0" + minute : minute)
.replace("$second", second < 10 ? "0" + second : second)
.replace("$msecond", settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace("$timemode", timemode)
.replace("$weekdayL", timestamp.toLocaleDateString(languageId, {weekday: "long"}))
.replace("$weekdayS", timestamp.toLocaleDateString(languageId, {weekday: "short"}))
.replace("$monthnameL", timestamp.toLocaleDateString(languageId, {month: "long"}))
.replace("$monthnameS", timestamp.toLocaleDateString(languageId, {month: "short"}))
.replace("$day", settings.forceZeros && day < 10 ? "0" + day : day)
.replace("$month", settings.forceZeros && month < 10 ? "0" + month : month)
.replace("$year", timestamp.getFullYear())
.replace("$quote", quotedLines || "")
.replace("$rawQuote", unquotedLines.join("\n") || "")
.replace(/\$/g, "$$$$");
}
return charArray.join("");
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
formats = Object.assign({"Standard": "$quote $mention"}, BDFDB.DataUtils.load(this, "formats"));
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
})();
addLeadingZeros (timestring) {
let charArray = timestring.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
module.exports = CustomQuoter;
return charArray.join("");
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,125 +1,79 @@
//META{"name":"DisplayLargeMessages","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/DisplayLargeMessages","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/DisplayLargeMessages/DisplayLargeMessages.plugin.js"}*//
var DisplayLargeMessages = (_ => {
var encodedMessages, requestedMessages, pendingRequests, oldMessages, updateTimeout;
var settings = {}, amounts = {};
return class DisplayLargeMessages {
getName () {return "DisplayLargeMessages";}
getVersion () {return "1.0.6";}
getAuthor () {return "DevilBro";}
getDescription () {return "Injects the contents of large messages that were sent by discord via 'message.txt'.";}
constructor () {
this.changelog = {
"fixed":[["Message Update","Fixed for yet another message update provided by our best friend discord"]]
};
this.patchedModules = {
after: {
Messages: "type",
Attachment: "default"
}
};
}
initConstructor () {
encodedMessages = {};
requestedMessages = [];
pendingRequests = [];
oldMessages = {};
this.css = `
${BDFDB.dotCN._displaylargemessagesinjectbutton} {
color: var(--interactive-normal);
cursor: pointer;
margin-left: 4px;
}
${BDFDB.dotCN._displaylargemessagesinjectbutton}:hover {
color: var(--interactive-hover);
}
`;
this.defaults = {
settings: {
onDemand: {value:false, description:"Inject the content of 'message.txt' on demand instead of automatically"}
},
amounts: {
maxFileSize: {value:10, min:0, description:"Max Filesize a fill will be read automatically", note: "in KB / 0 = inject all / ignored in On-Demand"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: _ => {
if (key == "onDemand") BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
}
}));
for (let key in amounts) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
disabled: key == "maxFileSize" && settings.onDemand,
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
module.exports = (_ => {
const config = {
"info": {
"name": "DisplayLargeMessages",
"author": "DevilBro",
"version": "1.0.6",
"description": "Injects the contents of large messages that were sent by discord via 'message.txt'."
},
"changelog": {
"fixed": {
"Message Update": "Fixed for yet another message update provided by our best friend discord"
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var encodedMessages, requestedMessages, pendingRequests, oldMessages, updateTimeout;
var settings = {}, amounts = {};
return class DisplayLargeMessages extends Plugin {
onLoad() {
this.defaults = {
settings: {
onDemand: {value:false, description:"Inject the content of 'message.txt' on demand instead of automatically"}
},
amounts: {
maxFileSize: {value:10, min:0, description:"Max Filesize a fill will be read automatically", note: "in KB / 0 = inject all / ignored in On-Demand"}
}
};
this.patchedModules = {
after: {
Messages: "type",
Attachment: "default"
}
};
this.css = `
${BDFDB.dotCN._displaylargemessagesinjectbutton} {
color: var(--interactive-normal);
cursor: pointer;
margin-left: 4px;
}
${BDFDB.dotCN._displaylargemessagesinjectbutton}:hover {
color: var(--interactive-hover);
}
`;
}
onStart() {
encodedMessages = {};
requestedMessages = [];
pendingRequests = [];
oldMessages = {};
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.MessageUtils, "startEditMessage", {before: e => {
let encodedContent = encodedMessages[e.methodArguments[1]];
@ -135,246 +89,268 @@ var DisplayLargeMessages = (_ => {
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
encodedMessages = {};
requestedMessages = [];
pendingRequests = [];
onStop() {
this.forceUpdateAll();
}
}
onMessageContextMenu (e) {
if (e.instance.props.message && !requestedMessages.includes(e.instance.props.message.id)) {
let encodedContent = encodedMessages[e.instance.props.message.id];
if (encodedContent) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_uninjectattchment_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "uninject-attachment"),
action: _ => {
delete encodedMessages[e.instance.props.message.id];
BDFDB.MessageUtils.rerenderAll(true);
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: _ => {
if (key == "onDemand") BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
}
}));
for (let key in amounts) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
disabled: key == "maxFileSize" && settings.onDemand,
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
encodedMessages = {};
requestedMessages = [];
pendingRequests = [];
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
onMessageContextMenu (e) {
if (e.instance.props.message && !requestedMessages.includes(e.instance.props.message.id)) {
let encodedContent = encodedMessages[e.instance.props.message.id];
if (encodedContent) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : 0, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_uninjectattchment_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "uninject-attachment"),
action: _ => {
delete encodedMessages[e.instance.props.message.id];
BDFDB.MessageUtils.rerenderAll(true);
}
})
}));
}
}
}
processMessages (e) {
e.returnvalue.props.children.props.channelStream = [].concat(e.returnvalue.props.children.props.channelStream);
for (let i in e.returnvalue.props.children.props.channelStream) {
let message = e.returnvalue.props.children.props.channelStream[i].content;
if (message) {
if (BDFDB.ArrayUtils.is(message.attachments)) this.checkMessage(e.instance, e.returnvalue.props.children.props.channelStream[i], message);
else if (BDFDB.ArrayUtils.is(message)) for (let j in message) {
let childMessage = message[j].content;
if (childMessage && BDFDB.ArrayUtils.is(childMessage.attachments)) this.checkMessage(e.instance, message[j], childMessage);
}
}
}
}
checkMessage (instance, stream, message) {
let encodedContent = encodedMessages[message.id];
if (encodedContent != null) {
if (message.content.indexOf(encodedContent.attachment) == -1) {
stream.content.content = (message.content && (message.content + "\n\n") || "") + encodedContent.attachment;
stream.content.attachments = message.attachments.filter(n => n.filename != "message.txt");
}
}
else if (oldMessages[message.id] && Object.keys(message).some(key => !BDFDB.equals(oldMessages[message.id][key], message[key]))) {
stream.content.content = oldMessages[message.id].content;
stream.content.attachments = oldMessages[message.id].attachments;
delete oldMessages[message.id];
}
else if (!settings.onDemand && !requestedMessages.includes(message.id)) for (let attachment of message.attachments) {
if (attachment.filename == "message.txt" && (!amounts.maxFileSize || (amounts.maxFileSize >= attachment.size/1024))) {
requestedMessages.push(message.id);
BDFDB.LibraryRequires.request(attachment.url, (error, response, body) => {
encodedMessages[message.id] = {
content: message.content || "",
attachment: body || ""
};
BDFDB.TimeUtils.clear(updateTimeout);
updateTimeout = BDFDB.TimeUtils.timeout(_ => {BDFDB.ReactUtils.forceUpdate(instance);}, 1000);
});
}
}
}
processAttachment (e) {
if (e.instance.props.filename == "message.txt" && (settings.onDemand || amounts.maxFileSize && (amounts.maxFileSize < e.instance.props.size/1024))) {
e.returnvalue.props.children.splice(2, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: this.labels.button_injectattchment_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
rel: "noreferrer noopener",
target: "_blank",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN._displaylargemessagesinjectbutton,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT,
width: 20,
height: 20
}),
onClick: event => {
BDFDB.ListenerUtils.stopEvent(event);
let target = event.target;
let message = BDFDB.ReactUtils.findValue(target, "message", {up: true});
if (message) {
pendingRequests.push(message.id);
BDFDB.LibraryRequires.request(e.instance.props.url, (error, response, body) => {
BDFDB.ArrayUtils.remove(pendingRequests, message.id, true);
oldMessages[message.id] = new BDFDB.DiscordObjects.Message(message);
encodedMessages[message.id] = {
content: message.content || "",
attachment: body || ""
};
BDFDB.MessageUtils.rerenderAll(true);
});
}
}
})
}));
}
}
}
processMessages (e) {
e.returnvalue.props.children.props.channelStream = [].concat(e.returnvalue.props.children.props.channelStream);
for (let i in e.returnvalue.props.children.props.channelStream) {
let message = e.returnvalue.props.children.props.channelStream[i].content;
if (message) {
if (BDFDB.ArrayUtils.is(message.attachments)) this.checkMessage(e.instance, e.returnvalue.props.children.props.channelStream[i], message);
else if (BDFDB.ArrayUtils.is(message)) for (let j in message) {
let childMessage = message[j].content;
if (childMessage && BDFDB.ArrayUtils.is(childMessage.attachments)) this.checkMessage(e.instance, message[j], childMessage);
}
}
}
}
checkMessage (instance, stream, message) {
let encodedContent = encodedMessages[message.id];
if (encodedContent != null) {
if (message.content.indexOf(encodedContent.attachment) == -1) {
stream.content.content = (message.content && (message.content + "\n\n") || "") + encodedContent.attachment;
stream.content.attachments = message.attachments.filter(n => n.filename != "message.txt");
}
}
else if (oldMessages[message.id] && Object.keys(message).some(key => !BDFDB.equals(oldMessages[message.id][key], message[key]))) {
stream.content.content = oldMessages[message.id].content;
stream.content.attachments = oldMessages[message.id].attachments;
delete oldMessages[message.id];
}
else if (!settings.onDemand && !requestedMessages.includes(message.id)) for (let attachment of message.attachments) {
if (attachment.filename == "message.txt" && (!amounts.maxFileSize || (amounts.maxFileSize >= attachment.size/1024))) {
requestedMessages.push(message.id);
BDFDB.LibraryRequires.request(attachment.url, (error, response, body) => {
encodedMessages[message.id] = {
content: message.content || "",
attachment: body || ""
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
context_uninjectattchment_text: "Uklonite učitani sadržaj poruke",
button_injectattchment_text: "Učitajte sadržaj poruke"
};
case "da": //danish
return {
context_uninjectattchment_text: "Fjern indlæst meddelelsesindhold",
button_injectattchment_text: "Indlæs meddelelsesindhold"
};
case "de": //german
return {
context_uninjectattchment_text: "Geladenen Nachrichteninhalt entfernen",
button_injectattchment_text: "Nachrichteninhalt laden"
};
case "es": //spanish
return {
context_uninjectattchment_text: "Eliminar contenido del mensaje cargado",
button_injectattchment_text: "Cargar contenido del mensaje"
};
case "fr": //french
return {
context_uninjectattchment_text: "Supprimer le contenu du message chargé",
button_injectattchment_text: "Charger le contenu du message"
};
case "it": //italian
return {
context_uninjectattchment_text: "Rimuovi il contenuto del messaggio caricato",
button_injectattchment_text: "Carica il contenuto del messaggio"
};
case "nl": //dutch
return {
context_uninjectattchment_text: "Verwijder geladen berichtinhoud",
button_injectattchment_text: "Laad berichtinhoud"
};
case "no": //norwegian
return {
context_uninjectattchment_text: "Fjern lastet meldingens innhold",
button_injectattchment_text: "Last inn meldingens innhold"
};
case "pl": //polish
return {
context_uninjectattchment_text: "Usuń załadowaną treść wiadomości",
button_injectattchment_text: "Załaduj treść wiadomości"
};
case "pt-BR": //portuguese (brazil)
return {
context_uninjectattchment_text: "Remover o conteúdo da mensagem carregada",
button_injectattchment_text: "Carregar conteúdo da mensagem"
};
case "fi": //finnish
return {
context_uninjectattchment_text: "Poista ladattu viestin sisältö",
button_injectattchment_text: "Lataa viestin sisältö"
};
case "sv": //swedish
return {
context_uninjectattchment_text: "Ta bort laddat meddelandeinnehåll",
button_injectattchment_text: "Ladda meddelandets innehåll"
};
case "tr": //turkish
return {
context_uninjectattchment_text: "Yüklenen mesaj içeriğini kaldır",
button_injectattchment_text: "Mesaj içeriğini yükle"
};
case "cs": //czech
return {
context_uninjectattchment_text: "Odebrat načtený obsah zprávy",
button_injectattchment_text: "Načíst obsah zprávy"
};
case "bg": //bulgarian
return {
context_uninjectattchment_text: "Премахнете зареденото съдържание на съобщението",
button_injectattchment_text: "Заредете съдържание на съобщението"
};
case "ru": //russian
return {
context_uninjectattchment_text: "Удалить загруженное содержимое сообщения",
button_injectattchment_text: "Загрузить содержимое сообщения"
};
case "uk": //ukrainian
return {
context_uninjectattchment_text: "Видаліть завантажений вміст повідомлення",
button_injectattchment_text: "Завантажте вміст повідомлення"
};
case "ja": //japanese
return {
context_uninjectattchment_text: "ロードされたメッセージコンテンツを削除する",
button_injectattchment_text: "メッセージの内容を読み込む"
};
case "zh-TW": //chinese (traditional)
return {
context_uninjectattchment_text: "刪除已加載的郵件內容",
button_injectattchment_text: "加載消息內容"
};
case "ko": //korean
return {
context_uninjectattchment_text: "로드 된 메시지 내용 제거",
button_injectattchment_text: "메시지 내용로드"
};
default: //default: english
return {
context_uninjectattchment_text: "Remove loaded message content",
button_injectattchment_text: "Load message content"
};
BDFDB.TimeUtils.clear(updateTimeout);
updateTimeout = BDFDB.TimeUtils.timeout(_ => {BDFDB.ReactUtils.forceUpdate(instance);}, 1000);
});
}
}
}
processAttachment (e) {
if (e.instance.props.filename == "message.txt" && (settings.onDemand || amounts.maxFileSize && (amounts.maxFileSize < e.instance.props.size/1024))) {
e.returnvalue.props.children.splice(2, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: this.labels.button_injectattchment_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {
rel: "noreferrer noopener",
target: "_blank",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN._displaylargemessagesinjectbutton,
name: BDFDB.LibraryComponents.SvgIcon.Names.RAW_TEXT,
width: 20,
height: 20
}),
onClick: event => {
BDFDB.ListenerUtils.stopEvent(event);
let target = event.target;
let message = BDFDB.ReactUtils.findValue(target, "message", {up: true});
if (message) {
pendingRequests.push(message.id);
BDFDB.LibraryRequires.request(e.instance.props.url, (error, response, body) => {
BDFDB.ArrayUtils.remove(pendingRequests, message.id, true);
oldMessages[message.id] = new BDFDB.DiscordObjects.Message(message);
encodedMessages[message.id] = {
content: message.content || "",
attachment: body || ""
};
BDFDB.MessageUtils.rerenderAll(true);
});
}
}
})
}));
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
context_uninjectattchment_text: "Uklonite učitani sadržaj poruke",
button_injectattchment_text: "Učitajte sadržaj poruke"
};
case "da": //danish
return {
context_uninjectattchment_text: "Fjern indlæst meddelelsesindhold",
button_injectattchment_text: "Indlæs meddelelsesindhold"
};
case "de": //german
return {
context_uninjectattchment_text: "Geladenen Nachrichteninhalt entfernen",
button_injectattchment_text: "Nachrichteninhalt laden"
};
case "es": //spanish
return {
context_uninjectattchment_text: "Eliminar contenido del mensaje cargado",
button_injectattchment_text: "Cargar contenido del mensaje"
};
case "fr": //french
return {
context_uninjectattchment_text: "Supprimer le contenu du message chargé",
button_injectattchment_text: "Charger le contenu du message"
};
case "it": //italian
return {
context_uninjectattchment_text: "Rimuovi il contenuto del messaggio caricato",
button_injectattchment_text: "Carica il contenuto del messaggio"
};
case "nl": //dutch
return {
context_uninjectattchment_text: "Verwijder geladen berichtinhoud",
button_injectattchment_text: "Laad berichtinhoud"
};
case "no": //norwegian
return {
context_uninjectattchment_text: "Fjern lastet meldingens innhold",
button_injectattchment_text: "Last inn meldingens innhold"
};
case "pl": //polish
return {
context_uninjectattchment_text: "Usuń załadowaną treść wiadomości",
button_injectattchment_text: "Załaduj treść wiadomości"
};
case "pt-BR": //portuguese (brazil)
return {
context_uninjectattchment_text: "Remover o conteúdo da mensagem carregada",
button_injectattchment_text: "Carregar conteúdo da mensagem"
};
case "fi": //finnish
return {
context_uninjectattchment_text: "Poista ladattu viestin sisältö",
button_injectattchment_text: "Lataa viestin sisältö"
};
case "sv": //swedish
return {
context_uninjectattchment_text: "Ta bort laddat meddelandeinnehåll",
button_injectattchment_text: "Ladda meddelandets innehåll"
};
case "tr": //turkish
return {
context_uninjectattchment_text: "Yüklenen mesaj içeriğini kaldır",
button_injectattchment_text: "Mesaj içeriğini yükle"
};
case "cs": //czech
return {
context_uninjectattchment_text: "Odebrat načtený obsah zprávy",
button_injectattchment_text: "Načíst obsah zprávy"
};
case "bg": //bulgarian
return {
context_uninjectattchment_text: "Премахнете зареденото съдържание на съобщението",
button_injectattchment_text: "Заредете съдържание на съобщението"
};
case "ru": //russian
return {
context_uninjectattchment_text: "Удалить загруженное содержимое сообщения",
button_injectattchment_text: "Загрузить содержимое сообщения"
};
case "uk": //ukrainian
return {
context_uninjectattchment_text: "Видаліть завантажений вміст повідомлення",
button_injectattchment_text: "Завантажте вміст повідомлення"
};
case "ja": //japanese
return {
context_uninjectattchment_text: "ロードされたメッセージコンテンツを削除する",
button_injectattchment_text: "メッセージの内容を読み込む"
};
case "zh-TW": //chinese (traditional)
return {
context_uninjectattchment_text: "刪除已加載的郵件內容",
button_injectattchment_text: "加載消息內容"
};
case "ko": //korean
return {
context_uninjectattchment_text: "로드 된 메시지 내용 제거",
button_injectattchment_text: "메시지 내용로드"
};
default: //default: english
return {
context_uninjectattchment_text: "Remove loaded message content",
button_injectattchment_text: "Load message content"
};
}
}
}
})();
module.exports = DisplayLargeMessages;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,108 +1,66 @@
//META{"name":"DisplayServersAsChannels","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/DisplayServersAsChannels","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/DisplayServersAsChannels/DisplayServersAsChannels.plugin.js"}*//
var DisplayServersAsChannels = (_ => {
var settings = {}, amounts = {};
return class DisplayServersAsChannels {
getName () {return "DisplayServersAsChannels";}
getVersion () {return "1.4.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Display servers in a similar way as channels.";}
constructor () {
this.patchPriority = 10;
this.patchedModules = {
after: {
Guilds: "render",
DefaultHomeButton: "render",
DirectMessage: "render",
Guild: "render",
GuildFolder: "type",
CircleIconButton: "render",
UnavailableGuildsButton: "UnavailableGuildsButton"
}
};
}
initConstructor () {
this.defaults = {
settings: {
showGuildIcon: {value:true, description:"Show a icon for servers"},
},
amounts: {
serverListWidth: {value:240, min:45, description:"Server list width in px:"},
serverElementHeight: {value:32, min:16, description:"Server element height in px:"}
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "DisplayServersAsChannels",
"author": "DevilBro",
"version": "1.4.1",
"description": "Display servers in a similar way as channels."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
for (let key in amounts) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {}, amounts = {};
return class DisplayServersAsChannels extends Plugin {
onLoad() {
this.defaults = {
settings: {
showGuildIcon: {value:true, description:"Show a icon for servers"},
},
amounts: {
serverListWidth: {value:240, min:45, description:"Server list width in px:"},
serverElementHeight: {value:32, min:16, description:"Server element height in px:"}
}
};
this.patchPriority = 10;
this.patchedModules = {
after: {
Guilds: "render",
DefaultHomeButton: "render",
DirectMessage: "render",
Guild: "render",
GuildFolder: "type",
CircleIconButton: "render",
UnavailableGuildsButton: "UnavailableGuildsButton"
}
};
}
onStart() {
BDFDB.DOMUtils.addClass(document.body, BDFDB.disCN._displayserversaschannelsstyled);
BDFDB.PatchUtils.patch(this, BDFDB.LibraryComponents.GuildComponents.Guild.prototype, "render", {after: e => {
@ -112,393 +70,410 @@ var DisplayServersAsChannels = (_ => {
this.forceUpdateAll();
this.addCSS();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.DOMUtils.removeClassFromDOM(BDFDB.disCN._displayserversaschannelsstyled);
BDFDB.DOMUtils.removeLocalStyle("DSACStyle" + this.name);
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
this.addCSS();
}
}
processGuilds (e) {
let [errorChildren, errorIndex] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "FluxContainer(<Unknown>)"});
if (errorIndex > -1) errorChildren[errorIndex] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Items.UnavailableGuildsButton, {
unavailableGuilds: BDFDB.LibraryModules.GuildUnavailableStore.totalUnavailableGuilds
});
let scroller = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.guildsscroller]]});
if (scroller) {
scroller.props.fade = true;
scroller.type = BDFDB.LibraryComponents.ScrollerThin;
}
}
processDefaultHomeButton (e) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, BDFDB.LanguageUtils.LanguageStrings.HOME);
}
processDirectMessage (e) {
if (e.instance.props.channel.id) {
let text = BDFDB.ReactUtils.findValue(e.returnvalue, "text");
let icon = BDFDB.ReactUtils.findValue(e.returnvalue, "icon");
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, text, {
badges: icon && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AvatarComponents.default, {
src: icon,
size: BDFDB.LibraryComponents.AvatarComponents.Sizes.SIZE_24
})
});
}
}
processGuild (e) {
if (e.instance.props.guild) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, e.instance.props.guild.name, {
badges: [
settings.showGuildIcon && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Icon, {
animate: e.instance.props.animatable && e.instance.state && e.instance.state.hovered,
guild: e.instance.props.guild,
size: BDFDB.LibraryComponents.GuildComponents.Icon.Sizes.SMALLER
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Badge, {
size: amounts.serverElementHeight * 0.5,
badgeColor: BDFDB.DiscordConstants.Colors.STATUS_GREY,
tooltipColor: BDFDB.LibraryComponents.TooltipContainer.Colors.BLACK,
tooltipPosition: BDFDB.LibraryComponents.TooltipContainer.Positions.RIGHT,
guild: e.instance.props.guild
})
]
});
}
}
processGuildFolder (e) {
if (e.instance.props.folderId) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
let folderColor = BDFDB.ColorUtils.convert(e.instance.props.folderColor, "HEX") || BDFDB.DiscordConstants.Colors.BRAND;
let folderSize = Math.round(amounts.serverElementHeight * 0.6);
this.addElementName(e.returnvalue, e.instance.props.folderName || BDFDB.LanguageUtils.LanguageStrings.SERVER_FOLDER_PLACEHOLDER, {
wrap: true,
backgroundColor: e.instance.props.expanded && BDFDB.ColorUtils.setAlpha(folderColor, 0.2),
badges: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
color: folderColor,
width: folderSize,
height: folderSize,
name: BDFDB.LibraryComponents.SvgIcon.Names.FOLDER
})
});
}
}
processCircleIconButton (e) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, e.instance.props.tooltipText, {
wrap: true,
backgroundColor: "transparent"
});
}
processUnavailableGuildsButton (e) {
this.removeTooltip(e.returnvalue);
this.addElementName(e.returnvalue, `${e.instance.props.unavailableGuilds} ${e.instance.props.unavailableGuilds == 1 ? "Server" : "Servers"}`, {
wrap: true,
backgroundColor: "transparent"
});
}
removeTooltip (parent) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: ["Tooltip", "ListItemTooltip", "GuildTooltip", "BDFDB_TooltipContainer"]});
if (index > -1) children[index] = children[index].props.children;
}
removeMask (parent) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: "BlobMask"});
if (index > -1) {
let badges = [];
for (let key of Object.keys(children[index].props)) if (key && key.endsWith("Badge") && BDFDB.ReactUtils.isValidElement(children[index].props[key])) badges.push(children[index].props[key]);
(children[index].props.children[0] || children[index].props.children).props.children = [
(children[index].props.children[0] || children[index].props.children).props.children,
badges
].flat(10).filter(n => n);
children[index] = children[index].props.children;
}
}
addElementName (parent, name, options = {}) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: ["NavItem", "Clickable"], props:[["className",BDFDB.disCN.guildserrorinner]]});
if (index > -1) {
delete children[index].props.icon;
delete children[index].props.name;
let [children2, index2] = BDFDB.ReactUtils.findParent(children[index].props.children, {name:"FolderIcon", props:[["className",BDFDB.disCN.guildfoldericonwrapper]]});
if (index2 > -1) children2.splice(index2, 1);
let childEles = [
[options.badges].flat(10).filter(n => n).map(badge => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._displayserversaschannelsbadge,
children: badge
})),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._displayserversaschannelsname,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: name
})
}),
children[index].props.children
].flat().filter(n => n);
children[index].props.children = options.wrap ? BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildiconchildwrapper,
style: {backgroundColor: options.backgroundColor},
children: childEles
}) : childEles;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
for (let key in amounts) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
this.addCSS();
}
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
amounts = BDFDB.DataUtils.get(this, "amounts");
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.GuildUtils.rerenderAll();
}
processGuilds (e) {
let [errorChildren, errorIndex] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "FluxContainer(<Unknown>)"});
if (errorIndex > -1) errorChildren[errorIndex] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Items.UnavailableGuildsButton, {
unavailableGuilds: BDFDB.LibraryModules.GuildUnavailableStore.totalUnavailableGuilds
});
let scroller = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.guildsscroller]]});
if (scroller) {
scroller.props.fade = true;
scroller.type = BDFDB.LibraryComponents.Scrollers.Thin;
}
}
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.GuildUtils.rerenderAll();
}
processDefaultHomeButton (e) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, BDFDB.LanguageUtils.LanguageStrings.HOME);
}
processDirectMessage (e) {
if (e.instance.props.channel.id) {
let text = BDFDB.ReactUtils.findValue(e.returnvalue, "text");
let icon = BDFDB.ReactUtils.findValue(e.returnvalue, "icon");
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, text, {
badges: icon && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.AvatarComponents.default, {
src: icon,
size: BDFDB.LibraryComponents.AvatarComponents.Sizes.SIZE_24
})
});
}
}
processGuild (e) {
if (e.instance.props.guild) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, e.instance.props.guild.name, {
badges: [
settings.showGuildIcon && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Icon, {
animate: e.instance.props.animatable && e.instance.state && e.instance.state.hovered,
guild: e.instance.props.guild,
size: BDFDB.LibraryComponents.GuildComponents.Icon.Sizes.SMALLER
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Badge, {
size: amounts.serverElementHeight * 0.5,
badgeColor: BDFDB.DiscordConstants.Colors.STATUS_GREY,
tooltipColor: BDFDB.LibraryComponents.TooltipContainer.Colors.BLACK,
tooltipPosition: BDFDB.LibraryComponents.TooltipContainer.Positions.RIGHT,
guild: e.instance.props.guild
})
]
});
}
}
processGuildFolder (e) {
if (e.instance.props.folderId) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
let folderColor = BDFDB.ColorUtils.convert(e.instance.props.folderColor, "HEX") || BDFDB.DiscordConstants.Colors.BRAND;
let folderSize = Math.round(amounts.serverElementHeight * 0.6);
this.addElementName(e.returnvalue, e.instance.props.folderName || BDFDB.LanguageUtils.LanguageStrings.SERVER_FOLDER_PLACEHOLDER, {
wrap: true,
backgroundColor: e.instance.props.expanded && BDFDB.ColorUtils.setAlpha(folderColor, 0.2),
badges: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
color: folderColor,
width: folderSize,
height: folderSize,
name: BDFDB.LibraryComponents.SvgIcon.Names.FOLDER
})
});
}
}
processCircleIconButton (e) {
this.removeTooltip(e.returnvalue);
this.removeMask(e.returnvalue);
this.addElementName(e.returnvalue, e.instance.props.tooltipText, {
wrap: true,
backgroundColor: "transparent"
});
}
processUnavailableGuildsButton (e) {
this.removeTooltip(e.returnvalue);
this.addElementName(e.returnvalue, `${e.instance.props.unavailableGuilds} ${e.instance.props.unavailableGuilds == 1 ? "Server" : "Servers"}`, {
wrap: true,
backgroundColor: "transparent"
});
}
removeTooltip (parent) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: ["Tooltip", "ListItemTooltip", "GuildTooltip", "BDFDB_TooltipContainer"]});
if (index > -1) children[index] = children[index].props.children;
}
removeMask (parent) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: "BlobMask"});
if (index > -1) {
let badges = [];
for (let key of Object.keys(children[index].props)) if (key && key.endsWith("Badge") && BDFDB.ReactUtils.isValidElement(children[index].props[key])) badges.push(children[index].props[key]);
(children[index].props.children[0] || children[index].props.children).props.children = [
(children[index].props.children[0] || children[index].props.children).props.children,
badges
].flat(10).filter(n => n);
children[index] = children[index].props.children;
}
}
addElementName (parent, name, options = {}) {
let [children, index] = BDFDB.ReactUtils.findParent(parent, {name: ["NavItem", "Clickable"], props:[["className",BDFDB.disCN.guildserrorinner]]});
if (index > -1) {
delete children[index].props.icon;
delete children[index].props.name;
let [children2, index2] = BDFDB.ReactUtils.findParent(children[index].props.children, {name:"FolderIcon", props:[["className",BDFDB.disCN.guildfoldericonwrapper]]});
if (index2 > -1) children2.splice(index2, 1);
let childEles = [
[options.badges].flat(10).filter(n => n).map(badge => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._displayserversaschannelsbadge,
children: badge
})),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._displayserversaschannelsname,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: name
})
}),
children[index].props.children
].flat().filter(n => n);
children[index].props.children = options.wrap ? BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildiconchildwrapper,
style: {backgroundColor: options.backgroundColor},
children: childEles
}) : childEles;
}
}
addCSS () {
BDFDB.DOMUtils.appendLocalStyle("DSACStyle" + this.name, `
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsbartop},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsbarbottom} {
width: ${amounts.serverListWidth}px;
}
${BDFDB.dotCNS.themedark + BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller}::-webkit-scrollbar-thumb,
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper + BDFDB.dotCNS.themedark + BDFDB.dotCN.guildsscroller}::-webkit-scrollbar-thumb {
background-color: ${BDFDB.DiscordConstants.Colors.PRIMARY_DARK_800};
}
addCSS () {
BDFDB.DOMUtils.appendLocalStyle("DSACStyle" + this.name, `
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsbartop},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildswrapperunreadmentionsbarbottom} {
width: ${amounts.serverListWidth}px;
}
${BDFDB.dotCNS.themedark + BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller}::-webkit-scrollbar-thumb,
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper + BDFDB.dotCNS.themedark + BDFDB.dotCN.guildsscroller}::-webkit-scrollbar-thumb {
background-color: ${BDFDB.DiscordConstants.Colors.PRIMARY_DARK_800};
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} {
width: auto;
display: flex;
justify-content: flex-start;
margin-left: 8px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller} > div[style*="transform"][style*="height"] {
height: unset !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildpillwrapper} {
top: ${-1 * (48 - amounts.serverElementHeight) / 2}px;
left: -8px;
transform: scaleY(calc(${amounts.serverElementHeight}/48));
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconchildwrapper} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
padding: 0 8px;
box-sizing: border-box;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN._displayserversaschannelsname} {
flex: 1 1 auto;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
padding-top: 1px;
overflow: hidden;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN._displayserversaschannelsbadge}:not(:empty) {
display: flex;
margin-right: 4px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCNS._displayserversaschannelsbadge + BDFDB.dotCN.avataricon} {
width: ${amounts.serverElementHeight/32 * 24}px;
height: ${amounts.serverElementHeight/32 * 24}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase} {
margin-left: 4px;
border-radius: ${amounts.serverElementHeight/32 * 8}px;
width: ${amounts.serverElementHeight/32 * 16}px;
height: ${amounts.serverElementHeight/32 * 16}px;
font-size: ${amounts.serverElementHeight/32 * 12}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 16px;"] {
width: ${amounts.serverElementHeight/32 * 16}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 22px;"] {
width: ${amounts.serverElementHeight/32 * 22}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 30px;"] {
width: ${amounts.serverElementHeight/32 * 30}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter} {
width: auto;
display: flex;
justify-content: flex-start;
margin-left: 8px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildsscroller} > div[style*="transform"][style*="height"] {
height: unset !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildpillwrapper} {
top: ${-1 * (48 - amounts.serverElementHeight) / 2}px;
left: -8px;
transform: scaleY(calc(${amounts.serverElementHeight}/48));
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconchildwrapper} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
padding: 0 8px;
box-sizing: border-box;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN._displayserversaschannelsname} {
flex: 1 1 auto;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
padding-top: 1px;
overflow: hidden;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN._displayserversaschannelsbadge}:not(:empty) {
display: flex;
margin-right: 4px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCNS._displayserversaschannelsbadge + BDFDB.dotCN.avataricon} {
width: ${amounts.serverElementHeight/32 * 24}px;
height: ${amounts.serverElementHeight/32 * 24}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase} {
margin-left: 4px;
border-radius: ${amounts.serverElementHeight/32 * 8}px;
width: ${amounts.serverElementHeight/32 * 16}px;
height: ${amounts.serverElementHeight/32 * 16}px;
font-size: ${amounts.serverElementHeight/32 * 12}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 16px;"] {
width: ${amounts.serverElementHeight/32 * 16}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 22px;"] {
width: ${amounts.serverElementHeight/32 * 22}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildiconchildwrapper + BDFDB.dotCN.badgebase}[style*="width: 30px;"] {
width: ${amounts.serverElementHeight/32 * 30}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.homebuttonicon} {
width: ${amounts.serverElementHeight/32 * 28}px;
height: ${amounts.serverElementHeight/32 * 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.homebuttonicon} {
width: ${amounts.serverElementHeight/32 * 28}px;
height: ${amounts.serverElementHeight/32 * 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.avatarwrapper} {
width: ${amounts.serverElementHeight/32 * 24}px !important;
height: ${amounts.serverElementHeight/32 * 24}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildseparator} {
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.avatarwrapper} {
width: ${amounts.serverElementHeight/32 * 24}px !important;
height: ${amounts.serverElementHeight/32 * 24}px !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildseparator} {
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconwrapper} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconwrapper} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} {
width: auto;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolder} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderexpandedbackground} {
top: -2px;
right: 2px;
bottom: -2px;
left: 6px;
width: auto;
border-radius: 4px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} [role="group"] {
height: auto !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} [role="group"] ${BDFDB.dotCN.guildouter}:last-child {
margin-bottom: 10px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} {
width: auto;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolder} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderexpandedbackground} {
top: -2px;
right: 2px;
bottom: -2px;
left: 6px;
width: auto;
border-radius: 4px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} [role="group"] {
height: auto !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolderwrapper} [role="group"] ${BDFDB.dotCN.guildouter}:last-child {
margin-bottom: 10px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner} svg {
width: ${amounts.serverElementHeight/32 * 20}px;
height: ${amounts.serverElementHeight/32 * 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildbuttoninner + BDFDB.dotCN._displayserversaschannelsname} {
padding-top: 0;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner} svg {
width: ${amounts.serverElementHeight/32 * 20}px;
height: ${amounts.serverElementHeight/32 * 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildbuttoninner + BDFDB.dotCN._displayserversaschannelsname} {
padding-top: 0;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildserror} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
font-size: ${amounts.serverElementHeight/32 * 20}px;
border: none;
display: block;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildserror + BDFDB.dotCN.guildiconchildwrapper} {
padding-right: ${amounts.serverElementHeight/32 * 16 + (32/amounts.serverElementHeight - 1) * 4}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildserror + BDFDB.dotCN._displayserversaschannelsname} {
padding-top: 0;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildserror} {
height: ${amounts.serverElementHeight}px;
width: ${amounts.serverListWidth - 20}px;
font-size: ${amounts.serverElementHeight/32 * 20}px;
border: none;
display: block;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildserror + BDFDB.dotCN.guildiconchildwrapper} {
padding-right: ${amounts.serverElementHeight/32 * 16 + (32/amounts.serverElementHeight - 1) * 4}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCNS.guildserror + BDFDB.dotCN._displayserversaschannelsname} {
padding-top: 0;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonframe},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttoninner},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonbutton},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-li,
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-button {
height: ${amounts.serverElementHeight}px !important;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._friendnotificationsfriendsonline},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildslabel} {
height: ${amounts.serverElementHeight * 0.6}px !important;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonbutton},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._friendnotificationsfriendsonline},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildslabel},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-button {
display: flex;
justify-content: flex-start;
align-items: center;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
text-transform: capitalize;
padding-top: 1px;
padding-left: 8px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonframe},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttoninner},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonbutton},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-li,
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-button {
height: ${amounts.serverElementHeight}px !important;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._friendnotificationsfriendsonline},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildslabel} {
height: ${amounts.serverElementHeight * 0.6}px !important;
width: ${amounts.serverListWidth - 20}px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._readallnotificationsbuttonbutton},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN._friendnotificationsfriendsonline},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildslabel},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} #bd-pub-button {
display: flex;
justify-content: flex-start;
align-items: center;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
text-transform: capitalize;
padding-top: 1px;
padding-left: 8px;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconwrapper},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolder},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildserror} {
border-radius: 4px;
overflow: hidden;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildiconwrapper},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildfolder},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildbuttoninner},
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildserror} {
border-radius: 4px;
overflow: hidden;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.appcontainer} {
display: flex !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} {
position: static !important;
contain: unset !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.chatbase} {
position: static !important;
contain: unset !important;
width: 100% !important;
}
#server-search ${BDFDB.dotCN.guildinner} {
width: ${amounts.serverListWidth - 20}px;
height: ${amounts.serverElementHeight}px;
border-radius: 4px !important;
}
#server-search ${BDFDB.dotCN.guildinner}::before {
content: "Server Search";
color: var(--text-normal);
display: flex;
align-items: center;
height: ${amounts.serverElementHeight}px;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
padding-left: 8px;
}
#server-search ${BDFDB.dotCN.guildinner}::after {
content: "";
position: absolute;
top: ${amounts.serverElementHeight/32 * 6}px;
right: 7px;
width: ${amounts.serverElementHeight/32 * 20}px;
height: ${amounts.serverElementHeight/32 * 20}px;
background: var(--text-normal);
-webkit-mask: url('data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAxOCAxOCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSJ3aGl0ZSIgZD0iTTMuNjAwOTE0ODEsNy4yMDI5NzMxMyBDMy42MDA5MTQ4MSw1LjIwOTgzNDE5IDUuMjA5ODM0MTksMy42MDA5MTQ4MSA3LjIwMjk3MzEzLDMuNjAwOTE0ODEgQzkuMTk2MTEyMDYsMy42MDA5MTQ4MSAxMC44MDUwMzE0LDUuMjA5ODM0MTkgMTAuODA1MDMxNCw3LjIwMjk3MzEzIEMxMC44MDUwMzE0LDkuMTk2MTEyMDYgOS4xOTYxMTIwNiwxMC44MDUwMzE0IDcuMjAyOTczMTMsMTAuODA1MDMxNCBDNS4yMDk4MzQxOSwxMC44MDUwMzE0IDMuNjAwOTE0ODEsOS4xOTYxMTIwNiAzLjYwMDkxNDgxLDcuMjAyOTczMTMgWiBNMTIuMDA1NzE3NiwxMC44MDUwMzE0IEwxMS4zNzMzNTYyLDEwLjgwNTAzMTQgTDExLjE0OTIyODEsMTAuNTg4OTA3OSBDMTEuOTMzNjc2NCw5LjY3NjM4NjUxIDEyLjQwNTk0NjMsOC40OTE3MDk1NSAxMi40MDU5NDYzLDcuMjAyOTczMTMgQzEyLjQwNTk0NjMsNC4zMjkzMzEwNSAxMC4wNzY2MTUyLDIgNy4yMDI5NzMxMywyIEM0LjMyOTMzMTA1LDIgMiw0LjMyOTMzMTA1IDIsNy4yMDI5NzMxMyBDMiwxMC4wNzY2MTUyIDQuMzI5MzMxMDUsMTIuNDA1OTQ2MyA3LjIwMjk3MzEzLDEyLjQwNTk0NjMgQzguNDkxNzA5NTUsMTIuNDA1OTQ2MyA5LjY3NjM4NjUxLDExLjkzMzY3NjQgMTAuNTg4OTA3OSwxMS4xNDkyMjgxIEwxMC44MDUwMzE0LDExLjM3MzM1NjIgTDEwLjgwNTAzMTQsMTIuMDA1NzE3NiBMMTQuODA3MzE4NSwxNiBMMTYsMTQuODA3MzE4NSBMMTIuMjEwMjUzOCwxMS4wMDk5Nzc2IEwxMi4wMDU3MTc2LDEwLjgwNTAzMTQgWiI+PC9wYXRoPjwvZz48L3N2Zz4=') center/cover no-repeat;
}
#server-search ${BDFDB.dotCN.guildbuttonpill},
#server-search ${BDFDB.dotCN.guildsvg} {
display: none;
}`);
}
}
})();
module.exports = DisplayServersAsChannels;
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.appcontainer} {
display: flex !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.guildswrapper} {
position: static !important;
contain: unset !important;
}
${BDFDB.dotCNS._displayserversaschannelsstyled + BDFDB.dotCN.chatbase} {
position: static !important;
contain: unset !important;
width: 100% !important;
}
#server-search ${BDFDB.dotCN.guildinner} {
width: ${amounts.serverListWidth - 20}px;
height: ${amounts.serverElementHeight}px;
border-radius: 4px !important;
}
#server-search ${BDFDB.dotCN.guildinner}::before {
content: "Server Search";
color: var(--text-normal);
display: flex;
align-items: center;
height: ${amounts.serverElementHeight}px;
font-size: ${amounts.serverElementHeight / 2}px;
font-weight: 400;
padding-left: 8px;
}
#server-search ${BDFDB.dotCN.guildinner}::after {
content: "";
position: absolute;
top: ${amounts.serverElementHeight/32 * 6}px;
right: 7px;
width: ${amounts.serverElementHeight/32 * 20}px;
height: ${amounts.serverElementHeight/32 * 20}px;
background: var(--text-normal);
-webkit-mask: url('data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAxOCAxOCI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBmaWxsPSJ3aGl0ZSIgZD0iTTMuNjAwOTE0ODEsNy4yMDI5NzMxMyBDMy42MDA5MTQ4MSw1LjIwOTgzNDE5IDUuMjA5ODM0MTksMy42MDA5MTQ4MSA3LjIwMjk3MzEzLDMuNjAwOTE0ODEgQzkuMTk2MTEyMDYsMy42MDA5MTQ4MSAxMC44MDUwMzE0LDUuMjA5ODM0MTkgMTAuODA1MDMxNCw3LjIwMjk3MzEzIEMxMC44MDUwMzE0LDkuMTk2MTEyMDYgOS4xOTYxMTIwNiwxMC44MDUwMzE0IDcuMjAyOTczMTMsMTAuODA1MDMxNCBDNS4yMDk4MzQxOSwxMC44MDUwMzE0IDMuNjAwOTE0ODEsOS4xOTYxMTIwNiAzLjYwMDkxNDgxLDcuMjAyOTczMTMgWiBNMTIuMDA1NzE3NiwxMC44MDUwMzE0IEwxMS4zNzMzNTYyLDEwLjgwNTAzMTQgTDExLjE0OTIyODEsMTAuNTg4OTA3OSBDMTEuOTMzNjc2NCw5LjY3NjM4NjUxIDEyLjQwNTk0NjMsOC40OTE3MDk1NSAxMi40MDU5NDYzLDcuMjAyOTczMTMgQzEyLjQwNTk0NjMsNC4zMjkzMzEwNSAxMC4wNzY2MTUyLDIgNy4yMDI5NzMxMywyIEM0LjMyOTMzMTA1LDIgMiw0LjMyOTMzMTA1IDIsNy4yMDI5NzMxMyBDMiwxMC4wNzY2MTUyIDQuMzI5MzMxMDUsMTIuNDA1OTQ2MyA3LjIwMjk3MzEzLDEyLjQwNTk0NjMgQzguNDkxNzA5NTUsMTIuNDA1OTQ2MyA5LjY3NjM4NjUxLDExLjkzMzY3NjQgMTAuNTg4OTA3OSwxMS4xNDkyMjgxIEwxMC44MDUwMzE0LDExLjM3MzM1NjIgTDEwLjgwNTAzMTQsMTIuMDA1NzE3NiBMMTQuODA3MzE4NSwxNiBMMTYsMTQuODA3MzE4NSBMMTIuMjEwMjUzOCwxMS4wMDk5Nzc2IEwxMi4wMDU3MTc2LDEwLjgwNTAzMTQgWiI+PC9wYXRoPjwvZz48L3N2Zz4=') center/cover no-repeat;
}
#server-search ${BDFDB.dotCN.guildbuttonpill},
#server-search ${BDFDB.dotCN.guildsvg} {
display: none;
}`);
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,397 +1,372 @@
//META{"name":"EmojiStatistics","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EmojiStatistics","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EmojiStatistics/EmojiStatistics.plugin.js"}*//
var EmojiStatistics = (_ => {
let emojiReplicaList;
return class EmojiStatistics {
getName () {return "EmojiStatistics";}
getVersion () {return "2.9.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds some helpful options to show you more information about emojis and emojiservers.";}
constructor () {
this.changelog = {
"fixed":[["New Style","Fixed for the new expression picker (emoji + gif combo)"]]
};
this.patchedModules = {
after: {
EmojiPicker: "type"
}
};
}
initConstructor () {
this.css = `
.${this.name}-table ${BDFDB.dotCN._emojistatisticsiconcell} {
justify-content: center;
width: 48px;
padding: 0;
}
.${this.name}-table ${BDFDB.dotCN._emojistatisticsnamecell} {
width: 300px;
}
.${this.name}-table ${BDFDB.dotCN._emojistatisticsamountcell} {
width: 120px;
}
${BDFDB.dotCNS.emojipicker + BDFDB.dotCN.emojipickerheader} {
grid-template-columns: auto 24px 24px;
}
${BDFDB.dotCNS.emojipicker + BDFDB.dotCN._emojistatisticsstatisticsbutton} {
width: 24px;
height: 24px;
grid-column: 3/4;
}`;
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processEmojiPicker (e) {
this.loadEmojiList();
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name:"DiversitySelector"});
if (index > -1) children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: "Emoji Statistics",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN._emojistatisticsstatisticsbutton,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.emojipickerdiversityemojiitemimage,
style: {
backgroundImage: "url(/assets/0477c6a43026315dd623bc6367e18acb.svg)"
}
})
}),
onClick: _ => {
this.showEmojiInformationModal();
e.instance.props.closePopout();
}
}));
}
loadEmojiList () {
emojiReplicaList = {};
let guilds = BDFDB.LibraryModules.GuildStore.getGuilds();
for (let id in guilds) for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(id)) {
if (emoji.managed) emojiReplicaList[emoji.name] = emojiReplicaList[emoji.name] != undefined;
}
module.exports = (_ => {
const config = {
"info": {
"name": "EmojiStatistics",
"author": "DevilBro",
"version": "2.9.5",
"description": "Adds some helpful options to show you more information about emojis and emojiservers."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
showEmojiInformationModal () {
BDFDB.ModalUtils.open(this, {
size: "LARGE",
header: this.labels.modal_header_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Table, {
className: `${this.name}-table`,
stickyHeader: true,
sortData: false,
columns: [{key:"icon", sortkey:"index", cell:"icon"}, {key:"name", cell:"name"}, {key:"total", cell:"amount", reverse:true}, {key:"global", cell:"amount", reverse:true}, {key:"local", cell:"amount", reverse:true}, {key:"copies", cell:"amount", reverse:true}].map(data => {return {
key: data.sortkey || data.key,
sort: true,
reverse: data.reverse,
cellClassName: BDFDB.disCN[`_emojistatistics${data.cell}cell`],
renderHeader: _ => {
return this.labels[`modal_titles${data.key}_text`]
},
render: guilddata => {
if (data.key == "icon") return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Guild, {
guild: guilddata[data.key],
menu: false,
tooltip: false
});
else if (data.key == "name") return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: guilddata[data.key]
});
else return guilddata[data.key]
}
}}),
data: BDFDB.GuildUtils.getAll().map((info, i) => {
let data = {
index: i,
icon: info,
name: info.name,
global: 0,
local: 0,
copies: 0
}
for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(info.id)) {
if (emoji.managed) {
data.global++;
if (emojiReplicaList[emoji.name]) data.copies++;
}
else data.local++;
}
data.total = data.global + data.local;
return data;
})
})
});
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
modal_header_text: "Statistike o emojima",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Naziv poslužitelja",
modal_titlestotal_text: "Cjelokupni",
modal_titlesglobal_text: "Globalno",
modal_titleslocal_text: "Kokalne",
modal_titlescopies_text: "Kopije"
};
case "da": //danish
return {
modal_header_text: "Statistikker af emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servernavn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Copies"
};
case "de": //german
return {
modal_header_text: "Statistiken über Emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servername",
modal_titlestotal_text: "Gesamt",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopien"
};
case "es": //spanish
return {
modal_header_text: "Estadísticas de emojis",
modal_titlesicon_text: "Icono",
modal_titlesname_text: "Nombre del servidor",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copias"
};
case "fr": //french
return {
modal_header_text: "Statistiques des emojis",
modal_titlesicon_text: "Icône",
modal_titlesname_text: "Nom du serveur",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copies"
};
case "it": //italian
return {
modal_header_text: "Statistiche di emojis",
modal_titlesicon_text: "Icona",
modal_titlesname_text: "Nome del server",
modal_titlestotal_text: "Totale",
modal_titlesglobal_text: "Globale",
modal_titleslocal_text: "Locale",
modal_titlescopies_text: "Copie"
};
case "nl": //dutch
return {
modal_header_text: "Statistieken van emojis",
modal_titlesicon_text: "Icoon",
modal_titlesname_text: "Servernaam",
modal_titlestotal_text: "Totaal",
modal_titlesglobal_text: "Globaal",
modal_titleslocal_text: "Lokaal",
modal_titlescopies_text: "Kopieën"
};
case "no": //norwegian
return {
modal_header_text: "Statistikk av emojis",
modal_titlesicon_text: "Ikon",
modal_titlesname_text: "Servernavn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopier"
};
case "pl": //polish
return {
modal_header_text: "Statystyki emoji",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Nazwa",
modal_titlestotal_text: "Całkowity",
modal_titlesglobal_text: "Światowy",
modal_titleslocal_text: "Lokalny",
modal_titlescopies_text: "Kopie"
};
case "pt-BR": //portuguese (brazil)
return {
modal_header_text: "Estatísticas de emojis",
modal_titlesicon_text: "Ícone",
modal_titlesname_text: "Nome do servidor",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Cópias"
};
case "fi": //finnish
return {
modal_header_text: "Tilastot emojista",
modal_titlesicon_text: "Ikoni",
modal_titlesname_text: "Palvelimen nimi",
modal_titlestotal_text: "Koko",
modal_titlesglobal_text: "Globaali",
modal_titleslocal_text: "Paikallinen",
modal_titlescopies_text: "Kopiot"
};
case "sv": //swedish
return {
modal_header_text: "Statistik för emojis",
modal_titlesicon_text: "Ikon",
modal_titlesname_text: "Servernamn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopior"
};
case "tr": //turkish
return {
modal_header_text: "Emojis istatistikleri",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Sunucuadı",
modal_titlestotal_text: "Toplam",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Yerel",
modal_titlescopies_text: "Kopya"
};
case "cs": //czech
return {
modal_header_text: "Statistiky emojis",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Název serveru",
modal_titlestotal_text: "Celkový",
modal_titlesglobal_text: "Globální",
modal_titleslocal_text: "Místní",
modal_titlescopies_text: "Kopie"
};
case "bg": //bulgarian
return {
modal_header_text: "Статистика на емотис",
modal_titlesicon_text: "Икона",
modal_titlesname_text: "Име на сървъра",
modal_titlestotal_text: "Oбщо",
modal_titlesglobal_text: "Cветовен",
modal_titleslocal_text: "Mестен",
modal_titlescopies_text: "Копия"
};
case "ru": //russian
return {
modal_header_text: "Статистика emojis",
modal_titlesicon_text: "Значок",
modal_titlesname_text: "Имя сервера",
modal_titlestotal_text: "Всего",
modal_titlesglobal_text: "Mировой",
modal_titleslocal_text: "Местный",
modal_titlescopies_text: "Копии"
};
case "uk": //ukrainian
return {
modal_header_text: "Статистика емідій",
modal_titlesicon_text: "Ікона",
modal_titlesname_text: "Ім'я сервера",
modal_titlestotal_text: "Всього",
modal_titlesglobal_text: "Cвітовий",
modal_titleslocal_text: "Місцевий",
modal_titlescopies_text: "Копії"
};
case "ja": //japanese
return {
modal_header_text: "エモジスの統計",
modal_titlesicon_text: "アイコン",
modal_titlesname_text: "サーバーの名前",
modal_titlestotal_text: "合計",
modal_titlesglobal_text: "グローバル",
modal_titleslocal_text: "地元",
modal_titlescopies_text: "コピー"
};
case "zh-TW": //chinese (traditional)
return {
modal_header_text: "表情統計",
modal_titlesicon_text: "圖標",
modal_titlesname_text: "服務器名稱",
modal_titlestotal_text: "總",
modal_titlesglobal_text: "全球",
modal_titleslocal_text: "本地",
modal_titlescopies_text: "副本"
};
case "ko": //korean
return {
modal_header_text: "그림 이모티콘의 통계",
modal_titlesicon_text: "상",
modal_titlesname_text: "서버 이름",
modal_titlestotal_text: "합계",
modal_titlesglobal_text: "글로벌",
modal_titleslocal_text: "지방의",
modal_titlescopies_text: "사본"
};
default: //default: english
return {
modal_header_text: "Statistics of emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servername",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copies"
};
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
}
}
})();
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var emojiReplicaList;
return class EmojiStatistics extends Plugin {
onLoad() {
this.patchedModules = {
after: {
EmojiPicker: "type"
}
};
this.css = `
.${this.name}-table ${BDFDB.dotCN._emojistatisticsiconcell} {
justify-content: center;
width: 48px;
padding: 0;
}
.${this.name}-table ${BDFDB.dotCN._emojistatisticsnamecell} {
width: 300px;
}
.${this.name}-table ${BDFDB.dotCN._emojistatisticsamountcell} {
width: 120px;
}
module.exports = EmojiStatistics;
${BDFDB.dotCNS.emojipicker + BDFDB.dotCN.emojipickerheader} {
grid-template-columns: auto 24px 24px;
}
${BDFDB.dotCNS.emojipicker + BDFDB.dotCN._emojistatisticsstatisticsbutton} {
width: 24px;
height: 24px;
grid-column: 3/4;
}
`;
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
processEmojiPicker (e) {
this.loadEmojiList();
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name:"DiversitySelector"});
if (index > -1) children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: "Emoji Statistics",
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN._emojistatisticsstatisticsbutton,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.emojipickerdiversityemojiitemimage,
style: {
backgroundImage: "url(/assets/0477c6a43026315dd623bc6367e18acb.svg)"
}
})
}),
onClick: _ => {
this.showEmojiInformationModal();
e.instance.props.closePopout();
}
}));
}
loadEmojiList () {
emojiReplicaList = {};
let guilds = BDFDB.LibraryModules.GuildStore.getGuilds();
for (let id in guilds) for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(id)) {
if (emoji.managed) emojiReplicaList[emoji.name] = emojiReplicaList[emoji.name] != undefined;
}
}
showEmojiInformationModal () {
BDFDB.ModalUtils.open(this, {
size: "LARGE",
header: this.labels.modal_header_text,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Table, {
className: `${this.name}-table`,
stickyHeader: true,
sortData: false,
columns: [{key:"icon", sortkey:"index", cell:"icon"}, {key:"name", cell:"name"}, {key:"total", cell:"amount", reverse:true}, {key:"global", cell:"amount", reverse:true}, {key:"local", cell:"amount", reverse:true}, {key:"copies", cell:"amount", reverse:true}].map(data => {return {
key: data.sortkey || data.key,
sort: true,
reverse: data.reverse,
cellClassName: BDFDB.disCN[`_emojistatistics${data.cell}cell`],
renderHeader: _ => {
return this.labels[`modal_titles${data.key}_text`]
},
render: guilddata => {
if (data.key == "icon") return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Guild, {
guild: guilddata[data.key],
menu: false,
tooltip: false
});
else if (data.key == "name") return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: guilddata[data.key]
});
else return guilddata[data.key]
}
}}),
data: BDFDB.GuildUtils.getAll().map((info, i) => {
let data = {
index: i,
icon: info,
name: info.name,
global: 0,
local: 0,
copies: 0
}
for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(info.id)) {
if (emoji.managed) {
data.global++;
if (emojiReplicaList[emoji.name]) data.copies++;
}
else data.local++;
}
data.total = data.global + data.local;
return data;
})
})
});
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
modal_header_text: "Statistike o emojima",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Naziv poslužitelja",
modal_titlestotal_text: "Cjelokupni",
modal_titlesglobal_text: "Globalno",
modal_titleslocal_text: "Kokalne",
modal_titlescopies_text: "Kopije"
};
case "da": //danish
return {
modal_header_text: "Statistikker af emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servernavn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Copies"
};
case "de": //german
return {
modal_header_text: "Statistiken über Emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servername",
modal_titlestotal_text: "Gesamt",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopien"
};
case "es": //spanish
return {
modal_header_text: "Estadísticas de emojis",
modal_titlesicon_text: "Icono",
modal_titlesname_text: "Nombre del servidor",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copias"
};
case "fr": //french
return {
modal_header_text: "Statistiques des emojis",
modal_titlesicon_text: "Icône",
modal_titlesname_text: "Nom du serveur",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copies"
};
case "it": //italian
return {
modal_header_text: "Statistiche di emojis",
modal_titlesicon_text: "Icona",
modal_titlesname_text: "Nome del server",
modal_titlestotal_text: "Totale",
modal_titlesglobal_text: "Globale",
modal_titleslocal_text: "Locale",
modal_titlescopies_text: "Copie"
};
case "nl": //dutch
return {
modal_header_text: "Statistieken van emojis",
modal_titlesicon_text: "Icoon",
modal_titlesname_text: "Servernaam",
modal_titlestotal_text: "Totaal",
modal_titlesglobal_text: "Globaal",
modal_titleslocal_text: "Lokaal",
modal_titlescopies_text: "Kopieën"
};
case "no": //norwegian
return {
modal_header_text: "Statistikk av emojis",
modal_titlesicon_text: "Ikon",
modal_titlesname_text: "Servernavn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopier"
};
case "pl": //polish
return {
modal_header_text: "Statystyki emoji",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Nazwa",
modal_titlestotal_text: "Całkowity",
modal_titlesglobal_text: "Światowy",
modal_titleslocal_text: "Lokalny",
modal_titlescopies_text: "Kopie"
};
case "pt-BR": //portuguese (brazil)
return {
modal_header_text: "Estatísticas de emojis",
modal_titlesicon_text: "Ícone",
modal_titlesname_text: "Nome do servidor",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Cópias"
};
case "fi": //finnish
return {
modal_header_text: "Tilastot emojista",
modal_titlesicon_text: "Ikoni",
modal_titlesname_text: "Palvelimen nimi",
modal_titlestotal_text: "Koko",
modal_titlesglobal_text: "Globaali",
modal_titleslocal_text: "Paikallinen",
modal_titlescopies_text: "Kopiot"
};
case "sv": //swedish
return {
modal_header_text: "Statistik för emojis",
modal_titlesicon_text: "Ikon",
modal_titlesname_text: "Servernamn",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Lokal",
modal_titlescopies_text: "Kopior"
};
case "tr": //turkish
return {
modal_header_text: "Emojis istatistikleri",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Sunucuadı",
modal_titlestotal_text: "Toplam",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Yerel",
modal_titlescopies_text: "Kopya"
};
case "cs": //czech
return {
modal_header_text: "Statistiky emojis",
modal_titlesicon_text: "Ikona",
modal_titlesname_text: "Název serveru",
modal_titlestotal_text: "Celkový",
modal_titlesglobal_text: "Globální",
modal_titleslocal_text: "Místní",
modal_titlescopies_text: "Kopie"
};
case "bg": //bulgarian
return {
modal_header_text: "Статистика на емотис",
modal_titlesicon_text: "Икона",
modal_titlesname_text: "Име на сървъра",
modal_titlestotal_text: "Oбщо",
modal_titlesglobal_text: "Cветовен",
modal_titleslocal_text: "Mестен",
modal_titlescopies_text: "Копия"
};
case "ru": //russian
return {
modal_header_text: "Статистика emojis",
modal_titlesicon_text: "Значок",
modal_titlesname_text: "Имя сервера",
modal_titlestotal_text: "Всего",
modal_titlesglobal_text: "Mировой",
modal_titleslocal_text: "Местный",
modal_titlescopies_text: "Копии"
};
case "uk": //ukrainian
return {
modal_header_text: "Статистика емідій",
modal_titlesicon_text: "Ікона",
modal_titlesname_text: "Ім'я сервера",
modal_titlestotal_text: "Всього",
modal_titlesglobal_text: "Cвітовий",
modal_titleslocal_text: "Місцевий",
modal_titlescopies_text: "Копії"
};
case "ja": //japanese
return {
modal_header_text: "エモジスの統計",
modal_titlesicon_text: "アイコン",
modal_titlesname_text: "サーバーの名前",
modal_titlestotal_text: "合計",
modal_titlesglobal_text: "グローバル",
modal_titleslocal_text: "地元",
modal_titlescopies_text: "コピー"
};
case "zh-TW": //chinese (traditional)
return {
modal_header_text: "表情統計",
modal_titlesicon_text: "圖標",
modal_titlesname_text: "服務器名稱",
modal_titlestotal_text: "總",
modal_titlesglobal_text: "全球",
modal_titleslocal_text: "本地",
modal_titlescopies_text: "副本"
};
case "ko": //korean
return {
modal_header_text: "그림 이모티콘의 통계",
modal_titlesicon_text: "상",
modal_titlesname_text: "서버 이름",
modal_titlestotal_text: "합계",
modal_titlesglobal_text: "글로벌",
modal_titleslocal_text: "지방의",
modal_titlescopies_text: "사본"
};
default: //default: english
return {
modal_header_text: "Statistics of emojis",
modal_titlesicon_text: "Icon",
modal_titlesname_text: "Servername",
modal_titlestotal_text: "Total",
modal_titlesglobal_text: "Global",
modal_titleslocal_text: "Local",
modal_titlescopies_text: "Copies"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,170 +1,144 @@
//META{"name":"ForceImagePreviews","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ForceImagePreviews","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ForceImagePreviews/ForceImagePreviews.plugin.js"}*//
var ForceImagePreviews = (_ => {
var loadedEmbeds, requestedEmbeds;
module.exports = (_ => {
const config = {
"info": {
"name": "ForceImagePreviews",
"author": "DevilBro",
"version": "1.2.0",
"description": "Forces embedded Image Previews, if Discord doesn't do it itself. Caution: Externals Images can contain malicious code and reveal your IP!"
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var loadedEmbeds, requestedEmbeds;
return class ForceImagePreviews {
getName () {return "ForceImagePreviews";}
getVersion () {return "1.2.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Forces embedded Image Previews, if Discord doesn't do it itself. Caution: Externals Images can contain malicious code and reveal your IP!";}
constructor () {
this.changelog = {
"improved":[["Requests","No longer tries to request an embed more than one time"]]
};
this.patchedModules = {
before: {
SimpleMessageAccessories: "default"
}
};
}
initConstructor () {
loadedEmbeds = {};
requestedEmbeds = [];
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
return class ForceImagePreviews extends Plugin {
onLoad() {
loadedEmbeds = {};
requestedEmbeds = [];
this.patchedModules = {
before: {
SimpleMessageAccessories: "default"
}
};
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processSimpleMessageAccessories (e) {
if (e.instance.props.message.content) {
let message = new BDFDB.DiscordObjects.Message(e.instance.props.message);
for (let link of e.instance.props.message.content.split(/\n|\s|\r|\t|\0/g)) if (link.indexOf("https://") > -1 || link.indexOf("http://") > -1) {
link = link.indexOf("<") == 0 && link.indexOf(">") == link.length - 1 ? link.slice(1, -1) : link;
if (!this.isEmbedded(message.embeds, link)) {
if (!requestedEmbeds.includes(link)) {
requestedEmbeds.push(link);
BDFDB.LibraryRequires.request(link, (error, response, result) => {
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") > -1) {
let imageThrowaway = document.createElement("img");
imageThrowaway.src = link;
imageThrowaway.onload = _ => {
processSimpleMessageAccessories (e) {
if (e.instance.props.message && e.instance.props.message.content) {
let message = new BDFDB.DiscordObjects.Message(e.instance.props.message);
for (let link of e.instance.props.message.content.split(/\n|\s|\r|\t|\0/g)) if (link.indexOf("https://") > -1 || link.indexOf("http://") > -1) {
link = link.indexOf("<") == 0 && link.indexOf(">") == link.length - 1 ? link.slice(1, -1) : link;
if (!this.isEmbedded(message.embeds, link)) {
if (!requestedEmbeds.includes(link)) {
requestedEmbeds.push(link);
BDFDB.LibraryRequires.request(link, (error, response, result) => {
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") > -1) {
let imageThrowaway = document.createElement("img");
imageThrowaway.src = link;
imageThrowaway.onload = _ => {
if (!this.isEmbedded(message.embeds, link)) {
loadedEmbeds[link] = {
image: {
url: link,
proxyURL: link,
height: imageThrowaway.naturalHeight,
width: imageThrowaway.naturalWidth
},
type: "image",
url: link
};
message.embeds.push(loadedEmbeds[link]);
BDFDB.ReactUtils.forceUpdate(e.instance);
}
};
}
else if (response && response.headers["server"] && response.headers["server"].toLowerCase().indexOf("youtube") > -1 && result.indexOf("yt-user-info") > -1) {
if (!this.isEmbedded(message.embeds, link)) {
result = result.replace(/[\r|\n|\t]|[\s]{2,}/g, "");
let width = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="width" content="'), "i"))[1].split('"')[0];
let height = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="height" content="'), "i"))[1].split('"')[0];
let thumbnail = result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="thumbnailUrl" href="'), "i"))[1].split('"')[0];
loadedEmbeds[link] = {
image: {
url: link,
proxyURL: link,
height: imageThrowaway.naturalHeight,
width: imageThrowaway.naturalWidth
author: {
name: result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('>')[1].split('<')[0],
url: `https://www.youtube.com${result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('"')[0]}`
},
type: "image",
url: link
color: "#ff0000",
provider: {
name: "YouTube",
url: "https://www.youtube.com/"
},
rawDescription: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og:description" content="'), "i"))[1].split('"')[0],
rawTitle: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og:title" content="'), "i"))[1].split('"')[0],
thumbnail: {
url: thumbnail,
proxyURL: thumbnail,
width: width,
height: height
},
type: "video",
url: link,
video: {
url: result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="embedUrl" href="'), "i"))[1].split('"')[0],
width: width,
height: height
}
};
message.embeds.push(loadedEmbeds[link]);
BDFDB.ReactUtils.forceUpdate(e.instance);
}
};
}
else if (response && response.headers["server"] && response.headers["server"].toLowerCase().indexOf("youtube") > -1 && result.indexOf("yt-user-info") > -1) {
if (!this.isEmbedded(message.embeds, link)) {
result = result.replace(/[\r|\n|\t]|[\s]{2,}/g, "");
let width = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="width" content="'), "i"))[1].split('"')[0];
let height = result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta itemprop="height" content="'), "i"))[1].split('"')[0];
let thumbnail = result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="thumbnailUrl" href="'), "i"))[1].split('"')[0];
loadedEmbeds[link] = {
author: {
name: result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('>')[1].split('<')[0],
url: `https://www.youtube.com${result.split(new RegExp(BDFDB.StringUtils.regEscape('<div class="yt-user-info"><a href="'), "i"))[1].split('"')[0]}`
},
color: "#ff0000",
provider: {
name: "YouTube",
url: "https://www.youtube.com/"
},
rawDescription: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og:description" content="'), "i"))[1].split('"')[0],
rawTitle: result.split(new RegExp(BDFDB.StringUtils.regEscape('<meta property="og:title" content="'), "i"))[1].split('"')[0],
thumbnail: {
url: thumbnail,
proxyURL: thumbnail,
width: width,
height: height
},
type: "video",
url: link,
video: {
url: result.split(new RegExp(BDFDB.StringUtils.regEscape('<link itemprop="embedUrl" href="'), "i"))[1].split('"')[0],
width: width,
height: height
}
};
message.embeds.push(loadedEmbeds[link]);
BDFDB.ReactUtils.forceUpdate(e.instance);
}
}
});
});
}
else if (loadedEmbeds[link]) message.embeds.push(loadedEmbeds[link]);
}
else if (loadedEmbeds[link]) message.embeds.push(loadedEmbeds[link]);
}
e.instance.props.message = message;
}
e.instance.props.message = message;
}
}
isEmbedded (embeds, link) {
if (link.indexOf("youtube.") > -1 || link.indexOf("youtu.be") > -1) {
let videoId = (link.split("watch?v=")[1] || link.split("?")[0].split("/").pop() || "").split("&").shift();
if (videoId) for (let embed of embeds) if (embed.url == link || embed.video && embed.url.indexOf(videoId) > -1) return true;
isEmbedded (embeds, link) {
if (link.indexOf("youtube.") > -1 || link.indexOf("youtu.be") > -1) {
let videoId = (link.split("watch?v=")[1] || link.split("?")[0].split("/").pop() || "").split("&").shift();
if (videoId) for (let embed of embeds) if (embed.url == link || embed.video && embed.url.indexOf(videoId) > -1) return true;
}
else {
for (let embed of embeds) if (embed.url == link || embed.image && embed.image.url == link) return true;
}
return false;
}
else {
for (let embed of embeds) if (embed.url == link || embed.image && embed.image.url == link) return true;
}
return false;
}
}
})();
module.exports = ForceImagePreviews;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

View File

@ -1,303 +1,275 @@
//META{"name":"GoogleSearchReplace","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/GoogleSearchReplace","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/GoogleSearchReplace/GoogleSearchReplace.plugin.js"}*//
var GoogleSearchReplace = (_ => {
const textUrlReplaceString = "DEVILBRO_BD_GOOGLESEARCHREPLACE_REPLACE_TEXTURL";
var enabledEngines = {}, settings = {};
module.exports = (_ => {
const config = {
"info": {
"name": "GoogleSearchReplace",
"author": "DevilBro",
"version": "1.2.7",
"description": "Replaces the default Google Text Search with a selection menu of several search engines."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
const textUrlReplaceString = "DEVILBRO_BD_GOOGLESEARCHREPLACE_REPLACE_TEXTURL";
var settings = {}, engines = {}, enabledEngines = {};
return class GoogleSearchReplace {
getName () {return "GoogleSearchReplace";}
getVersion () {return "1.2.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Replaces the default Google Text Search with a selection menu of several search engines.";}
constructor () {
this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
};
}
initConstructor () {
this.defaults = {
settings: {
useChromium: {value:false, description:"Use an inbuilt browser window instead of opening your default browser"},
},
engines: {
_all: {value:true, name:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL, url:null},
Ask: {value:true, name:"Ask", url:"https://ask.com/web?q=" + textUrlReplaceString},
Bing: {value:true, name:"Bing", url:"https://www.bing.com/search?q=" + textUrlReplaceString},
DogPile: {value:true, name:"DogPile", url:"http://www.dogpile.com/search/web?q=" + textUrlReplaceString},
DuckDuckGo: {value:true, name:"DuckDuckGo", url:"https://duckduckgo.com/?q=" + textUrlReplaceString},
Google: {value:true, name:"Google", url:"https://www.google.com/search?q=" + textUrlReplaceString},
GoogleScholar: {value:true, name:"Google Scholar", url:"https://scholar.google.com/scholar?q=" + textUrlReplaceString},
Quora: {value:true, name:"Quora", url:"https://www.quora.com/search?q=" + textUrlReplaceString},
Qwant: {value:true, name:"Qwant", url:"https://www.qwant.com/?t=all&q=" + textUrlReplaceString},
UrbanDictionary: {value:true, name:"Urban Dictionary", url:"https://www.urbandictionary.com/define.php?term=" + textUrlReplaceString},
Searx: {value:true, name:"Searx", url:"https://searx.me/?q=" + textUrlReplaceString},
WolframAlpha: {value:true, name:"Wolfram Alpha", url:"https://www.wolframalpha.com/input/?i=" + textUrlReplaceString},
Yandex: {value:true, name:"Yandex", url:"https://yandex.com/search/?text=" + textUrlReplaceString},
Yahoo: {value:true, name:"Yahoo", url:"https://search.yahoo.com/search?p=" + textUrlReplaceString},
YouTube: {value:true, name:"YouTube", url:"https://www.youtube.com/results?q=" + textUrlReplaceString}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let engines = BDFDB.DataUtils.get(this, "engines");
let settingsPanel, settingsItems = [];
return class GoogleSearchReplace extends Plugin {
onLoad() {
this.defaults = {
settings: {
useChromium: {value:false, description:"Use an inbuilt browser window instead of opening your default browser"},
},
engines: {
_all: {value:true, name:BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL, url:null},
Ask: {value:true, name:"Ask", url:"https://ask.com/web?q=" + textUrlReplaceString},
Bing: {value:true, name:"Bing", url:"https://www.bing.com/search?q=" + textUrlReplaceString},
DogPile: {value:true, name:"DogPile", url:"http://www.dogpile.com/search/web?q=" + textUrlReplaceString},
DuckDuckGo: {value:true, name:"DuckDuckGo", url:"https://duckduckgo.com/?q=" + textUrlReplaceString},
Google: {value:true, name:"Google", url:"https://www.google.com/search?q=" + textUrlReplaceString},
GoogleScholar: {value:true, name:"Google Scholar", url:"https://scholar.google.com/scholar?q=" + textUrlReplaceString},
Quora: {value:true, name:"Quora", url:"https://www.quora.com/search?q=" + textUrlReplaceString},
Qwant: {value:true, name:"Qwant", url:"https://www.qwant.com/?t=all&q=" + textUrlReplaceString},
UrbanDictionary: {value:true, name:"Urban Dictionary", url:"https://www.urbandictionary.com/define.php?term=" + textUrlReplaceString},
Searx: {value:true, name:"Searx", url:"https://searx.me/?q=" + textUrlReplaceString},
WolframAlpha: {value:true, name:"Wolfram Alpha", url:"https://www.wolframalpha.com/input/?i=" + textUrlReplaceString},
Yandex: {value:true, name:"Yandex", url:"https://yandex.com/search/?text=" + textUrlReplaceString},
Yahoo: {value:true, name:"Yahoo", url:"https://search.yahoo.com/search?p=" + textUrlReplaceString},
YouTube: {value:true, name:"YouTube", url:"https://www.youtube.com/results?q=" + textUrlReplaceString}
}
};
}
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Search Engines:",
first: settingsItems.length == 0,
last: true,
children: Object.keys(engines).filter(n => n && n != "_all").map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
onStart() {
this.forceUpdateAll();
}
onStop() {}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["engines", key],
label: this.defaults.engines[key].name,
value: engines[key]
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onMessageContextMenu (e) {
this.injectItem(e);
}
onNativeContextMenu (e) {
this.injectItem(e);
}
injectItem (e) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "search-google"});
if (index > -1) {
let text = document.getSelection().toString();
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
let engineKeys = Object.keys(enginesWithoutAll);
if (engineKeys.length == 1) {
children.splice(index, 1, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_googlesearchreplace_text.replace("...", this.defaults.engines[engineKeys[0]].name),
id: children[index].props.id,
persisting: true,
action: event => {
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.DiscordUtils.openLink(this.defaults.engines[engineKeys[0]].url.replace(textUrlReplaceString, encodeURIComponent(text)), !settings.useChromium, event.shiftKey);
}
}));
}
else {
let items = [];
for (let key in enabledEngines) items.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Search Engines:",
first: settingsItems.length == 0,
last: true,
children: Object.keys(engines).filter(n => n && n != "_all").map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["engines", key],
label: this.defaults.engines[key].name,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search", key),
color: key == "_all" ? BDFDB.LibraryComponents.MenuItems.Colors.DANGER : BDFDB.LibraryComponents.MenuItems.Colors.DEFAULT,
persisting: true,
action: event => {
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
if (key == "_all") {
for (let key2 in enginesWithoutAll) BDFDB.DiscordUtils.openLink(this.defaults.engines[key2].url.replace(textUrlReplaceString, encodeURIComponent(text)), settings.useChromium, event.shiftKey);
}
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(textUrlReplaceString, encodeURIComponent(text)), settings.useChromium, event.shiftKey);
}
}));
if (!items.length) items.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.submenu_disabled_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "disabled"),
disabled: true
}));
children.splice(index, 1, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_googlesearchreplace_text,
id: children[index].props.id,
children: items
}));
value: engines[key]
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
engines = BDFDB.DataUtils.get(this, "engines");
enabledEngines = BDFDB.ObjectUtils.filter(engines, n => n);
}
}
forceUpdateAll () {
enabledEngines = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "engines"), n => n);
settings = BDFDB.DataUtils.get(this, "settings");
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
context_googlesearchreplace_text: "Pretražujte s ...",
submenu_disabled_text: "Svi su onemogućeni"
};
case "da": //danish
return {
context_googlesearchreplace_text: "Søg med ...",
submenu_disabled_text: "Alle deaktiveret"
};
case "de": //german
return {
context_googlesearchreplace_text: "Suche mit ...",
submenu_disabled_text: "Alle deaktiviert"
};
case "es": //spanish
return {
context_googlesearchreplace_text: "Buscar con ...",
submenu_disabled_text: "Todo desactivado"
};
case "fr": //french
return {
context_googlesearchreplace_text: "Rechercher avec ...",
submenu_disabled_text: "Tous désactivés"
};
case "it": //italian
return {
context_googlesearchreplace_text: "Cerca con ...",
submenu_disabled_text: "Tutto disattivato"
};
case "nl": //dutch
return {
context_googlesearchreplace_text: "Zoeken met ...",
submenu_disabled_text: "Alles gedeactiveerd"
};
case "no": //norwegian
return {
context_googlesearchreplace_text: "Søk med ...",
submenu_disabled_text: "Alle deaktivert"
};
case "pl": //polish
return {
context_googlesearchreplace_text: "Szukaj za pomocą ...",
submenu_disabled_text: "Wszystkie wyłączone"
};
case "pt-BR": //portuguese (brazil)
return {
context_googlesearchreplace_text: "Pesquisar com ...",
submenu_disabled_text: "Todos desativados"
};
case "fi": //finnish
return {
context_googlesearchreplace_text: "Etsi ...",
submenu_disabled_text: "Kaikki on poistettu käytöstä"
};
case "sv": //swedish
return {
context_googlesearchreplace_text: "Sök med ...",
submenu_disabled_text: "Alla avaktiverade"
};
case "tr": //turkish
return {
context_googlesearchreplace_text: "Ile ara ...",
submenu_disabled_text: "Hepsi deaktive"
};
case "cs": //czech
return {
context_googlesearchreplace_text: "Hledat s ...",
submenu_disabled_text: "Všechny deaktivované"
};
case "bg": //bulgarian
return {
context_googlesearchreplace_text: "Търсене с ...",
submenu_disabled_text: "Всички са деактивирани"
};
case "ru": //russian
return {
context_googlesearchreplace_text: "Поиск с ...",
submenu_disabled_text: "Все деактивированные"
};
case "uk": //ukrainian
return {
context_googlesearchreplace_text: "Пошук з ...",
submenu_disabled_text: "Всі вимкнені"
};
case "ja": //japanese
return {
context_googlesearchreplace_text: "で検索する ...",
submenu_disabled_text: "すべて非アクティブ化"
};
case "zh-TW": //chinese (traditional)
return {
context_googlesearchreplace_text: "搜索 ...",
submenu_disabled_text: "全部停用"
};
case "ko": //korean
return {
context_googlesearchreplace_text: "다음으로 검색 ...",
submenu_disabled_text: "모두 비활성화 됨"
};
default: //default: english
return {
context_googlesearchreplace_text: "Search with ...",
submenu_disabled_text: "All disabled"
};
onMessageContextMenu (e) {
this.injectItem(e);
}
}
}
})();
module.exports = GoogleSearchReplace;
onNativeContextMenu (e) {
this.injectItem(e);
}
injectItem (e) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "search-google"});
if (index > -1) {
let text = document.getSelection().toString();
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
let engineKeys = Object.keys(enginesWithoutAll);
if (engineKeys.length == 1) {
children.splice(index, 1, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_googlesearchreplace_text.replace("...", this.defaults.engines[engineKeys[0]].name),
id: children[index].props.id,
persisting: true,
action: event => {
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
BDFDB.DiscordUtils.openLink(this.defaults.engines[engineKeys[0]].url.replace(textUrlReplaceString, encodeURIComponent(text)), !settings.useChromium, event.shiftKey);
}
}));
}
else {
let items = [];
for (let key in enabledEngines) items.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.defaults.engines[key].name,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search", key),
color: key == "_all" ? BDFDB.LibraryComponents.MenuItems.Colors.DANGER : BDFDB.LibraryComponents.MenuItems.Colors.DEFAULT,
persisting: true,
action: event => {
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
if (key == "_all") {
for (let key2 in enginesWithoutAll) BDFDB.DiscordUtils.openLink(this.defaults.engines[key2].url.replace(textUrlReplaceString, encodeURIComponent(text)), settings.useChromium, event.shiftKey);
}
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(textUrlReplaceString, encodeURIComponent(text)), settings.useChromium, event.shiftKey);
}
}));
if (!items.length) items.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.submenu_disabled_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "disabled"),
disabled: true
}));
children.splice(index, 1, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_googlesearchreplace_text,
id: children[index].props.id,
children: items
}));
}
}
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
context_googlesearchreplace_text: "Pretražujte s ...",
submenu_disabled_text: "Svi su onemogućeni"
};
case "da": //danish
return {
context_googlesearchreplace_text: "Søg med ...",
submenu_disabled_text: "Alle deaktiveret"
};
case "de": //german
return {
context_googlesearchreplace_text: "Suche mit ...",
submenu_disabled_text: "Alle deaktiviert"
};
case "es": //spanish
return {
context_googlesearchreplace_text: "Buscar con ...",
submenu_disabled_text: "Todo desactivado"
};
case "fr": //french
return {
context_googlesearchreplace_text: "Rechercher avec ...",
submenu_disabled_text: "Tous désactivés"
};
case "it": //italian
return {
context_googlesearchreplace_text: "Cerca con ...",
submenu_disabled_text: "Tutto disattivato"
};
case "nl": //dutch
return {
context_googlesearchreplace_text: "Zoeken met ...",
submenu_disabled_text: "Alles gedeactiveerd"
};
case "no": //norwegian
return {
context_googlesearchreplace_text: "Søk med ...",
submenu_disabled_text: "Alle deaktivert"
};
case "pl": //polish
return {
context_googlesearchreplace_text: "Szukaj za pomocą ...",
submenu_disabled_text: "Wszystkie wyłączone"
};
case "pt-BR": //portuguese (brazil)
return {
context_googlesearchreplace_text: "Pesquisar com ...",
submenu_disabled_text: "Todos desativados"
};
case "fi": //finnish
return {
context_googlesearchreplace_text: "Etsi ...",
submenu_disabled_text: "Kaikki on poistettu käytöstä"
};
case "sv": //swedish
return {
context_googlesearchreplace_text: "Sök med ...",
submenu_disabled_text: "Alla avaktiverade"
};
case "tr": //turkish
return {
context_googlesearchreplace_text: "Ile ara ...",
submenu_disabled_text: "Hepsi deaktive"
};
case "cs": //czech
return {
context_googlesearchreplace_text: "Hledat s ...",
submenu_disabled_text: "Všechny deaktivované"
};
case "bg": //bulgarian
return {
context_googlesearchreplace_text: "Търсене с ...",
submenu_disabled_text: "Всички са деактивирани"
};
case "ru": //russian
return {
context_googlesearchreplace_text: "Поиск с ...",
submenu_disabled_text: "Все деактивированные"
};
case "uk": //ukrainian
return {
context_googlesearchreplace_text: "Пошук з ...",
submenu_disabled_text: "Всі вимкнені"
};
case "ja": //japanese
return {
context_googlesearchreplace_text: "で検索する ...",
submenu_disabled_text: "すべて非アクティブ化"
};
case "zh-TW": //chinese (traditional)
return {
context_googlesearchreplace_text: "搜索 ...",
submenu_disabled_text: "全部停用"
};
case "ko": //korean
return {
context_googlesearchreplace_text: "다음으로 검색 ...",
submenu_disabled_text: "모두 비활성화 됨"
};
default: //default: english
return {
context_googlesearchreplace_text: "Search with ...",
submenu_disabled_text: "All disabled"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,78 @@
//META{"name":"HideMutedCategories","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/HideMutedCategories","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/HideMutedCategories/HideMutedCategories.plugin.js"}*//
//META{"name":"PluginTemplate","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/PluginTemplate","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PluginTemplate/PluginTemplate.plugin.js"}*//
var HideMutedCategories = (_ => {
return class HideMutedCategories {
getName () {return "HideMutedCategories";}
getVersion () {return "1.0.2";}
getAuthor () {return "DevilBro";}
getDescription () {return "Hides muted categories the same way muted channels are hidden, when the server is set to hide muted channels.";}
constructor () {
this.changelog = {
"fixed":[["New Scroller","Adjusted for the new scroller component"]]
};
this.patchPriority = 10;
this.patchedModules = {
before: {
Channels: "render"
},
after: {
Channels: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "HideMutedCategories",
"author": "DevilBro",
"version": "1.0.2",
"description": "Hides muted categories the same way muted channels are hidden, when the server is set to hide muted channels."
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.PatchUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
// Begin of own functions
processChannels (e) {
if (!e.instance.props.guild || !e.instance.props.collapseMuted) return;
if (!e.returnvalue) {
e.instance.props.categories = Object.assign({}, e.instance.props.categories);
for (let catId in e.instance.props.categories) if (BDFDB.LibraryModules.MutedUtils.isChannelMuted(e.instance.props.guild.id, catId)) e.instance.props.categories[catId] = [];
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else {
let list = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelsscroller]]});
if (list) {
let renderSection = list.props.renderSection;
list.props.renderSection = (...args) => {
let section = renderSection(...args);
if (section && section.props && section.props.channel && BDFDB.LibraryModules.MutedUtils.isChannelMuted(e.instance.props.guild.id, section.props.channel.id))return null;
else return section;
};
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class HideMutedCategories extends Plugin {
onLoad() {
this.patchPriority = 10;
this.patchedModules = {
before: {
Channels: "render"
},
after: {
Channels: "render"
}
};
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
processChannels (e) {
if (!e.instance.props.guild || !e.instance.props.collapseMuted) return;
if (!e.returnvalue) {
e.instance.props.categories = Object.assign({}, e.instance.props.categories);
for (let catId in e.instance.props.categories) if (BDFDB.LibraryModules.MutedUtils.isChannelMuted(e.instance.props.guild.id, catId)) e.instance.props.categories[catId] = [];
}
else {
let list = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelsscroller]]});
if (list) {
let renderSection = list.props.renderSection;
list.props.renderSection = (...args) => {
let section = renderSection(...args);
if (section && section.props && section.props.channel && BDFDB.LibraryModules.MutedUtils.isChannelMuted(e.instance.props.guild.id, section.props.channel.id))return null;
else return section;
};
}
}
}
}
}
})();
module.exports = HideMutedCategories;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

View File

@ -1,237 +1,75 @@
//META{"name":"JoinedAtDate","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/JoinedAtDate","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/JoinedAtDate/JoinedAtDate.plugin.js"}*//
var JoinedAtDate = (_ => {
var loadedUsers, requestedUsers, languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class JoinedAtDate {
getName () {return "JoinedAtDate";}
getVersion () {return "1.2.4";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays the Joined At Date of the current Server for a Member in the UserPopout and UserModal.";}
constructor () {
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "JoinedAtDate",
"author": "DevilBro",
"version": "1.2.4",
"description": "Displays the Joined At Date of the current Server for a Member in the UserPopout and UserModal."
}
initConstructor () {
loadedUsers = {};
requestedUsers = {};
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Joined on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
joinedAtDateLang: {value:"$discord", description:"Joined At Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: innerItems
}));
innerItems = [];
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in amounts) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: innerItems
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
dividertop: true,
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
});
})
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var loadedUsers, requestedUsers, languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class JoinedAtDate extends Plugin {
onLoad() {
loadedUsers = {};
requestedUsers = {};
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Joined on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
joinedAtDateLang: {value:"$discord", description:"Joined At Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
}
onStart() {
languages = BDFDB.ObjectUtils.deepAssign({
own: {
name: "Own",
@ -241,226 +79,343 @@ var JoinedAtDate = (_ => {
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processUserPopout (e) {
if (e.instance.props.user && e.instance.props.guild && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild.id);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(e.instance, children, 1, children[index].props.user, BDFDB.ReactUtils.findValue(e.instance, "guildId", {up: true}));
return renderedChildren;
};
}
}
injectDate (instance, children, index, user, guildId) {
if (!guildId) guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId();
if (!BDFDB.ArrayUtils.is(children) || !user || !guildId || user.discriminator == "0000" || !BDFDB.LibraryModules.MemberStore.getMember(guildId, user.id)) return;
if (!loadedUsers[guildId]) loadedUsers[guildId] = {};
if (!requestedUsers[guildId]) requestedUsers[guildId] = {};
if (!BDFDB.ArrayUtils.is(requestedUsers[guildId][user.id])) {
requestedUsers[guildId][user.id] = [instance];
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.GUILD_MEMBER(guildId, user.id)).then(result => {
loadedUsers[guildId][user.id] = new Date(result.body.joined_at);
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
});
}
else if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
else {
let timestamp = this.getTimestamp(languages[choices.joinedAtDateLang].id, loadedUsers[guildId][user.id]);
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._joinedatdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.joinedat_text.replace("{{time}}", timestamp) : timestamp
}));
}
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
joinedat_text: "Pridružio {{time}}"
};
case "da": //danish
return {
joinedat_text: "Tilmeldt den {{time}}"
};
case "de": //german
return {
joinedat_text: "Beigetreten am {{time}}"
};
case "es": //spanish
return {
joinedat_text: "Unido el {{time}}"
};
case "fr": //french
return {
joinedat_text: "Rejoint le {{time}}"
};
case "it": //italian
return {
joinedat_text: "Iscritto il {{time}}"
};
case "nl": //dutch
return {
joinedat_text: "Aangesloten op {{time}}"
};
case "no": //norwegian
return {
joinedat_text: "Ble med på {{time}}"
};
case "pl": //polish
return {
joinedat_text: "Dołączył {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
joinedat_text: "Inscreveu-se em {{time}}"
};
case "fi": //finnish
return {
joinedat_text: "Liittynyt {{time}}"
};
case "sv": //swedish
return {
joinedat_text: "Anlände den {{time}}"
};
case "tr": //turkish
return {
joinedat_text: "Katıldı {{time}}"
};
case "cs": //czech
return {
joinedat_text: "Přihlásil dne {{time}}"
};
case "bg": //bulgarian
return {
joinedat_text: "Се присъедини на {{time}}"
};
case "ru": //russian
return {
joinedat_text: "Присоединился {{time}}"
};
case "uk": //ukrainian
return {
joinedat_text: "Приєднався {{time}}"
};
case "ja": //japanese
return {
joinedat_text: "{{time}} に参加しました"
};
case "zh-TW": //chinese (traditional)
return {
joinedat_text: "加入於 {{time}}"
};
case "ko": //korean
return {
joinedat_text: "{{time}} 에 가입"
};
default: //default: english
return {
joinedat_text: "Joined on {{time}}"
};
onStop() {
this.forceUpdateAll();
}
}
}
})();
module.exports = JoinedAtDate;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processUserPopout (e) {
if (e.instance.props.user && e.instance.props.guild && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild.id);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(e.instance, children, 1, children[index].props.user, BDFDB.ReactUtils.findValue(e.instance, "guildId", {up: true}));
return renderedChildren;
};
}
}
injectDate (instance, children, index, user, guildId) {
if (!guildId) guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId();
if (!BDFDB.ArrayUtils.is(children) || !user || !guildId || user.discriminator == "0000" || !BDFDB.LibraryModules.MemberStore.getMember(guildId, user.id)) return;
if (!loadedUsers[guildId]) loadedUsers[guildId] = {};
if (!requestedUsers[guildId]) requestedUsers[guildId] = {};
if (!BDFDB.ArrayUtils.is(requestedUsers[guildId][user.id])) {
requestedUsers[guildId][user.id] = [instance];
BDFDB.LibraryModules.APIUtils.get(BDFDB.DiscordConstants.Endpoints.GUILD_MEMBER(guildId, user.id)).then(result => {
loadedUsers[guildId][user.id] = new Date(result.body.joined_at);
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
});
}
else if (!loadedUsers[guildId][user.id]) requestedUsers[guildId][user.id].push(instance);
else {
let timestamp = this.getTimestamp(languages[choices.joinedAtDateLang].id, loadedUsers[guildId][user.id]);
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._joinedatdatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.joinedat_text.replace("{{time}}", timestamp) : timestamp
}));
}
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
joinedat_text: "Pridružio {{time}}"
};
case "da": //danish
return {
joinedat_text: "Tilmeldt den {{time}}"
};
case "de": //german
return {
joinedat_text: "Beigetreten am {{time}}"
};
case "es": //spanish
return {
joinedat_text: "Unido el {{time}}"
};
case "fr": //french
return {
joinedat_text: "Rejoint le {{time}}"
};
case "it": //italian
return {
joinedat_text: "Iscritto il {{time}}"
};
case "nl": //dutch
return {
joinedat_text: "Aangesloten op {{time}}"
};
case "no": //norwegian
return {
joinedat_text: "Ble med på {{time}}"
};
case "pl": //polish
return {
joinedat_text: "Dołączył {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
joinedat_text: "Inscreveu-se em {{time}}"
};
case "fi": //finnish
return {
joinedat_text: "Liittynyt {{time}}"
};
case "sv": //swedish
return {
joinedat_text: "Anlände den {{time}}"
};
case "tr": //turkish
return {
joinedat_text: "Katıldı {{time}}"
};
case "cs": //czech
return {
joinedat_text: "Přihlásil dne {{time}}"
};
case "bg": //bulgarian
return {
joinedat_text: "Се присъедини на {{time}}"
};
case "ru": //russian
return {
joinedat_text: "Присоединился {{time}}"
};
case "uk": //ukrainian
return {
joinedat_text: "Приєднався {{time}}"
};
case "ja": //japanese
return {
joinedat_text: "{{time}} に参加しました"
};
case "zh-TW": //chinese (traditional)
return {
joinedat_text: "加入於 {{time}}"
};
case "ko": //korean
return {
joinedat_text: "{{time}} 에 가입"
};
default: //default: english
return {
joinedat_text: "Joined on {{time}}"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,237 +1,75 @@
//META{"name":"LastMessageDate","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/LastMessageDate","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/LastMessageDate/LastMessageDate.plugin.js"}*//
var LastMessageDate = (_ => {
var loadedUsers, requestedUsers, languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class LastMessageDate {
getName () {return "LastMessageDate";}
getVersion () {return "1.1.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Displays the Date of the last sent Message of a Member for the current Server/DM in the UserPopout and UserModal.";}
constructor () {
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "LastMessageDate",
"author": "DevilBro",
"version": "1.1.9",
"description": "Displays the Date of the last sent Message of a Member for the current Server/DM in the UserPopout and UserModal."
}
initConstructor () {
loadedUsers = {};
requestedUsers = {};
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Last message on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
lastMessageDateLang: {value:"$discord", description:"Last Message Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: innerItems
}));
innerItems = [];
for (let key in choices) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in formats) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}));
innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let key in amounts) innerItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: innerItems
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
dividertop: true,
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
});
})
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var loadedUsers, requestedUsers, languages;
var settings = {}, choices = {}, formats = {}, amounts = {};
return class LastMessageDate extends Plugin {
onLoad() {
loadedUsers = {};
requestedUsers = {};
this.defaults = {
settings: {
addInUserPopout: {value:true, description:"Add in User Popouts"},
addInUserProfil: {value:true, description:"Add in User Profile Modal"},
displayText: {value:true, description:"Display 'Last message on' text in the timestamp"},
displayTime: {value:true, description:"Display the time in the timestamp"},
displayDate: {value:true, description:"Display the date in the timestamp"},
cutSeconds: {value:false, description:"Cut off seconds of the time"},
forceZeros: {value:false, description:"Force leading zeros"},
otherOrder: {value:false, description:"Show the time before the date"}
},
choices: {
lastMessageDateLang: {value:"$discord", description:"Last Message Date Format"}
},
formats: {
ownFormat: {value:"$hour:$minute:$second, $day.$month.$year", description:"Own Format"}
},
amounts: {
maxDaysAgo: {value:0, min:0, description:"Maximum count of days displayed in the $daysago placeholder", note:"0 equals no limit"}
}
};
this.patchedModules = {
after: {
UserPopout: "render",
AnalyticsContext: "render"
}
};
}
onStart() {
languages = BDFDB.ObjectUtils.deepAssign({
own: {
name: "Own",
@ -251,240 +89,357 @@ var LastMessageDate = (_ => {
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild && e.instance.props.guild.id);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(e.instance, children, 1, children[index].props.user, BDFDB.ReactUtils.findValue(e.instance, "guildId", {up: true}));
return renderedChildren;
};
}
}
injectDate (instance, children, index, user, guildId) {
if (!guildId) guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId();
if (!BDFDB.ArrayUtils.is(children) || !user || user.discriminator == "0000") return;
let isGuild = guildId && guildId != BDFDB.DiscordConstants.ME;
guildId = isGuild ? guildId : BDFDB.LibraryModules.LastChannelStore.getChannelId();
if (!guildId) return;
if (!loadedUsers[guildId]) loadedUsers[guildId] = {};
if (!requestedUsers[guildId]) requestedUsers[guildId] = {};
if (!BDFDB.ArrayUtils.is(requestedUsers[guildId][user.id])) {
requestedUsers[guildId][user.id] = [instance];
BDFDB.LibraryModules.APIUtils.get((isGuild ? BDFDB.DiscordConstants.Endpoints.SEARCH_GUILD(guildId) : BDFDB.DiscordConstants.Endpoints.SEARCH_CHANNEL(guildId)) + "?author_id=" + user.id).then(result => {
if (typeof result.body.retry_after != "number") {
if (result.body.messages && Array.isArray(result.body.messages[0])) {
for (let message of result.body.messages[0]) if (message.hit && message.author.id == user.id) {
loadedUsers[guildId][user.id] = new Date(message.timestamp);
}
}
else loadedUsers[guildId][user.id] = null;
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
}
else {
delete requestedUsers[guildId][user.id];
BDFDB.TimeUtils.timeout(_ => {this.injectDate(instance, children, index, user);}, result.body.retry_after + 500);
}
});
}
else if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
else {
let timestamp = loadedUsers[guildId][user.id] ? this.getTimestamp(languages[choices.lastMessageDateLang].id, loadedUsers[guildId][user.id]) : "---";
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._lastmessagedatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.lastmessage_text.replace("{{time}}", timestamp) : timestamp
}));
}
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
lastmessage_text: "Posljednja poruka dana {{time}}"
};
case "da": //danish
return {
lastmessage_text: "Sidste besked den {{time}}"
};
case "de": //german
return {
lastmessage_text: "Letzte Nachricht am {{time}}"
};
case "es": //spanish
return {
lastmessage_text: "Último mensaje el {{time}}"
};
case "fr": //french
return {
lastmessage_text: "Dernier message le {{time}}"
};
case "it": //italian
return {
lastmessage_text: "Ultimo messaggio il {{time}}"
};
case "nl": //dutch
return {
lastmessage_text: "Laatste bericht op {{time}}"
};
case "no": //norwegian
return {
lastmessage_text: "Siste melding på {{time}}"
};
case "pl": //polish
return {
lastmessage_text: "Ostatnia wiadomość z {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
lastmessage_text: "Última mensagem em {{time}}"
};
case "fi": //finnish
return {
lastmessage_text: "Viimeisin viesti {{time}}"
};
case "sv": //swedish
return {
lastmessage_text: "Senaste meddelandet den {{time}}"
};
case "tr": //turkish
return {
lastmessage_text: "Son mesajı {{time}}"
};
case "cs": //czech
return {
lastmessage_text: "Poslední zpráva dne {{time}}"
};
case "bg": //bulgarian
return {
lastmessage_text: "Последно съобщение на {{time}}"
};
case "ru": //russian
return {
lastmessage_text: "Последнее сообщение {{time}}"
};
case "uk": //ukrainian
return {
lastmessage_text: "Останнє повідомлення {{time}}"
};
case "ja": //japanese
return {
lastmessage_text: "{{time}} 最後のメッセージ"
};
case "zh-TW": //chinese (traditional)
return {
lastmessage_text: "最後消息於 {{time}}"
};
case "ko": //korean
return {
lastmessage_text: "{{time}} 마지막 메시지"
};
default: //default: english
return {
lastmessage_text: "Last message on {{time}}"
};
onStop() {
this.forceUpdateAll();
}
}
}
})();
module.exports = LastMessageDate;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: (value, instance) => {
settings[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Format",
collapseStates: collapseStates,
children: Object.keys(choices).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Select",
plugin: this,
keys: ["choices", key],
label: this.defaults.choices[key].description,
basis: "70%",
value: choices[key],
options: BDFDB.ObjectUtils.toArray(BDFDB.ObjectUtils.map(languages, (lang, id) => {return {value:id, label:lang.name}})),
searchable: true,
optionRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "40%",
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
basis: "60%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
},
valueRenderer: lang => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 0,
shrink: 0,
children: lang.label
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
basis: "70%",
children: this.getTimestamp(languages[lang.value].id)
})
]
});
}
})).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(formats).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["formats", key],
label: this.defaults.formats[key].description,
basis: "70%",
value: formats[key],
onChange: (value, instance) => {
formats[key] = value;
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_SettingsPanel", up:true}), {name:"BDFDB_Select", all:true, noCopies:true}));
}
}))).concat(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
})).concat(Object.keys(amounts).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
childProps: {
type: "number"
},
plugin: this,
keys: ["amounts", key],
label: this.defaults.amounts[key].description,
note: this.defaults.amounts[key].note,
basis: "20%",
min: this.defaults.amounts[key].min,
max: this.defaults.amounts[key].max,
value: amounts[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Placeholder Guide",
collapseStates: collapseStates,
children: [
"$hour will be replaced with the hour of the date",
"$minute will be replaced with the minutes of the date",
"$second will be replaced with the seconds of the date",
"$msecond will be replaced with the milliseconds of the date",
"$timemode will change $hour to a 12h format and will be replaced with AM/PM",
"$year will be replaced with the year of the date",
"$yearS will be replaced with the year in short form",
"$month will be replaced with the month of the date",
"$day will be replaced with the day of the date",
"$monthnameL will be replaced with the monthname in long format based on the Discord Language",
"$monthnameS will be replaced with the monthname in short format based on the Discord Language",
"$weekdayL will be replaced with the weekday in long format based on the Discord Language",
"$weekdayS will be replaced with the weekday in short format based on the Discord Language",
"$daysago will be replaced with a string to tell you how many days ago the event occured. For Example: " + BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", 3)
].map(string => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormText, {
type: BDFDB.LibraryComponents.FormComponents.FormTextTypes.DESCRIPTION,
children: string
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll() {
settings = BDFDB.DataUtils.get(this, "settings");
choices = BDFDB.DataUtils.get(this, "choices");
formats = BDFDB.DataUtils.get(this, "formats");
amounts = BDFDB.DataUtils.get(this, "amounts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "CustomStatus"});
if (index > -1) this.injectDate(e.instance, children, 2, e.instance.props.user, e.instance.props.guild && e.instance.props.guild.id);
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.PROFILE_MODAL && settings.addInUserProfil) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let renderedChildren = renderChildren(...args);
let [children, index] = BDFDB.ReactUtils.findParent(renderedChildren, {name: ["DiscordTag", "ColoredFluxTag"]});
if (index > -1) this.injectDate(e.instance, children, 1, children[index].props.user, BDFDB.ReactUtils.findValue(e.instance, "guildId", {up: true}));
return renderedChildren;
};
}
}
injectDate (instance, children, index, user, guildId) {
if (!guildId) guildId = BDFDB.LibraryModules.LastGuildStore.getGuildId();
if (!BDFDB.ArrayUtils.is(children) || !user || user.discriminator == "0000") return;
let isGuild = guildId && guildId != BDFDB.DiscordConstants.ME;
guildId = isGuild ? guildId : BDFDB.LibraryModules.LastChannelStore.getChannelId();
if (!guildId) return;
if (!loadedUsers[guildId]) loadedUsers[guildId] = {};
if (!requestedUsers[guildId]) requestedUsers[guildId] = {};
if (!BDFDB.ArrayUtils.is(requestedUsers[guildId][user.id])) {
requestedUsers[guildId][user.id] = [instance];
BDFDB.LibraryModules.APIUtils.get((isGuild ? BDFDB.DiscordConstants.Endpoints.SEARCH_GUILD(guildId) : BDFDB.DiscordConstants.Endpoints.SEARCH_CHANNEL(guildId)) + "?author_id=" + user.id).then(result => {
if (typeof result.body.retry_after != "number") {
if (result.body.messages && Array.isArray(result.body.messages[0])) {
for (let message of result.body.messages[0]) if (message.hit && message.author.id == user.id) {
loadedUsers[guildId][user.id] = new Date(message.timestamp);
}
}
else loadedUsers[guildId][user.id] = null;
for (let queredinstance of requestedUsers[guildId][user.id]) BDFDB.ReactUtils.forceUpdate(queredinstance);
}
else {
delete requestedUsers[guildId][user.id];
BDFDB.TimeUtils.timeout(_ => {this.injectDate(instance, children, index, user);}, result.body.retry_after + 500);
}
});
}
else if (loadedUsers[guildId][user.id] === undefined) requestedUsers[guildId][user.id].push(instance);
else {
let timestamp = loadedUsers[guildId][user.id] ? this.getTimestamp(languages[choices.lastMessageDateLang].id, loadedUsers[guildId][user.id]) : "---";
children.splice(index, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
className: BDFDB.disCNS._lastmessagedatedate + BDFDB.disCNS.userinfodate + BDFDB.disCN.textrow,
children: settings.displayText ? this.labels.lastmessage_text.replace("{{time}}", timestamp) : timestamp
}));
}
}
getTimestamp (languageId, time) {
let timeObj = time || new Date();
if (typeof time == "string" || typeof time == "number") timeObj = new Date(time);
if (timeObj.toString() == "Invalid Date") timeObj = new Date(parseInt(time));
if (timeObj.toString() == "Invalid Date") return;
let timeString = "";
if (languageId != "own") {
let timestamp = [];
if (settings.displayDate) timestamp.push(timeObj.toLocaleDateString(languageId));
if (settings.displayTime) timestamp.push(settings.cutSeconds ? this.cutOffSeconds(timeObj.toLocaleTimeString(languageId)) : timeObj.toLocaleTimeString(languageId));
if (settings.otherOrder) timestamp.reverse();
timeString = timestamp.length > 1 ? timestamp.join(", ") : (timestamp.length > 0 ? timestamp[0] : "");
if (timeString && settings.forceZeros) timeString = this.addLeadingZeros(timeString);
}
else {
languageId = BDFDB.LanguageUtils.getLanguage().id;
let now = new Date();
let hour = timeObj.getHours(), minute = timeObj.getMinutes(), second = timeObj.getSeconds(), msecond = timeObj.getMilliseconds(), day = timeObj.getDate(), month = timeObj.getMonth()+1, timemode = "", daysago = Math.round((Date.UTC(now.getFullYear(), now.getMonth(), now.getDate()) - Date.UTC(timeObj.getFullYear(), timeObj.getMonth(), timeObj.getDate()))/(1000*60*60*24));
if (formats.ownFormat.indexOf("$timemode") > -1) {
timemode = hour >= 12 ? "PM" : "AM";
hour = hour % 12;
hour = hour ? hour : 12;
}
timeString = formats.ownFormat
.replace(/\$hour/g, settings.forceZeros && hour < 10 ? "0" + hour : hour)
.replace(/\$minute/g, minute < 10 ? "0" + minute : minute)
.replace(/\$second/g, second < 10 ? "0" + second : second)
.replace(/\$msecond/g, settings.forceZeros ? (msecond < 10 ? "00" + msecond : (msecond < 100 ? "0" + msecond : msecond)) : msecond)
.replace(/\$timemode/g, timemode)
.replace(/\$weekdayL/g, timeObj.toLocaleDateString(languageId, {weekday: "long"}))
.replace(/\$weekdayS/g, timeObj.toLocaleDateString(languageId, {weekday: "short"}))
.replace(/\$monthnameL/g, timeObj.toLocaleDateString(languageId, {month: "long"}))
.replace(/\$monthnameS/g, timeObj.toLocaleDateString(languageId, {month: "short"}))
.replace(/\$daysago/g, amounts.maxDaysAgo == 0 || amounts.maxDaysAgo >= daysago ? (daysago > 0 ? BDFDB.LanguageUtils.LanguageStringsFormat("ACTIVITY_FEED_USER_PLAYED_DAYS_AGO", daysago) : BDFDB.LanguageUtils.LanguageStrings.SEARCH_SHORTCUT_TODAY) : "")
.replace(/\$day/g, settings.forceZeros && day < 10 ? "0" + day : day)
.replace(/\$month/g, settings.forceZeros && month < 10 ? "0" + month : month)
.replace(/\$yearS/g, parseInt(timeObj.getFullYear().toString().slice(-2)))
.replace(/\$year/g, timeObj.getFullYear())
.trim().split(" ").filter(n => n).join(" ");
}
return timeString;
}
cutOffSeconds (timeString) {
return timeString.replace(/(.{1,2}:.{1,2}):.{1,2}(.*)/, "$1$2").replace(/(.{1,2}\..{1,2})\..{1,2}(.*)/, "$1$2").replace(/(.{1,2} h .{1,2} min) .{1,2} s(.*)/, "$1$2");
}
addLeadingZeros (timeString) {
let charArray = timeString.split("");
let numreg = /[0-9]/;
for (let i = 0; i < charArray.length; i++) {
if (!numreg.test(charArray[i-1]) && numreg.test(charArray[i]) && !numreg.test(charArray[i+1])) charArray[i] = "0" + charArray[i];
}
return charArray.join("");
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
lastmessage_text: "Posljednja poruka dana {{time}}"
};
case "da": //danish
return {
lastmessage_text: "Sidste besked den {{time}}"
};
case "de": //german
return {
lastmessage_text: "Letzte Nachricht am {{time}}"
};
case "es": //spanish
return {
lastmessage_text: "Último mensaje el {{time}}"
};
case "fr": //french
return {
lastmessage_text: "Dernier message le {{time}}"
};
case "it": //italian
return {
lastmessage_text: "Ultimo messaggio il {{time}}"
};
case "nl": //dutch
return {
lastmessage_text: "Laatste bericht op {{time}}"
};
case "no": //norwegian
return {
lastmessage_text: "Siste melding på {{time}}"
};
case "pl": //polish
return {
lastmessage_text: "Ostatnia wiadomość z {{time}}"
};
case "pt-BR": //portuguese (brazil)
return {
lastmessage_text: "Última mensagem em {{time}}"
};
case "fi": //finnish
return {
lastmessage_text: "Viimeisin viesti {{time}}"
};
case "sv": //swedish
return {
lastmessage_text: "Senaste meddelandet den {{time}}"
};
case "tr": //turkish
return {
lastmessage_text: "Son mesajı {{time}}"
};
case "cs": //czech
return {
lastmessage_text: "Poslední zpráva dne {{time}}"
};
case "bg": //bulgarian
return {
lastmessage_text: "Последно съобщение на {{time}}"
};
case "ru": //russian
return {
lastmessage_text: "Последнее сообщение {{time}}"
};
case "uk": //ukrainian
return {
lastmessage_text: "Останнє повідомлення {{time}}"
};
case "ja": //japanese
return {
lastmessage_text: "{{time}} 最後のメッセージ"
};
case "zh-TW": //chinese (traditional)
return {
lastmessage_text: "最後消息於 {{time}}"
};
case "ko": //korean
return {
lastmessage_text: "{{time}} 마지막 메시지"
};
default: //default: english
return {
lastmessage_text: "Last message on {{time}}"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,179 +1,76 @@
//META{"name":"MessageUtilities","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/MessageUtilities","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MessageUtilities/MessageUtilities.plugin.js"}*//
var MessageUtilities = (_ => {
var firedEvents = [];
const clickMap = ["CLICK", "DBLCLICK"];
var settings = {}, bindings = {}, toasts = {};
return class MessageUtilities {
getName () {return "MessageUtilities";}
getVersion () {return "1.7.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Offers a number of useful message options. Remap the keybindings in the settings.";}
constructor () {
this.changelog = {
"fixed":[["Mark as Unread","No longer shows key combo hint even if setting is disabled"]]
};
this.patchedModules = {
before: {
Menu: "default"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "MessageUtilities",
"author": "DevilBro",
"version": "1.7.7",
"description": "Offers a number of useful message options. Remap the keybindings in the settings."
}
initConstructor () {
this.defaults = {
settings: {
"addHints": {value:true, description:"Add keycombo hints to contextmenus:"},
"clearOnEscape": {value:true, description:"Clear chat input when Escape is pressed:"}
},
toasts: {},
bindings: {
"Edit_Message": {name:"Edit Message", func:this.doEdit, value:{click:1, keycombo:[]} },
"Delete_Message": {name:"Delete Message", func:this.doDelete, value:{click:0, keycombo:[46]} },
"Pin/Unpin_Message": {name:"Pin/Unpin Message", func:this.doPinUnPin, value:{click:0, keycombo:[17]} },
"React_to_Message": {name:"Open React Menu", func:this.doOpenReact, value:{click:0, keycombo:[17,83]} },
"Copy_Raw": {name:"Copy raw Message", func:this.doCopyRaw, value:{click:0, keycombo:[17,68]} },
"Copy_Link": {name:"Copy Message Link", func:this.doCopyLink, value:{click:0, keycombo:[17,81]} },
"Quote_Message": {name:"Quote Message", func:this.doQuote, value:{click:0, keycombo:[17,87]} },
"__Note_Message": {name:"Note Message", func:this.doNote, value:{click:0, keycombo:[16]}, plugin:"PersonalPins"},
"__Translate_Message": {name:"Translate Message", func:this.doTranslate, value:{click:0, keycombo:[20]}, plugin:"GoogleTranslateOption"},
"__Reveal_Spoilers": {name:"Reveal All Spoilers", func:this.doReveal, value:{click:0, keycombo:[17,74]}, plugin:"RevealAllSpoilersOption"}
}
};
for (let type in this.defaults.bindings) {
let nativeaction = type.indexOf("__") != 0;
this.defaults.settings[type] = {value:nativeaction};
if (nativeaction) this.defaults.toasts[type] = {value:type != "Edit_Message" && type != "React_to_Message" && type != "Quote_Message"};
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let bindings = BDFDB.DataUtils.get(this, "bindings");
let toasts = BDFDB.DataUtils.get(this, "toasts");
let settingsPanel, settingsItems = [];
for (let key in settings) if (this.defaults.settings[key].description) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let action in bindings) if (!this.defaults.bindings[action].plugin || BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom8,
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
label: this.defaults.bindings[action].name + (this.defaults.bindings[action].plugin ? ` (${this.defaults.bindings[action].plugin})` : "")
}),
toasts[action] != undefined ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
mini: true,
plugin: this,
keys: ["toasts", action],
grow: 0,
label: "Toast:",
value: toasts[action]
}) : null
].filter(n => n)
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
dividerbottom: true,
mini: true,
plugin: this,
keys: ["settings", action],
value: settings[action],
labelchildren: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.KeybindRecorder, {
defaultValue: bindings[action].keycombo.filter(n => n),
reset: true,
onChange: keycombo => {
bindings[action].keycombo = keycombo;
BDFDB.DataUtils.save(bindings, this, "bindings");
this.SettingsUpdated = true;
}
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
value: bindings[action].click,
options: clickMap.map((label, i) => {return {value:i, label:label}}),
onChange: choice => {
bindings[action].click = choice.value;
BDFDB.DataUtils.save(bindings, this, "bindings");
this.SettingsUpdated = true;
}
})
]
})
}));
}
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Reset all Key Bindings",
onClick: (e, instance) => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset all Key Bindings?", _ => {
BDFDB.DataUtils.remove(this, "bindings");
settingsPanel.parentElement.appendChild(this.getSettingsPanel());
settingsPanel.remove();
this.SettingsUpdated = true;
});
},
children: BDFDB.LanguageUtils.LanguageStrings.RESET
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
const clickMap = ["CLICK", "DBLCLICK"];
var firedEvents = [];
var settings = {}, bindings = {}, enabledBindings = {}, toasts = {};
return class MessageUtilities extends Plugin {
onLoad() {
this.defaults = {
settings: {
"addHints": {value:true, description:"Add keycombo hints to contextmenus:"},
"clearOnEscape": {value:true, description:"Clear chat input when Escape is pressed:"}
},
toasts: {},
bindings: {
"Edit_Message": {name:"Edit Message", func:this.doEdit, value:{click:1, keycombo:[]} },
"Delete_Message": {name:"Delete Message", func:this.doDelete, value:{click:0, keycombo:[46]} },
"Pin/Unpin_Message": {name:"Pin/Unpin Message", func:this.doPinUnPin, value:{click:0, keycombo:[17]} },
"React_to_Message": {name:"Open React Menu", func:this.doOpenReact, value:{click:0, keycombo:[17,83]} },
"Copy_Raw": {name:"Copy raw Message", func:this.doCopyRaw, value:{click:0, keycombo:[17,68]} },
"Copy_Link": {name:"Copy Message Link", func:this.doCopyLink, value:{click:0, keycombo:[17,81]} },
"Quote_Message": {name:"Quote Message", func:this.doQuote, value:{click:0, keycombo:[17,87]} },
"__Note_Message": {name:"Note Message", func:this.doNote, value:{click:0, keycombo:[16]}, plugin:"PersonalPins"},
"__Translate_Message": {name:"Translate Message", func:this.doTranslate, value:{click:0, keycombo:[20]}, plugin:"GoogleTranslateOption"},
"__Reveal_Spoilers": {name:"Reveal All Spoilers", func:this.doReveal, value:{click:0, keycombo:[17,74]}, plugin:"RevealAllSpoilersOption"}
}
};
this.patchedModules = {
before: {
Menu: "default"
}
};
for (let type in this.defaults.bindings) {
let nativeAction = type.indexOf("__") != 0;
this.defaults.settings[type] = {value: nativeAction};
if (nativeAction) this.defaults.toasts[type] = {value:type != "Edit_Message" && type != "React_to_Message" && type != "Quote_Message"};
}
}
onStart() {
BDFDB.ListenerUtils.add(this, document, "click", BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, e => {
this.onClick(e, 0, "onSglClick");
});
@ -184,234 +81,313 @@ var MessageUtilities = (_ => {
if (BDFDB.DOMUtils.getParent(BDFDB.dotCN.textareawrapchat, document.activeElement)) this.onKeyDown(document.activeElement, e.which, "onKeyDown");
});
this.loadConfig();
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
onStop() {
this.forceUpdateAll();
}
}
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) if (this.defaults.settings[key].description) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}));
for (let action in bindings) if (!this.defaults.bindings[action].plugin || BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom8,
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsLabel, {
label: this.defaults.bindings[action].name + (this.defaults.bindings[action].plugin ? ` (${this.defaults.bindings[action].plugin})` : "")
}),
toasts[action] != undefined ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
mini: true,
plugin: this,
keys: ["toasts", action],
grow: 0,
label: "Toast:",
value: toasts[action]
}) : null
].filter(n => n)
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
dividerbottom: true,
mini: true,
plugin: this,
keys: ["settings", action],
value: settings[action],
labelchildren: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.HORIZONTAL,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.KeybindRecorder, {
defaultValue: enabledBindings[action].keycombo.filter(n => n),
reset: true,
onChange: keycombo => {
enabledBindings[action].keycombo = keycombo;
BDFDB.DataUtils.save(enabledBindings, this, "bindings");
this.SettingsUpdated = true;
}
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Select, {
value: enabledBindings[action].click,
options: clickMap.map((label, i) => {return {value:i, label:label}}),
onChange: choice => {
enabledBindings[action].click = choice.value;
BDFDB.DataUtils.save(enabledBindings, this, "bindings");
this.SettingsUpdated = true;
}
})
]
})
}));
}
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Reset all Key Bindings",
onClick: (e, instance) => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to reset all Key Bindings?", _ => {
BDFDB.DataUtils.remove(this, "bindings");
settingsPanel.parentElement.appendChild(this.getSettingsPanel());
settingsPanel.remove();
this.SettingsUpdated = true;
});
},
children: BDFDB.LanguageUtils.LanguageStrings.RESET
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
//begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
bindings = BDFDB.DataUtils.get(this, "bindings");
enabledBindings = BDFDB.ObjectUtils.filter(bindings, action => settings[action], true);
toasts = BDFDB.DataUtils.get(this, "toasts");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processMenu (e) {
let contextMenu = BDFDB.ReactUtils.findChild(e.instance, {props: "navId"});
if (contextMenu && BDFDB.ArrayUtils.is(contextMenu.props.children)) for (let group of contextMenu.props.children) {
if (group && group.type == BDFDB.LibraryComponents.MenuItems.MenuGroup && BDFDB.ArrayUtils.is(group.props.children)) for (let item of group.props.children) {
if (item && item.props && item.props.id && !item.props.hint && !item.props.children) {
let hint, action;
if (item.props.id == "mark-unread") hint = settings.addHints && `${BDFDB.LibraryModules.KeyCodeUtils.getString(18)}+${clickMap[0]}`;
else {
switch (item.props.id) {
case "copy-link":
action = "Copy_Link";
break;
case "edit":
action = "Edit_Message";
break;
case "pin":
case "unpin":
action = "Pin/Unpin_Message";
break;
case "delete":
action = "Delete_Message";
break;
case "quote":
action = "Quote_Message";
break;
processMenu (e) {
let contextMenu = BDFDB.ReactUtils.findChild(e.instance, {props: "navId"});
if (contextMenu && BDFDB.ArrayUtils.is(contextMenu.props.children)) for (let group of contextMenu.props.children) {
if (group && group.type == BDFDB.LibraryComponents.MenuItems.MenuGroup && BDFDB.ArrayUtils.is(group.props.children)) for (let item of group.props.children) {
if (item && item.props && item.props.id && !item.props.hint && !item.props.children) {
let hint, action;
if (item.props.id == "mark-unread") hint = settings.addHints && `${BDFDB.LibraryModules.KeyCodeUtils.getString(18)}+${clickMap[0]}`;
else {
switch (item.props.id) {
case "copy-link":
action = "Copy_Link";
break;
case "edit":
action = "Edit_Message";
break;
case "pin":
case "unpin":
action = "Pin/Unpin_Message";
break;
case "delete":
action = "Delete_Message";
break;
case "quote":
action = "Quote_Message";
break;
}
if (action) hint = this.getActiveShortcutString(action);
}
if (action) hint = this.getActiveShortcutString(action);
if (hint) item.props.hint = _ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
};
}
if (hint) item.props.hint = _ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
};
}
}
}
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.loadConfig();
}
}
loadConfig () {
settings = BDFDB.DataUtils.get(this, "settings");
bindings = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "bindings"), action => settings[action], true);
toasts = BDFDB.DataUtils.get(this, "toasts");
}
onClick (e, click, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
let priorityAction = null;
for (let action in bindings) {
let binding = bindings[action];
let priorityBinding = bindings[priorityAction];
if (this.checkIfBindingIsValid(binding, click) && (!bindings[priorityAction] || binding.click > priorityBinding.click || binding.keycombo.length > priorityBinding.keycombo.length)) priorityAction = action;
}
if (priorityAction) {
let {messageDiv, message} = this.getMessageData(e.currentTarget);
if (messageDiv && message) {
BDFDB.ListenerUtils.stopEvent(e);
BDFDB.TimeUtils.clear(this.clickTimeout);
if (!this.hasDoubleClickOverwrite(bindings[priorityAction])) {
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
onClick (e, click, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
let priorityAction = null;
for (let action in enabledBindings) {
let binding = enabledBindings[action];
let priorityBinding = enabledBindings[priorityAction];
if (this.checkIfBindingIsValid(binding, click) && (!enabledBindings[priorityAction] || binding.click > priorityBinding.click || binding.keycombo.length > priorityBinding.keycombo.length)) priorityAction = action;
}
if (priorityAction) {
let {messageDiv, message} = this.getMessageData(e.currentTarget);
if (messageDiv && message) {
BDFDB.ListenerUtils.stopEvent(e);
BDFDB.TimeUtils.clear(this.clickTimeout);
if (!this.hasDoubleClickOverwrite(enabledBindings[priorityAction])) {
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
}
else this.clickTimeout = BDFDB.TimeUtils.timeout(_ => {
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
}, 500);
}
else this.clickTimeout = BDFDB.TimeUtils.timeout(_ => {
this.defaults.bindings[priorityAction].func.apply(this, [{messageDiv, message}, priorityAction]);
}, 500);
}
}
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
}
}
checkIfBindingIsValid (binding, doneclick) {
if (binding.click != doneclick) return false;
for (let key of binding.keycombo) if (!BDFDB.InternalData.pressedKeys.includes(key)) return false;
return true;
}
hasDoubleClickOverwrite (binding) {
if (binding.click == 1) return false;
let dblBindings = BDFDB.ObjectUtils.filter(bindings, bndg => {return bndg.click == 1});
for (let dblAction in dblBindings) {
let dblBinding = dblBindings[dblAction];
let overwrite = true;
if (BDFDB.equals(binding.keycombo, dblBinding.keycombo)) return true;
}
return false;
}
doDelete ({messageDiv, message}, action) {
let deleteLink = messageDiv.parentElement.querySelector(BDFDB.dotCNS.messagelocalbotoperations + BDFDB.dotCN.anchor);
if (deleteLink) deleteLink.click();
else {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if ((channel && BDFDB.UserUtils.can("MANAGE_MESSAGES")) || message.author.id == BDFDB.UserUtils.me.id && message.type != 1 && message.type != 2 && message.type != 3) {
BDFDB.LibraryModules.MessageUtils.deleteMessage(message.channel_id, message.id, message.state != "SENT");
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been deleted.", {type:"success"});
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
}
}
}
doEdit ({messageDiv, message}, action) {
if (message.author.id == BDFDB.UserUtils.me.id && !messageDiv.querySelector("textarea")) {
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
if (toasts[action]) BDFDB.NotificationUtils.toast("Started editing.", {type:"success"});
checkIfBindingIsValid (binding, doneclick) {
if (binding.click != doneclick) return false;
for (let key of binding.keycombo) if (!BDFDB.ListenerUtils.isPressed(key)) return false;
return true;
}
}
doOpenReact ({messageDiv, message}, action) {
let reactButton = messageDiv.querySelector(`${BDFDB.dotCN.messagetoolbarbutton}[aria-label="${BDFDB.LanguageUtils.LanguageStrings.ADD_REACTION}"]`);
if (reactButton) {
reactButton.click();
if (toasts[action]) BDFDB.NotificationUtils.toast("Reaction popout has been opened.", {type:"success"});
hasDoubleClickOverwrite (binding) {
if (binding.click == 1) return false;
let dblBindings = BDFDB.ObjectUtils.filter(enabledBindings, bndg => {return bndg.click == 1});
for (let dblAction in dblBindings) {
let dblBinding = dblBindings[dblAction];
let overwrite = true;
if (BDFDB.equals(binding.keycombo, dblBinding.keycombo)) return true;
}
return false;
}
}
doPinUnPin ({messageDiv, message}, action) {
if (message.state == "SENT") {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && (channel.type == 1 || channel.type == 3 || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && message.type == 0) {
if (message.pinned) {
BDFDB.LibraryModules.MessagePinUtils.unpinMessage(channel, message.id);
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been unpinned.", {type:"error"});
}
else {
BDFDB.LibraryModules.MessagePinUtils.pinMessage(channel, message.id);
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been pinned.", {type:"success"});
doDelete ({messageDiv, message}, action) {
let deleteLink = messageDiv.parentElement.querySelector(BDFDB.dotCNS.messagelocalbotoperations + BDFDB.dotCN.anchor);
if (deleteLink) deleteLink.click();
else {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if ((channel && BDFDB.UserUtils.can("MANAGE_MESSAGES")) || message.author.id == BDFDB.UserUtils.me.id && message.type != 1 && message.type != 2 && message.type != 3) {
BDFDB.LibraryModules.MessageUtils.deleteMessage(message.channel_id, message.id, message.state != "SENT");
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been deleted.", {type:"success"});
}
}
}
}
doCopyRaw ({messageDiv, message}, action) {
if (message.content) {
BDFDB.LibraryRequires.electron.clipboard.write({text:message.content});
if (toasts[action]) BDFDB.NotificationUtils.toast("Raw message content has been copied.", {type:"success"});
doEdit ({messageDiv, message}, action) {
if (message.author.id == BDFDB.UserUtils.me.id && !messageDiv.querySelector("textarea")) {
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
if (toasts[action]) BDFDB.NotificationUtils.toast("Started editing.", {type:"success"});
}
}
}
doCopyLink ({messageDiv, message}, action) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) {
BDFDB.LibraryModules.MessageManageUtils.copyLink(channel, message);
if (toasts[action]) BDFDB.NotificationUtils.toast("Messagelink has been copied.", {type:"success"});
doOpenReact ({messageDiv, message}, action) {
let reactButton = messageDiv.querySelector(`${BDFDB.dotCN.messagetoolbarbutton}[aria-label="${BDFDB.LanguageUtils.LanguageStrings.ADD_REACTION}"]`);
if (reactButton) {
reactButton.click();
if (toasts[action]) BDFDB.NotificationUtils.toast("Reaction popout has been opened.", {type:"success"});
}
}
}
doQuote ({messageDiv, message}, action) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && BDFDB.LibraryModules.QuoteUtils.canQuote(message, channel)) {
BDFDB.LibraryModules.MessageManageUtils.quoteMessage(channel, message);
if (toasts[action]) BDFDB.NotificationUtils.toast("Quote has been created.", {type:"success"});
}
}
doNote ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, channel);
}
}
doTranslate ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel);
}
}
doReveal ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv);
}
}
onKeyDown (target, key, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
if (key == 27 && settings.clearOnEscape) {
let chatform = BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, target);
if (chatform) {
let instance = BDFDB.ReactUtils.findOwner(chatform, {name:"ChannelTextAreaForm"}) || BDFDB.ReactUtils.findOwner(chatform, {name:"ChannelTextAreaForm", up:true});
if (instance) instance.setState({textValue:"", richValue:BDFDB.LibraryModules.SlateUtils.deserialize("")});
doPinUnPin ({messageDiv, message}, action) {
if (message.state == "SENT") {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && (channel.type == 1 || channel.type == 3 || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && message.type == 0) {
if (message.pinned) {
BDFDB.LibraryModules.MessagePinUtils.unpinMessage(channel, message.id);
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been unpinned.", {type:"error"});
}
else {
BDFDB.LibraryModules.MessagePinUtils.pinMessage(channel, message.id);
if (toasts[action]) BDFDB.NotificationUtils.toast("Message has been pinned.", {type:"success"});
}
}
}
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
}
}
getActiveShortcutString (action) {
if (!action) return null;
let str = [];
if (settings.addHints && settings[action] && bindings[action]) {
if (bindings[action].keycombo.length) str.push(BDFDB.LibraryModules.KeyCodeUtils.getString(bindings[action].keycombo));
str.push(clickMap[bindings[action].click]);
doCopyRaw ({messageDiv, message}, action) {
if (message.content) {
BDFDB.LibraryRequires.electron.clipboard.write({text:message.content});
if (toasts[action]) BDFDB.NotificationUtils.toast("Raw message content has been copied.", {type:"success"});
}
}
return str.join("+").replace(/ /g, "");
}
getMessageData (target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, target);
if (messageDiv && messageDiv.querySelector(BDFDB.dotCN.textarea)) return {messageDiv: null, message: null};
let instance = BDFDB.ReactUtils.getInstance(messageDiv);
let message = instance && BDFDB.ReactUtils.findValue(instance, "message");
return {messageDiv, message};
}
}
})();
doCopyLink ({messageDiv, message}, action) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) {
BDFDB.LibraryModules.MessageManageUtils.copyLink(channel, message);
if (toasts[action]) BDFDB.NotificationUtils.toast("Messagelink has been copied.", {type:"success"});
}
}
module.exports = MessageUtilities;
doQuote ({messageDiv, message}, action) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && BDFDB.LibraryModules.QuoteUtils.canQuote(message, channel)) {
BDFDB.LibraryModules.MessageManageUtils.quoteMessage(channel, message);
if (toasts[action]) BDFDB.NotificationUtils.toast("Quote has been created.", {type:"success"});
}
}
doNote ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, channel);
}
}
doTranslate ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, channel);
}
}
doReveal ({messageDiv, message}, action) {
if (BDFDB.BDUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
BDFDB.BDUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messageDiv);
}
}
onKeyDown (target, key, name) {
if (!firedEvents.includes(name)) {
firedEvents.push(name);
if (key == 27 && settings.clearOnEscape) {
let chatform = BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, target);
if (chatform) {
let instance = BDFDB.ReactUtils.findOwner(chatform, {name:"ChannelTextAreaForm"}) || BDFDB.ReactUtils.findOwner(chatform, {name:"ChannelTextAreaForm", up:true});
if (instance) instance.setState({textValue:"", richValue:BDFDB.LibraryModules.SlateUtils.deserialize("")});
}
}
BDFDB.TimeUtils.timeout(_ => {BDFDB.ArrayUtils.remove(firedEvents, name, true)});
}
}
getActiveShortcutString (action) {
if (!action) return null;
let str = [];
if (settings.addHints && settings[action] && enabledBindings[action]) {
if (enabledBindings[action].keycombo.length) str.push(BDFDB.LibraryModules.KeyCodeUtils.getString(enabledBindings[action].keycombo));
str.push(clickMap[enabledBindings[action].click]);
}
return str.join("+").replace(/ /g, "");
}
getMessageData (target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCNC.message + BDFDB.dotCN.searchresultsgroupcozy, target);
if (messageDiv && messageDiv.querySelector(BDFDB.dotCN.textarea)) return {messageDiv: null, message: null};
let instance = BDFDB.ReactUtils.getInstance(messageDiv);
let message = instance && BDFDB.ReactUtils.findValue(instance, "message");
return {messageDiv, message};
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,79 +0,0 @@
//META{"name":"MoveablePopups","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/MoveablePopups","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MoveablePopups/MoveablePopups.plugin.js"}*//
var MoveablePopups = (_ => {
return class MoveablePopups {
getName () {return "MoveablePopups";}
getVersion () {return "1.1.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "DISCONTINUED";}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.ModalUtils.open(this, {
header: this.name,
subheader: "Delete?",
text: `This plugin is discontinued, click "${BDFDB.LanguageUtils.LanguageStrings.DELETE}" to delete all remaining files created by this plugin.`,
buttons: [{
color: "RED",
contents: BDFDB.LanguageUtils.LanguageStrings.DELETE,
close: true,
click: _ => {
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), `${this.name}.config.json`), _ => {});
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), `${this.name}.plugin.js`), _ => {});
}
}],
onClose: _ => {
BDFDB.BDUtils.disablePlugin(this.name);
}
});
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
}
})();
module.exports = MoveablePopups;

View File

@ -1,12 +0,0 @@
# Moveable Popups - [![Downlad][download-badge]][download-link] [![Paypal][paypal-badge]][paypal-link] [![Patreon][patreon-badge]][patreon-link]
[download-badge]: https://img.shields.io/badge/Download-Plugin-brightgreen.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADGGlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjaY2BgnuDo4uTKJMDAUFBUUuQe5BgZERmlwH6egY2BmYGBgYGBITG5uMAxIMCHgYGBIS8/L5UBFTAyMHy7xsDIwMDAcFnX0cXJlYE0wJpcUFTCwMBwgIGBwSgltTiZgYHhCwMDQ3p5SUEJAwNjDAMDg0hSdkEJAwNjAQMDg0h2SJAzAwNjCwMDE09JakUJAwMDg3N+QWVRZnpGiYKhpaWlgmNKflKqQnBlcUlqbrGCZ15yflFBflFiSWoKAwMD1A4GBgYGXpf8EgX3xMw8BSMDVQYqg4jIKAUICxE+CDEESC4tKoMHJQODAIMCgwGDA0MAQyJDPcMChqMMbxjFGV0YSxlXMN5jEmMKYprAdIFZmDmSeSHzGxZLlg6WW6x6rK2s99gs2aaxfWMPZ9/NocTRxfGFM5HzApcj1xZuTe4FPFI8U3mFeCfxCfNN45fhXyygI7BD0FXwilCq0A/hXhEVkb2i4aJfxCaJG4lfkaiQlJM8JpUvLS19QqZMVl32llyfvIv8H4WtioVKekpvldeqFKiaqP5UO6jepRGqqaT5QeuA9iSdVF0rPUG9V/pHDBYY1hrFGNuayJsym740u2C+02KJ5QSrOutcmzjbQDtXe2sHY0cdJzVnJRcFV3k3BXdlD3VPXS8Tbxsfd99gvwT//ID6wIlBS4N3hVwMfRnOFCEXaRUVEV0RMzN2T9yDBLZE3aSw5IaUNak30zkyLDIzs+ZmX8xlz7PPryjYVPiuWLskq3RV2ZsK/cqSql01jLVedVPrHzbqNdU0n22VaytsP9op3VXUfbpXta+x/+5Em0mzJ/+dGj/t8AyNmf2zvs9JmHt6vvmCpYtEFrcu+bYsc/m9lSGrTq9xWbtvveWGbZtMNm/ZarJt+w6rnft3u+45uy9s/4ODOYd+Hmk/Jn58xUnrU+fOJJ/9dX7SRe1LR68kXv13fc5Nm1t379TfU75/4mHeY7En+59lvhB5efB1/lv5dxc+NH0y/fzq64Lv4T8Ffp360/rP8f9/AA0ADzT6lvFdAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAF1SURBVHja7JihTgNBEIb/K1WkBtEEAsESBKEvgEKRAhLHOxAMfQ9cHwEMBoFA1/ACBEGgzbkmUAwI+BENubTs9WZmLz1CZtZd9v7/u9vMZGdAGFabA05Hn3sWrYQwRB9rwafreikbQN5LiV6qhorDARzAARzAARzAARzAARzAARygGOAQ6a+GLr9jmlwpDuJbsxQrER+YYrXaI2D8EZyAEfangj2Fq0NrnBWry8YI5yb7rkRbBrDAK7X9NevlAYCL7Kns79iQKcunOU0+iO0fuSzV1QyUNjkU2b9wS66qm2nt8L3Q/oO7Gk3tWO2InzPtv3isU9RP9jqxmR8LMKsqdPVqFoC8qiDM/HiAcFUQZ34IYDr0VUGW+QEfK8BkVZBmfqkAWVWQZ37JAOA+n/nEtnh/wGd8JWP81Nt0P0r8Wu4ADvAHAOq2fsaP4N8BvFXi/ZoB3FYCcJMNKDbQw9Kc7YdoYfDzB+6xjUuM5mY+wsXYHvgeABIzsPkSOM/lAAAAAElFTkSuQmCC&style=flat
[download-link]: https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MoveablePopups/MoveablePopups.plugin.js
[paypal-badge]: https://img.shields.io/badge/Paypal-Donate!-%23003087.svg?logo=paypal&style=flat
[paypal-link]: https://paypal.me/MircoWittrien
[patreon-badge]: https://img.shields.io/badge/Patreon-Support!-%23F96854.svg?logo=patreon&style=flat
[patreon-link]: https://patreon.com/MircoWittrien
Adds the feature to move all popups and modals around like on a normal desktop. Ctrl + drag with your left mousebutton to drag element.

File diff suppressed because it is too large Load Diff

View File

@ -1,161 +1,114 @@
//META{"name":"OldTitleBar","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/OldTitleBar","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/OldTitleBar/OldTitleBar.plugin.js"}*//
var OldTitleBar = (_ => {
var patched, electronWindow;
var settings = {};
return class OldTitleBar {
getName () {return "OldTitleBar";}
getVersion () {return "1.6.7";}
getAuthor () {return "DevilBro";}
getDescription () {return "Reverts the title bar back to its former self.";}
constructor () {
this.patchedModules = {
after: {
App: "render",
AppSkeleton: "render",
HeaderBarContainer: "render",
StandardSidebarView: "render",
AuthWrapper: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "OldTitleBar",
"author": "DevilBro",
"version": "1.6.7",
"description": "Reverts the title bar back to its former self."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var patched, electronWindow;
var settings = {};
return class OldTitleBar extends Plugin {
onLoad() {
patched = false;
initConstructor () {
patched = false;
electronWindow = BDFDB.LibraryRequires.electron.remote.getCurrentWindow();
electronWindow = BDFDB.LibraryRequires.electron.remote.getCurrentWindow();
this.defaults = {
settings: {
displayNative: {value:!!document.querySelector(".platform-linux"), description:"Displays the native Title Bar."},
addOldBar: {value:true, description:"Displays the Title Bar in the old fashion."},
addToSettings: {value:true, description:"Adds a Title Bar to Settings Windows."},
reloadButton: {value:false, description:"Adds a Reload Button to the Title Bar."}
}
};
this.css = `
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.titlebar},
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.splashbackground}:before {
display: none !important;
}
this.patchedModules = {
after: {
App: "render",
AppSkeleton: "render",
HeaderBarContainer: "render",
StandardSidebarView: "render",
AuthWrapper: "render"
}
};
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.guildswrapper} {
margin-top: 0;
padding-top: 0;
}
this.css = `
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.titlebar},
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.splashbackground}:before {
display: none !important;
}
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.guildswrapper} {
margin-top: 0;
padding-top: 0;
}
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.guildsscroller} {
padding-top: 4px;
}
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.settingswindowstandardsidebarview}:before {
display: none;
}
${BDFDB.dotCN._oldtitlebartoolbar} {
flex: 1 1 auto;
justify-content: flex-end;
}
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.guildsscroller} {
padding-top: 4px;
}
.platform-osx ${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCN.settingswindowstandardsidebarview}:before {
display: none;
}
${BDFDB.dotCN._oldtitlebartoolbar} {
flex: 1 1 auto;
justify-content: flex-end;
}
${BDFDB.dotCN._oldtitlebarsettingstoolbar} {
position: absolute;
top: 0;
right: 0;
padding: 10px;
z-index: 2;
-webkit-app-region: drag !important;
}
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCNS.splashbackground + BDFDB.dotCN._oldtitlebarsettingstoolbar} {
background: rgba(0, 0, 0, 0.3);
border-radius: 0 0 0 5px;
}
${BDFDB.dotCN._oldtitlebarsettingstoolbar} {
position: absolute;
top: 0;
right: 0;
padding: 10px;
z-index: 2;
-webkit-app-region: drag !important;
}
${BDFDB.dotCNS._oldtitlebarenabled + BDFDB.dotCNS.splashbackground + BDFDB.dotCN._oldtitlebarsettingstoolbar} {
background: rgba(0, 0, 0, 0.3);
border-radius: 0 0 0 5px;
}
${BDFDB.dotCN.channelheaderheaderbar} {
-webkit-app-region: drag !important;
}
${BDFDB.dotCN.channelheaderheaderbar} {
-webkit-app-region: drag !important;
}
${BDFDB.dotCNS.stopanimations + BDFDB.dotCN.channelheaderheaderbar},
${BDFDB.dotCN.channelheaderheaderbar} * {
-webkit-app-region: no-drag !important;
}`;
this.defaults = {
settings: {
displayNative: {value:!!document.querySelector(".platform-linux"), description:"Displays the native Title Bar."},
addOldBar: {value:true, description:"Displays the Title Bar in the old fashion."},
addToSettings: {value:true, description:"Adds a Title Bar to Settings Windows."},
reloadButton: {value:false, description:"Adds a Reload Button to the Title Bar."}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [];
let isLinux = !!document.querySelector(".platform-linux");
for (let key in settings) {
let isNativeTitlebarSetting = key == "displayNative";
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: isLinux && isNativeTitlebarSetting || settings[key],
disabled: isLinux && isNativeTitlebarSetting,
note: isLinux && isNativeTitlebarSetting && "This is disabled on Linux, because Discord/BD forces the titlebar on Linux systems!",
onChange: isNativeTitlebarSetting ? value => {
if (this.patchMainScreen(value)) {
patched = !patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (patched) {
notifybar = BDFDB.NotificationUtils.notice("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", _ => {
BDFDB.LibraryRequires.electron.remote.app.relaunch();
BDFDB.LibraryRequires.electron.remote.app.quit();
});
}
}
} : null
}));
${BDFDB.dotCNS.stopanimations + BDFDB.dotCN.channelheaderheaderbar},
${BDFDB.dotCN.channelheaderheaderbar} * {
-webkit-app-region: no-drag !important;
}
`;
}
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onStart() {
BDFDB.ListenerUtils.add(this, window, "resize", e => {
BDFDB.PatchUtils.forceAllUpdates(this, ["HeaderBarContainer", "StandardSidebarView"]);
});
@ -166,147 +119,168 @@ var OldTitleBar = (_ => {
this.patchMainScreen(settings.displayNative);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
this.forceUpdateAll();
BDFDB.ReactUtils.forceUpdate(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"App"}));
BDFDB.DOMUtils.removeClassFromDOM(BDFDB.disCN._oldtitlebarenabled);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
let isLinux = !!document.querySelector(".platform-linux");
for (let key in settings) {
let isNativeTitlebarSetting = key == "displayNative";
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: isLinux && isNativeTitlebarSetting || settings[key],
disabled: isLinux && isNativeTitlebarSetting,
note: isLinux && isNativeTitlebarSetting && "This is disabled on Linux, because Discord/BD forces the titlebar on Linux systems!",
onChange: isNativeTitlebarSetting ? value => {
if (this.patchMainScreen(value)) {
patched = !patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (patched) {
notifybar = BDFDB.NotificationUtils.notice("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", _ => {
BDFDB.LibraryRequires.electron.remote.app.relaunch();
BDFDB.LibraryRequires.electron.remote.app.quit();
});
}
}
} : null
}));
}
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
}
processApp (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {props:[["type",["WINDOWS", "MACOS"]]]});
if (index > -1) children[index] = null;
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
processAppSkeleton (e) {
this.processApp(e);
}
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
}
processHeaderBarContainer (e) {
if (!settings.addOldBar) return;
let children = BDFDB.ObjectUtils.get(e.returnvalue, "props.toolbar.props.children");
if (!children) {
let [oldToolbarParent, oldToolbarIndex] = BDFDB.ReactUtils.findParent(e.returnvalue, {key: "OldTitleBar-toolbar"});
if (oldToolbarIndex > -1) oldToolbarParent.splice(oldToolbarIndex, 1);
processApp (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {props:[["type",["WINDOWS", "MACOS"]]]});
if (index > -1) children[index] = null;
}
processAppSkeleton (e) {
this.processApp(e);
}
processHeaderBarContainer (e) {
if (!settings.addOldBar) return;
let children = BDFDB.ObjectUtils.get(e.returnvalue, "props.toolbar.props.children");
if (!children) {
let [oldToolbarParent, oldToolbarIndex] = BDFDB.ReactUtils.findParent(e.returnvalue, {key: "OldTitleBar-toolbar"});
if (oldToolbarIndex > -1) oldToolbarParent.splice(oldToolbarIndex, 1);
let toolbar = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.channelheadertoolbar + BDFDB.disCN._oldtitlebartoolbar,
key: "OldTitleBar-toolbar",
children: []
});
e.returnvalue.props.children.push(toolbar);
children = toolbar.props.children;
}
this.injectButtons(children, true);
}
processStandardSidebarView (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children);
}
processAuthWrapper (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children, true);
}
injectSettingsToolbar (children, fixed) {
if (!settings.addToSettings) return;
let toolbar = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.channelheadertoolbar + BDFDB.disCN._oldtitlebartoolbar,
key: "OldTitleBar-toolbar",
children: []
className: BDFDB.disCNS.channelheadertoolbar + BDFDB.disCN._oldtitlebarsettingstoolbar,
children: [],
style: fixed ? {position: "fixed"} : null
});
e.returnvalue.props.children.push(toolbar);
children = toolbar.props.children;
this.injectButtons(toolbar.props.children);
children.push(toolbar);
}
this.injectButtons(children, true);
}
processStandardSidebarView (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children);
}
processAuthWrapper (e) {
if (!BDFDB.ArrayUtils.is(e.returnvalue.props.children)) e.returnvalue.props.children = [e.returnvalue.props.children];
this.injectSettingsToolbar(e.returnvalue.props.children, true);
}
injectSettingsToolbar (children, fixed) {
if (!settings.addToSettings) return;
let toolbar = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.channelheadertoolbar + BDFDB.disCN._oldtitlebarsettingstoolbar,
children: [],
style: fixed ? {position: "fixed"} : null
});
this.injectButtons(toolbar.props.children);
children.push(toolbar);
}
injectButtons (children, addFirstDivider) {
if (addFirstDivider) children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}))
if (settings.reloadButton) {
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.ERRORS_RELOAD,
tooltipConfig: {type: "bottom"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.reload();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg><path fill="currentColor" stroke="none" transform="translate(3,4)" d="M 17.061, 7.467 V 0 l -2.507, 2.507 C 13.013, 0.96, 10.885, 0, 8.528, 0 C 3.813, 0, 0.005, 3.819, 0.005, 8.533 s 3.808, 8.533, 8.523, 8.533 c 3.973, 0, 7.301 -2.72, 8.245 -6.4 h -2.219 c -0.88, 2.485 -3.237, 4.267 -6.027, 4.267 c -3.536, 0 -6.4 -2.864 -6.4 -6.4 s 2.864 -6.4, 6.4 -6.4 c 1.765, 0, 3.349, 0.736, 4.507, 1.893 l -3.44, 3.44 H 17.061 z"/></svg>`
injectButtons (children, addFirstDivider) {
if (addFirstDivider) children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}))
if (settings.reloadButton) {
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.ERRORS_RELOAD,
tooltipConfig: {type: "bottom"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.reload();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg><path fill="currentColor" stroke="none" transform="translate(3,4)" d="M 17.061, 7.467 V 0 l -2.507, 2.507 C 13.013, 0.96, 10.885, 0, 8.528, 0 C 3.813, 0, 0.005, 3.819, 0.005, 8.533 s 3.808, 8.533, 8.523, 8.533 c 3.973, 0, 7.301 -2.72, 8.245 -6.4 h -2.219 c -0.88, 2.485 -3.237, 4.267 -6.027, 4.267 c -3.536, 0 -6.4 -2.864 -6.4 -6.4 s 2.864 -6.4, 6.4 -6.4 c 1.765, 0, 3.349, 0.736, 4.507, 1.893 l -3.44, 3.44 H 17.061 z"/></svg>`
})
})
}));
children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}));
};
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.minimize();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 18 l13 0"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement("div", {className: BDFDB.disCN.channelheaderdivider}));
};
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.minimize();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 18 l13 0"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {
if (electronWindow.isMaximized()) electronWindow.unmaximize();
else electronWindow.maximize();
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: electronWindow.isMaximized() ? `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/></svg>` : `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.close();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 13 m0 -13 l-13 13"/></svg>`
})
}));
}
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {
if (electronWindow.isMaximized()) electronWindow.unmaximize();
else electronWindow.maximize();
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: electronWindow.isMaximized() ? `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 9 l10 0 l0 10 l-10 0 l0 -10 m3 -3 l10 0 l0 10"/></svg>` : `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 0 l0 13 l-13 0 l0 -13"/></svg>`
})
}));
children.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCNS.channelheadericonwrapper + BDFDB.disCN.channelheadericonclickable,
onClick: _ => {electronWindow.close();},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.channelheadericon,
iconSVG: `<svg width="26" height="26"><path stroke-width="2" stroke="currentColor" fill="none" d="M6 6 l13 13 m0 -13 l-13 13"/></svg>`
})
}));
}
patchMainScreen (enable) {
try {
if (BdApi.getWindowPreference("frame") != enable) {
BdApi.setWindowPreference("frame", enable);
return true;
patchMainScreen (enable) {
try {
if (BdApi.getWindowPreference("frame") != enable) {
BdApi.setWindowPreference("frame", enable);
return true;
}
return false;
}
catch (err) {
return false;
}
return false;
}
catch (err) {
return false;
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
}
}
})();
module.exports = OldTitleBar;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,437 +1,407 @@
//META{"name":"OwnerTag","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/OwnerTag","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/OwnerTag/OwnerTag.plugin.js"}*//
var OwnerTag = (_ => {
const userTypes = {
NONE: 0,
MANAGEMENT: 1,
ADMIN: 2,
OWNER: 3
module.exports = (_ => {
const config = {
"info": {
"name": "OwnerTag",
"author": "DevilBro",
"version": "1.3.3",
"description": "Adds a tag or crown to the server owner (or admins/management)."
}
};
var settings = {}, inputs = {};
return class OwnerTag {
getName () {return "OwnerTag";}
getVersion () {return "1.3.3";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a tag or crown to the server owner (or admins/management).";}
constructor () {
this.changelog = {
"added":[["Management Crown/Tag","Added a third tag for people with the server/channel/role management permission"]],
"improved":[["Management Tag","Tag now shows for all kinds of management perms and the type of management is displayed in the tooltip"]]
};
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default",
NameTag: "default",
UserPopout: "render"
}
};
}
initConstructor () {
this.css = `
${BDFDB.dotCN.memberownericon + BDFDB.dotCN._ownertagadminicon} {
color: #c0c0c0;
}
${BDFDB.dotCN.memberownericon + BDFDB.dotCN._ownertagmanagementicon} {
color: #ef7f32;
}
${BDFDB.dotCNS.message + BDFDB.dotCN.memberownericon} {
top: 2px;
}
${BDFDB.dotCNS.userprofile + BDFDB.dotCN.memberownericon} {
top: 0px;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCN.memberownericon} {
margin-right: .25rem;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCN.messageusername} + ${BDFDB.dotCN.memberownericon} {
margin-left: 0;
}
`;
this.defaults = {
settings: {
addInChatWindow: {value:true, inner:true, description:"Messages"},
addInMemberList: {value:true, inner:true, description:"Member List"},
addInUserPopout: {value:true, inner:true, description:"User Popouts"},
addInUserProfile: {value:true, inner:true, description:"User Profile Modal"},
useRoleColor: {value:true, inner:false, description:"Use the Rolecolor instead of the default blue"},
useBlackFont: {value:false, inner:false, description:"Instead of darkening the Rolecolor on bright colors use black font"},
useCrown: {value:false, inner:false, description:"Use the Crown Icon instead of the Bot Tag Style"},
hideNativeCrown: {value:true, inner:false, description:"Hide the native Crown Icon (not the Plugin one)"},
addForAdmins: {value:false, inner:false, description:"Add an Admin Tag for users with admin permissions"},
addForManagement: {value:false, inner:false, description:"Add a Management Tag for users with management permissions"},
ignoreBotAdmins: {value:false, inner:false, description:"Do not add the Admin/Management tag for bots"}
},
inputs: {
ownTagName: {value:"Owner", description:"Tag Text for Owners"},
ownAdminTagName: {value:"Admin", description:"Tag Text for Admins"},
ownManagementTagName: {value:"Management", description:"Tag Text for Management"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
settings = BDFDB.DataUtils.get(this, "settings");
inputs = BDFDB.DataUtils.get(this, "inputs");
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings).map(key => !this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
key: key,
disabled: key == "hideNativeCrown" && settings.useCrown,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: key == "useCrown" ? (value, instance) => {
let hideNativeCrownInstance = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key: "hideNativeCrown"});
if (hideNativeCrownInstance) {
hideNativeCrownInstance.props.disabled = value;
BDFDB.ReactUtils.forceUpdate(hideNativeCrownInstance);
}
} : null
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Tag Settings",
collapseStates: collapseStates,
children: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
className: BDFDB.disCN.marginbottom4,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
children: "Add Tags in:"
})].concat(Object.keys(settings).map(key => this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Tag Text Settings",
collapseStates: collapseStates,
children: Object.keys(inputs).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["inputs", key],
label: this.defaults.inputs[key].description,
basis: "50%",
value: inputs[key]
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processMemberListItem (e) {
let userType = this.getUserType(e.instance.props.user, e.instance.props.channel && e.instance.props.channel.id);
if (userType && settings.addInMemberList) {
this.injectOwnerTag(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, userType, 1, {
tagClass: BDFDB.disCN.bottagmember
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
const userTypes = {
NONE: 0,
MANAGEMENT: 1,
ADMIN: 2,
OWNER: 3
};
var settings = {}, inputs = {};
return class OwnerTag extends Plugin {
onLoad() {
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default",
NameTag: "default",
UserPopout: "render"
}
};
this.defaults = {
settings: {
addInChatWindow: {value:true, inner:true, description:"Messages"},
addInMemberList: {value:true, inner:true, description:"Member List"},
addInUserPopout: {value:true, inner:true, description:"User Popouts"},
addInUserProfile: {value:true, inner:true, description:"User Profile Modal"},
useRoleColor: {value:true, inner:false, description:"Use the Rolecolor instead of the default blue"},
useBlackFont: {value:false, inner:false, description:"Instead of darkening the Rolecolor on bright colors use black font"},
useCrown: {value:false, inner:false, description:"Use the Crown Icon instead of the Bot Tag Style"},
hideNativeCrown: {value:true, inner:false, description:"Hide the native Crown Icon (not the Plugin one)"},
addForAdmins: {value:false, inner:false, description:"Add an Admin Tag for users with admin permissions"},
addForManagement: {value:false, inner:false, description:"Add a Management Tag for users with management permissions"},
ignoreBotAdmins: {value:false, inner:false, description:"Do not add the Admin/Management tag for bots"}
},
inputs: {
ownTagName: {value:"Owner", description:"Tag Text for Owners"},
ownAdminTagName: {value:"Admin", description:"Tag Text for Admins"},
ownManagementTagName: {value:"Management", description:"Tag Text for Management"}
}
};
this.css = `
${BDFDB.dotCN.memberownericon + BDFDB.dotCN._ownertagadminicon} {
color: #c0c0c0;
}
${BDFDB.dotCN.memberownericon + BDFDB.dotCN._ownertagmanagementicon} {
color: #ef7f32;
}
${BDFDB.dotCNS.message + BDFDB.dotCN.memberownericon} {
top: 2px;
}
${BDFDB.dotCNS.userprofile + BDFDB.dotCN.memberownericon} {
top: 0px;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCN.memberownericon} {
margin-right: .25rem;
}
${BDFDB.dotCNS.messagecozy + BDFDB.dotCN.messageusername} + ${BDFDB.dotCN.memberownericon} {
margin-left: 0;
}
`;
}
onStart() {
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
processMessageHeader (e) {
if (e.instance.props.message && settings.addInChatWindow) {
let userType = this.getUserType(e.instance.props.message.author, e.instance.props.message.channel_id);
if (userType) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) this.injectOwnerTag(children, e.instance.props.message.author, userType, e.instance.props.compact ? 0 : 2, {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Settings",
collapseStates: collapseStates,
children: Object.keys(settings).map(key => !this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
key: key,
disabled: key == "hideNativeCrown" && settings.useCrown,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
onChange: key == "useCrown" ? (value, instance) => {
let hideNativeCrownInstance = BDFDB.ReactUtils.findOwner(instance._reactInternalFiber.return, {key: "hideNativeCrown"});
if (hideNativeCrownInstance) {
hideNativeCrownInstance.props.disabled = value;
BDFDB.ReactUtils.forceUpdate(hideNativeCrownInstance);
}
} : null
}))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Tag Settings",
collapseStates: collapseStates,
children: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
className: BDFDB.disCN.marginbottom4,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
children: "Add Tags in:"
})].concat(Object.keys(settings).map(key => this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
})))
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
title: "Tag Text Settings",
collapseStates: collapseStates,
children: Object.keys(inputs).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "TextInput",
plugin: this,
keys: ["inputs", key],
label: this.defaults.inputs[key].description,
basis: "50%",
value: inputs[key]
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
inputs = BDFDB.DataUtils.get(this, "inputs");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
processMemberListItem (e) {
let userType = this.getUserType(e.instance.props.user, e.instance.props.channel && e.instance.props.channel.id);
if (userType && settings.addInMemberList) {
this.injectOwnerTag(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, userType, 1, {
tagClass: BDFDB.disCN.bottagmember
});
}
}
}
processNameTag (e) {
if (e.instance.props.user && e.instance.props.className) {
let userType = this.getUserType(e.instance.props.user);
if (userType) {
let inject = false, tagClass = "";
switch (e.instance.props.className) {
case BDFDB.disCN.userpopoutheadertagnonickname:
inject = settings.addInUserPopout;
tagClass = BDFDB.disCN.bottagnametag;
processMessageHeader (e) {
if (e.instance.props.message && settings.addInChatWindow) {
let userType = this.getUserType(e.instance.props.message.author, e.instance.props.message.channel_id);
if (userType) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) this.injectOwnerTag(children, e.instance.props.message.author, userType, e.instance.props.compact ? 0 : 2, {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
});
}
}
}
processNameTag (e) {
if (e.instance.props.user && e.instance.props.className) {
let userType = this.getUserType(e.instance.props.user);
if (userType) {
let inject = false, tagClass = "";
switch (e.instance.props.className) {
case BDFDB.disCN.userpopoutheadertagnonickname:
inject = settings.addInUserPopout;
tagClass = BDFDB.disCN.bottagnametag;
break;
case BDFDB.disCN.userprofilenametag:
inject = settings.addInUserProfile;
tagClass = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag;
break;
}
if (inject) this.injectOwnerTag(e.returnvalue.props.children, e.instance.props.user, userType, 2, {
tagClass: tagClass,
useRem: e.instance.props.useRemSizes,
inverted: e.instance.props.invertBotTagColor
});
}
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let userType = this.getUserType(e.instance.props.user, e.instance.props.channel && e.instance.props.channel.id);
if (userType) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutheadertagwithnickname]]});
if (index > -1) this.injectOwnerTag(children, e.instance.props.user, userType, 2, {
tagClass: BDFDB.disCNS.userpopoutheaderbottagwithnickname + BDFDB.disCN.bottagnametag,
inverted: typeof e.instance.getMode == "function" && e.instance.getMode() !== "Normal"
});
}
}
}
injectOwnerTag (children, user, userType, insertIndex, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
if (settings.useCrown || settings.hideNativeCrown) {
let [_, index] = BDFDB.ReactUtils.findParent(children, {props: [["text",[BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER, BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER]]]});
if (index > -1) children[index] = null;
}
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
let member = settings.useRoleColor ? (BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, user.id) || {}) : {};
let tag = null;
if (settings.useCrown) {
let label, className;
switch (userType) {
case userTypes.OWNER:
label = channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER;
className = BDFDB.disCN._ownertagownericon;
break;
case BDFDB.disCN.userprofilenametag:
inject = settings.addInUserProfile;
tagClass = BDFDB.disCNS.userprofilebottag + BDFDB.disCN.bottagnametag;
case userTypes.ADMIN:
label = BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR;
className = BDFDB.disCN._ownertagadminicon;
break;
case userTypes.MANAGEMENT:
label = `${this.labels.management_text} (${[BDFDB.UserUtils.can("MANAGE_GUILD", user.id) && BDFDB.LanguageUtils.LibraryStrings.server, BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) && BDFDB.LanguageUtils.LanguageStrings.CHANNELS, BDFDB.UserUtils.can("MANAGE_ROLES", user.id) && BDFDB.LanguageUtils.LanguageStrings.ROLES].filter(n => n).join(", ")})`;
className = BDFDB.disCN._ownertagmanagementicon;
break;
}
if (inject) this.injectOwnerTag(e.returnvalue.props.children, e.instance.props.user, userType, 2, {
tagClass: tagClass,
useRem: e.instance.props.useRemSizes,
inverted: e.instance.props.invertBotTagColor
tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: label,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.memberownericon, className),
name: BDFDB.LibraryComponents.SvgIcon.Names.CROWN,
"aria-label": label
})
});
}
}
}
processUserPopout (e) {
if (e.instance.props.user && settings.addInUserPopout) {
let userType = this.getUserType(e.instance.props.user, e.instance.props.channel && e.instance.props.channel.id);
if (userType) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutheadertagwithnickname]]});
if (index > -1) this.injectOwnerTag(children, e.instance.props.user, userType, 2, {
tagClass: BDFDB.disCNS.userpopoutheaderbottagwithnickname + BDFDB.disCN.bottagnametag,
inverted: typeof e.instance.getMode == "function" && e.instance.getMode() !== "Normal"
else {
let input, label;
switch (userType) {
case userTypes.OWNER:
input = "ownTagName";
break;
case userTypes.ADMIN:
input = "ownAdminTagName";
break;
case userTypes.MANAGEMENT:
input = "ownManagementTagName";
label = [BDFDB.UserUtils.can("MANAGE_GUILD", user.id) && BDFDB.LanguageUtils.LibraryStrings.server, BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) && BDFDB.LanguageUtils.LanguageStrings.CHANNELS, BDFDB.UserUtils.can("MANAGE_ROLES", user.id) && BDFDB.LanguageUtils.LanguageStrings.ROLES].filter(n => n).join(", ");
break;
}
let tagColor = BDFDB.ColorUtils.convert(member.colorString, "RGBA");
let isBright = BDFDB.ColorUtils.isBright(tagColor);
tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor;
tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, {
className: config.tagClass,
useRemSizes: config.useRem,
invertColor: config.inverted,
style: {
backgroundColor: config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor,
color: !config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor
},
tag: inputs[input]
});
if (label) tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: label,
children: tag
});
}
children.splice(insertIndex, 0, tag);
}
}
injectOwnerTag (children, user, userType, insertIndex, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
if (settings.useCrown || settings.hideNativeCrown) {
let [_, index] = BDFDB.ReactUtils.findParent(children, {props: [["text",[BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER, BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER]]]});
if (index > -1) children[index] = null;
}
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
let member = settings.useRoleColor ? (BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, user.id) || {}) : {};
let tag = null;
if (settings.useCrown) {
let label, className;
switch (userType) {
case userTypes.OWNER:
label = channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER;
className = BDFDB.disCN._ownertagownericon;
break;
case userTypes.ADMIN:
label = BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR;
className = BDFDB.disCN._ownertagadminicon;
break;
case userTypes.MANAGEMENT:
label = `${this.labels.management_text} (${[BDFDB.UserUtils.can("MANAGE_GUILD", user.id) && BDFDB.LanguageUtils.LibraryStrings.server, BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) && BDFDB.LanguageUtils.LanguageStrings.CHANNELS, BDFDB.UserUtils.can("MANAGE_ROLES", user.id) && BDFDB.LanguageUtils.LanguageStrings.ROLES].filter(n => n).join(", ")})`;
className = BDFDB.disCN._ownertagmanagementicon;
break;
}
tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: label,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.memberownericon, className),
name: BDFDB.LibraryComponents.SvgIcon.Names.CROWN,
"aria-label": label
})
});
}
else {
let input, label;
switch (userType) {
case userTypes.OWNER:
input = "ownTagName";
break;
case userTypes.ADMIN:
input = "ownAdminTagName";
break;
case userTypes.MANAGEMENT:
input = "ownManagementTagName";
label = [BDFDB.UserUtils.can("MANAGE_GUILD", user.id) && BDFDB.LanguageUtils.LibraryStrings.server, BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) && BDFDB.LanguageUtils.LanguageStrings.CHANNELS, BDFDB.UserUtils.can("MANAGE_ROLES", user.id) && BDFDB.LanguageUtils.LanguageStrings.ROLES].filter(n => n).join(", ");
break;
}
let tagColor = BDFDB.ColorUtils.convert(member.colorString, "RGBA");
let isBright = BDFDB.ColorUtils.isBright(tagColor);
tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor;
tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, {
className: config.tagClass,
useRemSizes: config.useRem,
invertColor: config.inverted,
style: {
backgroundColor: config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor,
color: !config.inverted ? (isBright && settings.useBlackFont ? "black" : null) : tagColor
},
tag: inputs[input]
});
if (label) tag = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: label,
children: tag
});
}
children.splice(insertIndex, 0, tag);
}
getUserType (user, channelId) {
if (!user) return userTypes.NONE;
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId || BDFDB.LibraryModules.LastChannelStore.getChannelId());
if (!channel) return userTypes.NONE;
let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id);
let isOwner = channel.ownerId == user.id || guild && guild.ownerId == user.id;
if (isOwner) return userTypes.OWNER;
else if (settings.addForAdmins && BDFDB.UserUtils.can("ADMINISTRATOR", user.id) && !(settings.ignoreBotAdmins && user.bot)) return userTypes.ADMIN;
else if (settings.addForManagement && (BDFDB.UserUtils.can("MANAGE_GUILD", user.id) || BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) || BDFDB.UserUtils.can("MANAGE_ROLES", user.id)) && !(settings.ignoreBotAdmins && user.bot)) return userTypes.MANAGEMENT;
return userTypes.NONE;
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
inputs = BDFDB.DataUtils.get(this, "inputs");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
management_text: "Upravljanje"
};
case "da": //danish
return {
management_text: "Ledelse"
};
case "de": //german
return {
management_text: "Verwaltung"
};
case "es": //spanish
return {
management_text: "Administración"
};
case "fr": //french
return {
management_text: "Gestion"
};
case "it": //italian
return {
management_text: "Gestione"
};
case "nl": //dutch
return {
management_text: "Beheer"
};
case "no": //norwegian
return {
management_text: "Ledelse"
};
case "pl": //polish
return {
management_text: "Zarządzanie"
};
case "pt-BR": //portuguese (brazil)
return {
management_text: "Gestão"
};
case "fi": //finnish
return {
management_text: "Johto"
};
case "sv": //swedish
return {
management_text: "Förvaltning"
};
case "tr": //turkish
return {
management_text: "Yönetim"
};
case "cs": //czech
return {
management_text: "Řízení"
};
case "bg": //bulgarian
return {
management_text: "Управление"
};
case "ru": //russian
return {
management_text: "Управление"
};
case "uk": //ukrainian
return {
management_text: "Управління"
};
case "ja": //japanese
return {
management_text: "管理"
};
case "zh-TW": //chinese (traditional)
return {
management_text: "管理"
};
case "ko": //korean
return {
management_text: "관리"
};
default: //default: english
return {
management_text: "Management"
};
getUserType (user, channelId) {
if (!user) return userTypes.NONE;
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(channelId || BDFDB.LibraryModules.LastChannelStore.getChannelId());
if (!channel) return userTypes.NONE;
let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id);
let isOwner = channel.ownerId == user.id || guild && guild.ownerId == user.id;
if (isOwner) return userTypes.OWNER;
else if (settings.addForAdmins && BDFDB.UserUtils.can("ADMINISTRATOR", user.id) && !(settings.ignoreBotAdmins && user.bot)) return userTypes.ADMIN;
else if (settings.addForManagement && (BDFDB.UserUtils.can("MANAGE_GUILD", user.id) || BDFDB.UserUtils.can("MANAGE_CHANNELS", user.id) || BDFDB.UserUtils.can("MANAGE_ROLES", user.id)) && !(settings.ignoreBotAdmins && user.bot)) return userTypes.MANAGEMENT;
return userTypes.NONE;
}
}
}
})();
module.exports = OwnerTag;
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
management_text: "Upravljanje"
};
case "da": //danish
return {
management_text: "Ledelse"
};
case "de": //german
return {
management_text: "Verwaltung"
};
case "es": //spanish
return {
management_text: "Administración"
};
case "fr": //french
return {
management_text: "Gestion"
};
case "it": //italian
return {
management_text: "Gestione"
};
case "nl": //dutch
return {
management_text: "Beheer"
};
case "no": //norwegian
return {
management_text: "Ledelse"
};
case "pl": //polish
return {
management_text: "Zarządzanie"
};
case "pt-BR": //portuguese (brazil)
return {
management_text: "Gestão"
};
case "fi": //finnish
return {
management_text: "Johto"
};
case "sv": //swedish
return {
management_text: "Förvaltning"
};
case "tr": //turkish
return {
management_text: "Yönetim"
};
case "cs": //czech
return {
management_text: "Řízení"
};
case "bg": //bulgarian
return {
management_text: "Управление"
};
case "ru": //russian
return {
management_text: "Управление"
};
case "uk": //ukrainian
return {
management_text: "Управління"
};
case "ja": //japanese
return {
management_text: "管理"
};
case "zh-TW": //chinese (traditional)
return {
management_text: "管理"
};
case "ko": //korean
return {
management_text: "관리"
};
default: //default: english
return {
management_text: "Management"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,138 +0,0 @@
https://raw.githubusercontent.com/An00nymushun/DiscordFreeEmojis/master/DiscordFreeEmojis.plugin.js
https://raw.githubusercontent.com/An00nymushun/DiscordMyTyping/master/MyTyping.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/Miscellanious/jsMaterialThemeCodeblocks.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/ChatUserIDsRedux/ChatUserIDsRedux.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/HideServersChannelsRedux/HideServersChannelsRedux.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/HideUtils/HideUtils.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/LineNumbersRedux/LineNumbersRedux.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/MemberCount/MemberCount.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/MessageTimestampsRedux/MessageTimestampsRedux.plugin.js
https://raw.githubusercontent.com/Arashiryuu/crap/master/ToastIntegrated/TitleForTitlebar/TitleForTitlebar.plugin.js
https://raw.githubusercontent.com/Curtis-D/ChannelPopouts/master/ChannelPopouts.plugin.js
https://raw.githubusercontent.com/Egrodo/DiscordPlugins/master/GameActivityToggle.plugin.js
https://raw.githubusercontent.com/hammy1/BDStuff/master/Plugins/dateViewer/dateViewer.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/AvatarHover.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/channelHistory.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/directDownload.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/discordexperiments.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/linkProfilePicture.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/localFileServer.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/minimizeShortcut.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/MultiInstance.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/scrollToLast.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/Snowfall.plugin.js
https://raw.githubusercontent.com/Inve1951/BetterDiscordStuff/master/plugins/toggleYourStuff.plugin.js
https://raw.githubusercontent.com/l0c4lh057/BetterDiscordStuff/master/Plugins/ChannelTabs/ChannelTabs.plugin.js
https://raw.githubusercontent.com/l0c4lh057/BetterDiscordStuff/master/Plugins/Minespoiler/Minespoiler.plugin.js
https://raw.githubusercontent.com/l0c4lh057/BetterDiscordStuff/master/Plugins/TypingIndicator/TypingIndicator.plugin.js
https://raw.githubusercontent.com/leogx9r/DiscordCrypt/master/build/discordCrypt.plugin.js
https://raw.githubusercontent.com/Mega-Mewthree/BetterDiscordPlugins/master/Plugins/AlwaysMentionEveryone/AlwaysMentionEveryone.plugin.js
https://raw.githubusercontent.com/Mega-Mewthree/BetterDiscordPlugins/master/Plugins/AutoStartRichPresence/AutoStartRichPresence.plugin.js
https://raw.githubusercontent.com/Mega-Mewthree/BetterDiscordPlugins/master/Plugins/ColorSighted/ColorSighted.plugin.js
https://raw.githubusercontent.com/Mega-Mewthree/BetterDiscordPlugins/master/Plugins/DiscordCakeDay/DiscordCakeDay.plugin.js
https://raw.githubusercontent.com/Mega-Mewthree/BetterDiscordPlugins/master/Plugins/MobileForAll/MobileForAll.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/AvatarIconViewer.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/BetterEmoteSizes.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/CustomizableAvatarDPI.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/DetailedServerTooltips.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/DoubleClickVoiceChannels.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/GuildAndFriendRemovalAlerts.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/GuildCounter.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/OpenLinksInDiscord.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/PinCollapsedChannels.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/ReactionImages.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/ShareButton.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/TransitioningBackgrounds.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/UserBirthdays.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/ViewGuildRelationships.plugin.js
https://raw.githubusercontent.com/Metalloriff/BetterDiscordPlugins/master/VoiceChatNotifications.plugin.js
https://raw.githubusercontent.com/MKSx/Send-Audio-Plugin-BetterDiscord/master/SendAudio.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BadgesEverywhere/BadgesEverywhere.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterFriendList/BetterFriendList.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterNsfwTag/BetterNsfwTag.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/BetterSearchPage/BetterSearchPage.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CharCounter/CharCounter.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ChatAliases/ChatAliases.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ChatFilter/ChatFilter.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CompleteTimestamps/CompleteTimestamps.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CopyRawMessage/CopyRawMessage.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CreationDate/CreationDate.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/CustomQuoter/CustomQuoter.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/DisplayLargeMessages/DisplayLargeMessages.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/DisplayServersAsChannels/DisplayServersAsChannels.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditChannels/EditChannels.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditServers/EditServers.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditUsers/EditUsers.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EmojiStatistics/EmojiStatistics.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ForceImagePreviews/ForceImagePreviews.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/GoogleSearchReplace/GoogleSearchReplace.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/GoogleTranslateOption/GoogleTranslateOption.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/HideMutedCategories/HideMutedCategories.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ImageUtilities/ImageUtilities.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/JoinedAtDate/JoinedAtDate.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/LastMessageDate/LastMessageDate.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/MessageUtilities/MessageUtilities.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/NotificationSounds/NotificationSounds.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/OldTitleBar/OldTitleBar.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/OwnerTag/OwnerTag.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PersonalPins/PersonalPins.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PinDMs/PinDMs.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PluginRepo/PluginRepo.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/QuickMention/QuickMention.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RemoveNicknames/RemoveNicknames.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SendLargeMessages/SendLargeMessages.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerCounter/ServerCounter.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerDetails/ServerDetails.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerFolders/ServerFolders.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerHider/ServerHider.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpellCheck/SpellCheck.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpotifyControls/SpotifyControls.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SteamProfileLink/SteamProfileLink.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ThemeRepo/ThemeRepo.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ThemeSettings/ThemeSettings.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/WriteUpperCase/WriteUpperCase.plugin.js
https://raw.githubusercontent.com/noodlebox/betterdiscord-plugins/master/SilentTyping.plugin.js
https://raw.githubusercontent.com/noodlebox/betterdiscord-plugins/master/StaticAvatars.plugin.js
https://raw.githubusercontent.com/Orrielel/BetterDiscordAddons/master/Plugins/BetterImagePopups/BetterImagePopups.plugin.js
https://raw.githubusercontent.com/planetarian/BetterDiscordPlugins/master/DefaultChannels.plugin.js
https://raw.githubusercontent.com/planetarian/BetterDiscordPlugins/master/Zalgo.plugin.js
https://raw.githubusercontent.com/qwerasd205/qwerasd205.github.io/master/EditUploads.plugin.js
https://raw.githubusercontent.com/qwerasd205/qwerasd205.github.io/master/ExtendedContextMenu.plugin.js
https://raw.githubusercontent.com/qwerasd205/qwerasd205.github.io/master/WordNotifications.plugin.js
https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/AccountDetailsPlus/AccountDetailsPlus.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/AutoPlayGifs/AutoPlayGifs.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BDContextMenu/BDContextMenu.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BetterFormattingRedux/BetterFormattingRedux.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BetterRoleColors/BetterRoleColors.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/BlurNSFW/BlurNSFW.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/DoNotTrack/DoNotTrack.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/EmojiUtilities/EmojiUtilities.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/HideDisabledEmojis/HideDisabledEmojis.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/HideMutedServers/HideMutedServers.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/HideIconBadge/HideIconBadge.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/ImageToClipboard/ImageToClipboard.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/PermissionsViewer/PermissionsViewer.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/ResizableCSS/ResizableCSS.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/RemoveMinimumSize/RemoveMinimumSize.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/RoleMembers/RoleMembers.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/SendButton/SendButton.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/ServerSearch/ServerSearch.plugin.js
https://raw.githubusercontent.com/rauenzi/BetterDiscordAddons/master/Plugins/StatusEverywhere/StatusEverywhere.plugin.js
https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/LinkChannels/LinkChannels.plugin.js
https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/OpenSpotifylinksInSpotify/OpenSpotifylinksInSpotify.plugin.js
https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/QuickMuteChannels/QuickMuteChannels.plugin.js
https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/ShowAllActivities/ShowAllActivities.plugin.js
https://raw.githubusercontent.com/Strencher/BetterDiscordStuff/master/VoiceUsersCounter/VoiceUsersCounter.plugin.js
https://raw.githubusercontent.com/Zerthox/BetterDiscord-Plugins/master/v1/BetterFolders.plugin.js
https://raw.githubusercontent.com/Zerthox/BetterDiscord-Plugins/master/v1/BetterReplyer.plugin.js
https://raw.githubusercontent.com/Zerthox/BetterDiscord-Plugins/master/v1/Emulator.plugin.js
https://raw.githubusercontent.com/Zerthox/BetterDiscord-Plugins/master/v1/OnlineFriendCount.plugin.js
https://raw.githubusercontent.com/Zerthox/BetterDiscord-Plugins/master/v1/VoiceEvents.plugin.js

View File

@ -1,88 +1,62 @@
//META{"name":"QuickMention","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/QuickMention","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/QuickMention/QuickMention.plugin.js"}*//
var QuickMention = (_ => {
return class QuickMention {
getName () {return "QuickMention";}
getVersion () {return "1.0.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a mention entry to the message option toolbar.";}
constructor () {
this.changelog = {
"fixed":[["DMs","Works again in DMs"]]
};
module.exports = (_ => {
const config = {
"info": {
"name": "QuickMention",
"author": "DevilBro",
"version": "1.0.1",
"description": "Adds a mention entry to the message option toolbar."
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
}
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
// Begin of own functions
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class QuickMention extends Plugin {
onLoad() {}
onStart() {}
onStop() {}
onMessageOptionToolbar (e) {
if (e.instance.props.message.author.id != BDFDB.UserUtils.me.id && e.instance.props.message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT && (BDFDB.UserUtils.can("SEND_MESSAGES") || e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.DM || e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM)) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "mention",
text: BDFDB.LanguageUtils.LanguageStrings.MENTION,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
BDFDB.LibraryModules.DispatchUtils.ComponentDispatch.dispatchToLastSubscribed(BDFDB.DiscordConstants.ComponentActions.INSERT_TEXT, {
content: `<@!${e.instance.props.message.author.id}>`
});
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
nativeClass: true,
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_AT
onMessageOptionToolbar (e) {
if (e.instance.props.message.author.id != BDFDB.UserUtils.me.id && e.instance.props.message.type == BDFDB.DiscordConstants.MessageTypes.DEFAULT && (BDFDB.UserUtils.can("SEND_MESSAGES") || e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.DM || e.instance.props.channel.type == BDFDB.DiscordConstants.ChannelTypes.GROUP_DM)) e.returnvalue.props.children.unshift(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
key: "mention",
text: BDFDB.LanguageUtils.LanguageStrings.MENTION,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.messagetoolbarbutton,
onClick: _ => {
BDFDB.LibraryModules.DispatchUtils.ComponentDispatch.dispatchToLastSubscribed(BDFDB.DiscordConstants.ComponentActions.INSERT_TEXT, {
content: `<@!${e.instance.props.message.author.id}>`
});
},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCNS.messagetoolbaricon,
nativeClass: true,
name: BDFDB.LibraryComponents.SvgIcon.Names.NOVA_AT
})
})
})
}));
}
}
})();
module.exports = QuickMention;
}));
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,97 +1,76 @@
//META{"name":"RemoveBlockedMessages","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveBlockedMessages","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RemoveBlockedMessages/RemoveBlockedMessages.plugin.js"}*//
var RemoveBlockedMessages = (_ => {
return class RemoveBlockedMessages {
getName () {return "RemoveBlockedMessages";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Completely removes blocked messages.";}
module.exports = (_ => {
const config = {
"info": {
"name": "RemoveBlockedMessages",
"author": "DevilBro",
"version": "1.0.5",
"description": "Completely removes blocked messages."
},
"changeLog": {
"fixed": {
"Date Deviders": "No longer shows date deviders of blocked messages"
}
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
constructor () {
this.changelog = {
"fixed":[["Date Deviders","No longer shows date deviders of blocked messages"]]
};
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class RemoveBlockedMessages extends Plugin {
onLoad() {
this.patchedModules = {
after: {
Messages: "type"
}
};
}
this.patchedModules = {
after: {
Messages: "type"
}
};
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onStart() {
BDFDB.MessageUtils.rerenderAll();
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.MessageUtils.rerenderAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processMessages (e) {
let messagesIns = e.returnvalue.props.children;
if (BDFDB.ArrayUtils.is(messagesIns.props.channelStream)) {
let oldStream = messagesIns.props.channelStream.filter(n => n.type != "MESSAGE_GROUP_BLOCKED"), newChannelStream = [];
for (let i in oldStream) {
let next = parseInt(i)+1;
if (oldStream[i].type != "DIVIDER" || (oldStream[next] && oldStream[i].type == "DIVIDER" && oldStream[next].type != "DIVIDER" && oldStream.slice(next).some(nextStream => nextStream.type != "DIVIDER"))) newChannelStream.push(oldStream[i]);
processMessages (e) {
let messagesIns = e.returnvalue.props.children;
if (BDFDB.ArrayUtils.is(messagesIns.props.channelStream)) {
let oldStream = messagesIns.props.channelStream.filter(n => n.type != "MESSAGE_GROUP_BLOCKED"), newChannelStream = [];
for (let i in oldStream) {
let next = parseInt(i)+1;
if (oldStream[i].type != "DIVIDER" || (oldStream[next] && oldStream[i].type == "DIVIDER" && oldStream[next].type != "DIVIDER" && oldStream.slice(next).some(nextStream => nextStream.type != "DIVIDER"))) newChannelStream.push(oldStream[i]);
}
messagesIns.props.channelStream = newChannelStream;
}
if (BDFDB.ObjectUtils.is(messagesIns.props.messages) && BDFDB.ArrayUtils.is(messagesIns.props.messages._array)) {
let messages = messagesIns.props.messages;
messagesIns.props.messages = new BDFDB.DiscordObjects.Messages(messages);
for (let key in messages) messagesIns.props.messages[key] = messages[key];
messagesIns.props.messages._array = [].concat(messagesIns.props.messages._array.filter(n => n.author && !BDFDB.LibraryModules.FriendUtils.isBlocked(n.author.id)));
if (messagesIns.props.oldestUnreadMessageId && messagesIns.props.messages._array.every(n => n.id != messagesIns.props.oldestUnreadMessageId)) messagesIns.props.oldestUnreadMessageId = null;
}
messagesIns.props.channelStream = newChannelStream;
}
if (BDFDB.ObjectUtils.is(messagesIns.props.messages) && BDFDB.ArrayUtils.is(messagesIns.props.messages._array)) {
let messages = messagesIns.props.messages;
messagesIns.props.messages = new BDFDB.DiscordObjects.Messages(messages);
for (let key in messages) messagesIns.props.messages[key] = messages[key];
messagesIns.props.messages._array = [].concat(messagesIns.props.messages._array.filter(n => n.author && !BDFDB.LibraryModules.FriendUtils.isBlocked(n.author.id)));
if (messagesIns.props.oldestUnreadMessageId && messagesIns.props.messages._array.every(n => n.id != messagesIns.props.oldestUnreadMessageId)) messagesIns.props.oldestUnreadMessageId = null;
}
}
}
})();
module.exports = RemoveBlockedMessages;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,208 +1,179 @@
//META{"name":"RemoveNicknames","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RemoveNicknames","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RemoveNicknames/RemoveNicknames.plugin.js"}*//
var RemoveNicknames = (_ => {
var settings = {};
module.exports = (_ => {
const config = {
"info": {
"name": "RemoveNicknames",
"author": "DevilBro",
"version": "1.3.0",
"description": "Replace all nicknames with the actual accountnames."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {};
return class RemoveNicknames {
getName () {return "RemoveNicknames";}
getVersion () {return "1.3.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Replace all nicknames with the actual accountnames.";}
constructor () {
this.changelog = {
"fixed":[["Typing List","Works now"]]
};
this.patchedModules = {
before: {
AutocompleteUserResult: "render",
VoiceUser: "render",
MemberListItem: "render",
Message: "default",
MessageContent: "type",
},
after: {
TypingUsers: "render"
}
};
}
initConstructor () {
this.defaults = {
settings: {
replaceOwn: {value:false, inner:false, description:"Replace your own name:"},
replaceBots: {value:true, inner:false, description:"Replace the nickname of bots:"},
addNickname: {value:false, inner:false, description:"Add nickname as parentheses:"},
swapPositions: {value:false, inner:false, description:"Swap the position of username and nickname:"},
changeInChatWindow: {value:true, inner:true, description:"Messages"},
changeInMentions: {value:true, inner:true, description:"Mentions"},
changeInVoiceChat: {value:true, inner:true, description:"Voice Channels"},
changeInMemberList: {value:true, inner:true, description:"Member List"},
changeInTyping: {value:true, inner:true, description:"Typing List"},
changeInAutoComplete: {value:true, inner:true, description:"Autocomplete Menu"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [], innerItems = [];
return class RemoveNicknames extends Plugin {
onLoad() {
this.defaults = {
settings: {
replaceOwn: {value:false, inner:false, description:"Replace your own name:"},
replaceBots: {value:true, inner:false, description:"Replace the nickname of bots:"},
addNickname: {value:false, inner:false, description:"Add nickname as parentheses:"},
swapPositions: {value:false, inner:false, description:"Swap the position of username and nickname:"},
changeInChatWindow: {value:true, inner:true, description:"Messages"},
changeInMentions: {value:true, inner:true, description:"Mentions"},
changeInVoiceChat: {value:true, inner:true, description:"Voice Channels"},
changeInMemberList: {value:true, inner:true, description:"Member List"},
changeInTyping: {value:true, inner:true, description:"Typing List"},
changeInAutoComplete: {value:true, inner:true, description:"Autocomplete Menu"}
}
};
for (let key in settings) (!this.defaults.settings[key].inner ? settingsItems : innerItems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Remove Nicknames in:",
first: settingsItems.length == 0,
last: true,
children: innerItems
}));
this.patchedModules = {
before: {
AutocompleteUserResult: "render",
VoiceUser: "render",
MemberListItem: "render",
Message: "default",
MessageContent: "type",
},
after: {
TypingUsers: "render"
}
};
}
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onStart() {
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [], innerItems = [];
this.forceUpdateAll();
for (let key in settings) (!this.defaults.settings[key].inner ? settingsItems : innerItems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Remove Nicknames in:",
first: settingsItems.length == 0,
last: true,
children: innerItems
}));
BDFDB.PluginUtils.clear(this);
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
}
// Begin of own functions
onSettingsClosed (e) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
onSettingsClosed (e) {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
}
processAutocompleteUserResult (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInAutoComplete) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
processVoiceUser (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInVoiceChat) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
processAutocompleteUserResult (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInAutoComplete) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
}
}
}
processMemberListItem (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInMemberList) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
processVoiceUser (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInVoiceChat) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
}
}
}
processTypingUsers (e) {
if (BDFDB.ObjectUtils.is(e.instance.props.typingUsers) && Object.keys(e.instance.props.typingUsers).length && settings.changeInTyping) {
let users = Object.keys(e.instance.props.typingUsers).filter(id => id != BDFDB.UserUtils.me.id).filter(id => !BDFDB.LibraryModules.FriendUtils.isBlocked(id)).map(id => BDFDB.LibraryModules.UserStore.getUser(id)).filter(user => user);
if (users.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.typingtext]]});
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) if (child.type == "strong") {
let newName = this.getNewName(users.shift());
if (newName) BDFDB.ReactUtils.setChild(child, newName);
processMemberListItem (e) {
if (e.instance.props.user && e.instance.props.nick && settings.changeInMemberList) {
let newName = this.getNewName(e.instance.props.user);
if (newName) e.instance.props.nick = newName;
}
}
processTypingUsers (e) {
if (BDFDB.ObjectUtils.is(e.instance.props.typingUsers) && Object.keys(e.instance.props.typingUsers).length && settings.changeInTyping) {
let users = Object.keys(e.instance.props.typingUsers).filter(id => id != BDFDB.UserUtils.me.id).filter(id => !BDFDB.LibraryModules.FriendUtils.isBlocked(id)).map(id => BDFDB.LibraryModules.UserStore.getUser(id)).filter(user => user);
if (users.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.typingtext]]});
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) for (let child of children[index].props.children) if (child.type == "strong") {
let newName = this.getNewName(users.shift());
if (newName) BDFDB.ReactUtils.setChild(child, newName);
}
}
}
}
}
processMessage (e) {
let header = e.instance.props.childrenHeader;
if (header && header.props && header.props.message && header.props.message.nick) {
let newName = this.getNewName(header.props.message.author);
if (newName) header.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, header.props.message, {nick: newName}));
processMessage (e) {
let header = e.instance.props.childrenHeader;
if (header && header.props && header.props.message && header.props.message.nick) {
let newName = this.getNewName(header.props.message.author);
if (newName) header.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, header.props.message, {nick: newName}));
}
}
}
processMessageContent (e) {
if (BDFDB.ArrayUtils.is(e.instance.props.content) && settings.changeInMentions) for (let ele of e.instance.props.content) {
if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && (ele.type.displayName || "").toLowerCase().indexOf("popout") > -1 && typeof ele.props.render == "function") {
if (BDFDB.ObjectUtils.get(ele, "props.children.type.displayName") == "Mention") {
let newName = this.getNewName(BDFDB.LibraryModules.UserStore.getUser(ele.props.render().props.userId));
if (newName) ele.props.children.props.children[0] = "@" + newName;
processMessageContent (e) {
if (BDFDB.ArrayUtils.is(e.instance.props.content) && settings.changeInMentions) for (let ele of e.instance.props.content) {
if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && (ele.type.displayName || "").toLowerCase().indexOf("popout") > -1 && typeof ele.props.render == "function") {
if (BDFDB.ObjectUtils.get(ele, "props.children.type.displayName") == "Mention") {
let newName = this.getNewName(BDFDB.LibraryModules.UserStore.getUser(ele.props.render().props.userId));
if (newName) ele.props.children.props.children[0] = "@" + newName;
}
}
}
if (e.instance.props.message.type != BDFDB.DiscordConstants.MessageTypes.DEFAULT && e.instance.props.message.nick && settings.changeInChatWindow) {
let newName = this.getNewName(e.instance.props.message.author);
if (newName) {
e.instance.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, e.instance.props.message, {nick: newName}));
e.instance.props.children.props.message = e.instance.props.message;
}
}
}
if (e.instance.props.message.type != BDFDB.DiscordConstants.MessageTypes.DEFAULT && e.instance.props.message.nick && settings.changeInChatWindow) {
let newName = this.getNewName(e.instance.props.message.author);
if (newName) {
e.instance.props.message = new BDFDB.DiscordObjects.Message(Object.assign({}, e.instance.props.message, {nick: newName}));
e.instance.props.children.props.message = e.instance.props.message;
}
getNewName (user, wrapper) {
if (!user) return null;
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), user.id) || {};
if (!member.nick || user.id == BDFDB.UserUtils.me.id && !settings.replaceOwn || user.bot && !settings.replaceBots) return null;
let username = (BDFDB.BDUtils.isPluginEnabled("EditUsers") && BDFDB.DataUtils.load("EditUsers", "users", user.id) || {}).name || user.username;
return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + username + ")") : (username + " (" + member.nick + ")")) : username;
}
}
getNewName (user, wrapper) {
if (!user) return null;
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), user.id) || {};
if (!member.nick || user.id == BDFDB.UserUtils.me.id && !settings.replaceOwn || user.bot && !settings.replaceBots) return null;
let username = (BDFDB.BDUtils.isPluginEnabled("EditUsers") && BDFDB.DataUtils.load("EditUsers", "users", user.id) || {}).name || user.username;
return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + username + ")") : (username + " (" + member.nick + ")")) : username;
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
})();
module.exports = RemoveNicknames;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,96 +1,71 @@
//META{"name":"RevealAllSpoilersOption","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/RevealAllSpoilersOption","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/RevealAllSpoilersOption/RevealAllSpoilersOption.plugin.js"}*//
var RevealAllSpoilersOption = (_ => {
return class RevealAllSpoilersOption {
getName () {return "RevealAllSpoilersOption";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds an entry to the message contextmenu to reveal all spoilers within a messageblock.";}
constructor () {
this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
};
module.exports = (_ => {
const config = {
"info": {
"name": "RevealAllSpoilersOption",
"author": "DevilBro",
"version": "1.0.5",
"description": "Adds an entry to the message contextmenu to reveal all spoilers within a messageblock."
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class RevealAllSpoilersOption extends Plugin {
onLoad() {}
onStart() {}
onStop() {}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, e.instance.props.target);
if (!messageDiv || !messageDiv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null;
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: "Reveal all Spoilers",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "reveal-all"),
hint: hint && (_ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
}),
action: _ => {
this.revealAllSpoilers(messageDiv);
}
})
}));
}
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
revealAllSpoilers (target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, target);
if (!messageDiv) return;
for (let spoiler of messageDiv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
}
}
// Begin of own functions
onMessageContextMenu (e) {
if (e.instance.props.message && e.instance.props.target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, e.instance.props.target);
if (!messageDiv || !messageDiv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
let hint = BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null;
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: "Reveal all Spoilers",
id: BDFDB.ContextMenuUtils.createItemId(this.name, "reveal-all"),
hint: hint && (_ => {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuHint, {
hint: hint
});
}),
action: _ => {
this.revealAllSpoilers(messageDiv);
}
})
}));
}
}
revealAllSpoilers (target) {
let messageDiv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.message, target);
if (!messageDiv) return;
for (let spoiler of messageDiv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
}
}
})();
module.exports = RevealAllSpoilersOption;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,262 +1,234 @@
//META{"name":"SendLargeMessages","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SendLargeMessages","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SendLargeMessages/SendLargeMessages.plugin.js"}*//
var SendLargeMessages = (_ => {
var messageDelay = 1000; //changing at own risk, might result in bans or mutes
return class SendLargeMessages {
getName () {return "SendLargeMessages";}
getVersion () {return "1.6.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Opens a popout when your message is too large, which allows you to automatically send the message in several smaller messages.";}
constructor () {
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
},
after: {
ChannelTextAreaContainer: "render",
}
};
}
initConstructor () {
this.css = `
.${this.name}-modal textarea {
height: 50vh;
}`;
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processChannelTextAreaForm (e) {
if (!BDFDB.PatchUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.PatchUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
if (e2.methodArguments[0].length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0]);
messages.filter(n => n).forEach((message, i) => {
BDFDB.TimeUtils.timeout(_ => {
e2.originalMethod(message);
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
}, messageDelay * i);
});
return Promise.resolve({
shouldClear: true,
shouldRefocus: true
});
}
else return e2.callOriginalMethodAfterwards();
}}, {force: true, noCache: true});
module.exports = (_ => {
const config = {
"info": {
"name": "SendLargeMessages",
"author": "DevilBro",
"version": "1.6.5",
"description": "Splits messages into several smaller messages when your message exceeds the limit."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
processChannelTextAreaContainer (e) {
if (e.returnvalue.ref && e.returnvalue.ref.current && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, e.returnvalue.ref.current)) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SlateCharacterCount"});
if (index > -1) {
let text = BDFDB.LibraryModules.SlateSelectionUtils.serialize(children[index].props.document, "raw");
if (text.length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) children[index] = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.textareacharcounter + BDFDB.disCN.textareacharcountererror,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: Math.ceil(text.length / BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) + " " + BDFDB.LanguageUtils.LanguageStrings.MESSAGES,
children: BDFDB.ReactUtils.createElement("span", {
children: BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH - text.length
})
})
});
}
}
}
processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) e.instance.props.shouldUploadLongMessages = false;
}
formatText (text) {
text = text.replace(/\t/g, " ");
let longWords = text.match(new RegExp(`[^ ]{${BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)},}`, "gm"));
if (longWords) for (let longWord of longWords) {
let count1 = 0;
let shortWords = [];
longWord.split("").forEach(c => {
if (shortWords[count1] && (shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) || (c == "\n" && shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) - 100))) count1++;
shortWords[count1] = shortWords[count1] ? shortWords[count1] + c : c;
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
text = text.replace(longWord, shortWords.join(" "));
}
let messages = [];
let count2 = 0;
text.split(" ").forEach((word) => {
if (messages[count2] && (messages[count2] + "" + word).length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) count2++;
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
});
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
const messageDelay = 1000; //changing at own risk, might result in bans or mutes
return class SendLargeMessages extends Plugin {
onLoad() {
this.patchedModules = {
before: {
ChannelTextAreaForm: "render",
ChannelEditorContainer: "render"
},
after: {
ChannelTextAreaContainer: "render",
}
};
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
let insertCodeBlock = null, insertCodeLine = null;
for (let j = 0; j < messages.length; j++) {
if (insertCodeBlock) {
messages[j] = insertCodeBlock + messages[j];
insertCodeBlock = null;
}
else if (insertCodeLine) {
messages[j] = insertCodeLine + messages[j];
insertCodeLine = null;
}
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
if (codeBlocks && codeBlocks.length % 2 == 1) {
messages[j] = messages[j] + "```";
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
}
else if (codeLines && codeLines.length % 2 == 1) {
insertCodeLine = codeLines[codeLines.length-1].replace(/[^`]/g, "");
messages[j] = messages[j] + insertCodeLine;
processChannelTextAreaForm (e) {
if (!BDFDB.PatchUtils.isPatched(this, e.instance, "handleSendMessage")) BDFDB.PatchUtils.patch(this, e.instance, "handleSendMessage", {instead: e2 => {
if (e2.methodArguments[0].length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) {
e2.stopOriginalMethodCall();
let messages = this.formatText(e2.methodArguments[0]);
messages.filter(n => n).forEach((message, i) => {
BDFDB.TimeUtils.timeout(_ => {
e2.originalMethod(message);
if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
}, messageDelay * i);
});
return Promise.resolve({
shouldClear: true,
shouldRefocus: true
});
}
else return e2.callOriginalMethodAfterwards();
}}, {force: true, noCache: true});
}
processChannelTextAreaContainer (e) {
if (e.returnvalue.ref && e.returnvalue.ref.current && BDFDB.DOMUtils.getParent(BDFDB.dotCN.chatform, e.returnvalue.ref.current)) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SlateCharacterCount"});
if (index > -1) {
let text = BDFDB.LibraryModules.SlateSelectionUtils.serialize(children[index].props.document, "raw");
if (text.length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH) children[index] = BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.textareacharcounter + BDFDB.disCN.textareacharcountererror,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: Math.ceil(text.length / BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) + " " + BDFDB.LanguageUtils.LanguageStrings.MESSAGES,
children: BDFDB.ReactUtils.createElement("span", {
children: BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH - text.length
})
})
});
}
}
}
return messages;
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
toast_allsent_text: "Sve veliku poslane."
};
case "da": //danish
return {
toast_allsent_text: "Alle beskeder sendes."
};
case "de": //german
return {
toast_allsent_text: "Alle Nachrichten versendet."
};
case "es": //spanish
return {
toast_allsent_text: "Todos los mensajes enviados."
};
case "fr": //french
return {
toast_allsent_text: "Tous les messages envoyés"
};
case "it": //italian
return {
toast_allsent_text: "Tutti i messaggi inviati."
};
case "nl": //dutch
return {
toast_allsent_text: "Alle berichten verzonden."
};
case "no": //norwegian
return {
toast_allsent_text: "Alle meldinger sendt."
};
case "pl": //polish
return {
toast_allsent_text: "Wszystkie wiadomości zostały wysłane."
};
case "pt-BR": //portuguese (brazil)
return {
toast_allsent_text: "Todas as mensagens enviadas."
};
case "fi": //finnish
return {
toast_allsent_text: "Kaikki lähetetyt viestit."
};
case "sv": //swedish
return {
toast_allsent_text: "Alla meddelanden skickade."
};
case "tr": //turkish
return {
toast_allsent_text: "Tüm mesajlar gönderildi."
};
case "cs": //czech
return {
toast_allsent_text: "Všechny zprávy byly odeslány."
};
case "bg": //bulgarian
return {
toast_allsent_text: "Всички изпратени съобщения."
};
case "ru": //russian
return {
toast_allsent_text: "Все отправленные сообщения."
};
case "uk": //ukrainian
return {
toast_allsent_text: "Всі повідомлення надіслано."
};
case "ja": //japanese
return {
toast_allsent_text: "すべてのメッセージが送信されました。"
};
case "zh-TW": //chinese (traditional)
return {
toast_allsent_text: "發送的所有消息。"
};
case "ko": //korean
return {
toast_allsent_text: "모든 메시지가 전송되었습니다."
};
default: //default: english
return {
toast_allsent_text: "All messages sent."
};
processChannelEditorContainer (e) {
if (e.instance.props.type && e.instance.props.type == BDFDB.DiscordConstants.TextareaTypes.NORMAL) e.instance.props.shouldUploadLongMessages = false;
}
}
}
})();
module.exports = SendLargeMessages;
formatText (text) {
text = text.replace(/\t/g, " ");
let longWords = text.match(new RegExp(`[^ ]{${BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20)},}`, "gm"));
if (longWords) for (let longWord of longWords) {
let count1 = 0;
let shortWords = [];
longWord.split("").forEach(c => {
if (shortWords[count1] && (shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) || (c == "\n" && shortWords[count1].length >= BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (19/20) - 100))) count1++;
shortWords[count1] = shortWords[count1] ? shortWords[count1] + c : c;
});
text = text.replace(longWord, shortWords.join(" "));
}
let messages = [];
let count2 = 0;
text.split(" ").forEach((word) => {
if (messages[count2] && (messages[count2] + "" + word).length > BDFDB.DiscordConstants.MAX_MESSAGE_LENGTH * (39/40)) count2++;
messages[count2] = messages[count2] ? messages[count2] + " " + word : word;
});
let insertCodeBlock = null, insertCodeLine = null;
for (let j = 0; j < messages.length; j++) {
if (insertCodeBlock) {
messages[j] = insertCodeBlock + messages[j];
insertCodeBlock = null;
}
else if (insertCodeLine) {
messages[j] = insertCodeLine + messages[j];
insertCodeLine = null;
}
let codeBlocks = messages[j].match(/`{3,}[\S]*\n|`{3,}/gm);
let codeLines = messages[j].match(/[^`]{0,1}`{1,2}[^`]|[^`]`{1,2}[^`]{0,1}/gm);
if (codeBlocks && codeBlocks.length % 2 == 1) {
messages[j] = messages[j] + "```";
insertCodeBlock = codeBlocks[codeBlocks.length-1] + "\n";
}
else if (codeLines && codeLines.length % 2 == 1) {
insertCodeLine = codeLines[codeLines.length-1].replace(/[^`]/g, "");
messages[j] = messages[j] + insertCodeLine;
}
}
return messages;
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
toast_allsent_text: "Sve veliku poslane."
};
case "da": //danish
return {
toast_allsent_text: "Alle beskeder sendes."
};
case "de": //german
return {
toast_allsent_text: "Alle Nachrichten versendet."
};
case "es": //spanish
return {
toast_allsent_text: "Todos los mensajes enviados."
};
case "fr": //french
return {
toast_allsent_text: "Tous les messages envoyés"
};
case "it": //italian
return {
toast_allsent_text: "Tutti i messaggi inviati."
};
case "nl": //dutch
return {
toast_allsent_text: "Alle berichten verzonden."
};
case "no": //norwegian
return {
toast_allsent_text: "Alle meldinger sendt."
};
case "pl": //polish
return {
toast_allsent_text: "Wszystkie wiadomości zostały wysłane."
};
case "pt-BR": //portuguese (brazil)
return {
toast_allsent_text: "Todas as mensagens enviadas."
};
case "fi": //finnish
return {
toast_allsent_text: "Kaikki lähetetyt viestit."
};
case "sv": //swedish
return {
toast_allsent_text: "Alla meddelanden skickade."
};
case "tr": //turkish
return {
toast_allsent_text: "Tüm mesajlar gönderildi."
};
case "cs": //czech
return {
toast_allsent_text: "Všechny zprávy byly odeslány."
};
case "bg": //bulgarian
return {
toast_allsent_text: "Всички изпратени съобщения."
};
case "ru": //russian
return {
toast_allsent_text: "Все отправленные сообщения."
};
case "uk": //ukrainian
return {
toast_allsent_text: "Всі повідомлення надіслано."
};
case "ja": //japanese
return {
toast_allsent_text: "すべてのメッセージが送信されました。"
};
case "zh-TW": //chinese (traditional)
return {
toast_allsent_text: "發送的所有消息。"
};
case "ko": //korean
return {
toast_allsent_text: "모든 메시지가 전송되었습니다."
};
default: //default: english
return {
toast_allsent_text: "All messages sent."
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,85 +1,63 @@
//META{"name":"ServerCounter","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerCounter","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerCounter/ServerCounter.plugin.js"}*//
var ServerCounter = (_ => {
return class ServerCounter {
getName () {return "ServerCounter";}
getVersion () {return "1.0.1";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds a server counter to the server list.";}
constructor () {
this.patchedModules = {
after: {
Guilds: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "ServerCounter",
"author": "DevilBro",
"version": "1.0.1",
"description": "Adds a server counter to the server list."
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class ServerCounter extends Plugin {
onLoad() {
this.patchedModules = {
after: {
Guilds: "render"
}
};
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processGuilds (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ConnectedUnreadDMs"});
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildouter,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.guildslabel + BDFDB.disCN._servercounterservercount,
children: `${BDFDB.LanguageUtils.LanguageStrings.SERVERS} - ${BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds().length}`
})
}));
}
}
})();
module.exports = ServerCounter;
processGuilds (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "ConnectedUnreadDMs"});
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildouter,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS.guildslabel + BDFDB.disCN._servercounterservercount,
children: `${BDFDB.LanguageUtils.LanguageStrings.SERVERS}  ${BDFDB.LibraryModules.FolderStore.getFlattenedGuildIds().length}`
})
}));
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +1,46 @@
//META{"name":"ServerHider","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ServerHider","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ServerHider/ServerHider.plugin.js"}*//
var ServerHider = (_ => {
return class ServerHider {
getName () {return "ServerHider";}
getVersion () {return "6.1.6";}
getAuthor () {return "DevilBro";}
getDescription () {return "Hide Servers in your Serverlist";}
constructor () {
this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
};
this.patchedModules = {
after: {
Guilds: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "ServerHider",
"author": "DevilBro",
"version": "6.1.6",
"description": "Hide Servers in your Serverlist."
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Unhide all Servers/Folders",
onClick: _ => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to unhide all servers and folders?", _ => {
BDFDB.DataUtils.save([], this, "hidden");
BDFDB.PatchUtils.forceAllUpdates(this);
});
},
children: BDFDB.LanguageUtils.LanguageStrings.RESET
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class ServerHider extends Plugin {
onLoad() {
this.patchedModules = {
after: {
Guilds: "render"
}
};
}
onStart() {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.FolderStore, "getGuildFolderById", {after: e => {
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
if (e.returnValue && hiddenGuildIds.length) {
@ -86,370 +53,378 @@ var ServerHider = (_ => {
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onGuildContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
if (e.type == "GuildIconNewContextMenu") {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "create", group: true});
this.injectItem(e.instance, children, -1);
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Unhide all Servers/Folders",
onClick: _ => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to unhide all servers and folders?", _ => {
BDFDB.DataUtils.save([], this, "hidden");
BDFDB.PatchUtils.forceAllUpdates(this);
});
},
children: BDFDB.LanguageUtils.LanguageStrings.RESET
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
else {
onGuildContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
if (e.type == "GuildIconNewContextMenu") {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "create", group: true});
this.injectItem(e.instance, children, -1);
}
else {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
this.injectItem(e.instance, children, index);
}
}
onGuildFolderContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
this.injectItem(e.instance, children, index);
}
}
onGuildFolderContextMenu (e) {
if (document.querySelector(BDFDB.dotCN.modalwrapper)) return;
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
this.injectItem(e.instance, children, index);
}
injectItem (instance, children, index) {
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_serverhider_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "submenu-hide"),
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.submenu_openhidemenu_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "openmenu"),
action: _ => {
this.showHideModal();
}
}),
!instance.props.guild && !instance.props.folderId ? null : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: instance.props.guild ? this.labels.submenu_hideserver_text : this.labels.submenu_hidefolder_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "hide"),
action: _ => {
if (instance.props.guild) this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "servers") || [], instance.props.guild.id, "servers");
else this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "folders") || [], instance.props.folderId, "folders");
}
})
].filter(n => n)
injectItem (instance, children, index) {
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.context_serverhider_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "submenu-hide"),
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: this.labels.submenu_openhidemenu_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "openmenu"),
action: _ => {
this.showHideModal();
}
}),
!instance.props.guild && !instance.props.folderId ? null : BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: instance.props.guild ? this.labels.submenu_hideserver_text : this.labels.submenu_hidefolder_text,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "hide"),
action: _ => {
if (instance.props.guild) this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "servers") || [], instance.props.guild.id, "servers");
else this.toggleItem(BDFDB.DataUtils.load(this, "hidden", "folders") || [], instance.props.folderId, "folders");
}
})
].filter(n => n)
})
})
})
]
}));
}
]
}));
}
processGuilds (e) {
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
if (hiddenGuildIds.length || hiddenFolderIds.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:["folderId", "guildId"], someProps:true});
if (index > -1) for (let i in children) {
let child = children[i];
if (child.props.folderId) {
if (hiddenFolderIds.includes(child.props.folderId)) children[i] = null;
else {
let guildIds = [].concat(child.props.guildIds.filter(guildId => !hiddenGuildIds.includes(guildId)));
if (guildIds.length) {
child.props.hiddenGuildIds = [].concat(child.props.guildIds.filter(guildId => hiddenGuildIds.includes(guildId)));
child.props.guildIds = guildIds;
processGuilds (e) {
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
if (hiddenGuildIds.length || hiddenFolderIds.length) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:["folderId", "guildId"], someProps:true});
if (index > -1) for (let i in children) {
let child = children[i];
if (child.props.folderId) {
if (hiddenFolderIds.includes(child.props.folderId)) children[i] = null;
else {
let guildIds = [].concat(child.props.guildIds.filter(guildId => !hiddenGuildIds.includes(guildId)));
if (guildIds.length) {
child.props.hiddenGuildIds = [].concat(child.props.guildIds.filter(guildId => hiddenGuildIds.includes(guildId)));
child.props.guildIds = guildIds;
}
else children[i] = null;
}
else children[i] = null;
}
else if (child.props.guildId && hiddenGuildIds.includes(child.props.guildId)) children[i] = null;
}
else if (child.props.guildId && hiddenGuildIds.includes(child.props.guildId)) children[i] = null;
}
}
}
showHideModal () {
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
let guilds = BDFDB.LibraryModules.FolderStore.guildFolders.map(n => n.guildIds).flat(10).map(guildId => BDFDB.LibraryModules.GuildStore.getGuild(guildId)).filter(n => n);
let folders = BDFDB.LibraryModules.FolderStore.guildFolders.filter(n => n.folderId);
let foldersAdded = [];
BDFDB.ModalUtils.open(this, {
size: "MEDIUM",
header: this.labels.modal_header_text,
subheader: "",
contentClassName: BDFDB.disCN.listscroller,
children: guilds.map((guild, i) => {
let folder = folders.find(folder => folder.guildIds.includes(guild.id) && !foldersAdded.includes(folder.folderId));
if (folder) foldersAdded.push(folder.folderId);
return [
folder ? [
folders.indexOf(folder) == 0 ? null : [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom4
})
],
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
prefix: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.listavatar,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.BlobMask, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.guildfolder,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildfoldericonwrapper,
showHideModal () {
let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || [];
let hiddenFolderIds = BDFDB.DataUtils.load(this, "hidden", "folders") || [];
let guilds = BDFDB.LibraryModules.FolderStore.guildFolders.map(n => n.guildIds).flat(10).map(guildId => BDFDB.LibraryModules.GuildStore.getGuild(guildId)).filter(n => n);
let folders = BDFDB.LibraryModules.FolderStore.guildFolders.filter(n => n.folderId);
let foldersAdded = [];
BDFDB.ModalUtils.open(this, {
size: "MEDIUM",
header: this.labels.modal_header_text,
subheader: "",
contentClassName: BDFDB.disCN.listscroller,
children: guilds.map((guild, i) => {
let folder = folders.find(folder => folder.guildIds.includes(guild.id) && !foldersAdded.includes(folder.folderId));
if (folder) foldersAdded.push(folder.folderId);
return [
folder ? [
folders.indexOf(folder) == 0 ? null : [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop8 + BDFDB.disCN.marginbottom4
})
],
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
prefix: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.listavatar,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.BlobMask, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.guildfolder,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildfoldericonwrapperexpanded,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
name: BDFDB.LibraryComponents.SvgIcon.Names.FOLDER,
color: BDFDB.ColorUtils.convert(folder.folderColor, "RGB") || BDFDB.DiscordConstants.Colors.BRAND
className: BDFDB.disCN.guildfoldericonwrapper,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.guildfoldericonwrapperexpanded,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
name: BDFDB.LibraryComponents.SvgIcon.Names.FOLDER,
color: BDFDB.ColorUtils.convert(folder.folderColor, "RGB") || BDFDB.DiscordConstants.Colors.BRAND
})
})
})
})
})
}),
label: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: folder.folderName || `${BDFDB.LanguageUtils.LanguageStrings.SERVER_FOLDER_PLACEHOLDER} #${folders.indexOf(folder) + 1}`
}),
suffix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
value: !hiddenFolderIds.includes(folder.folderId),
onChange: value => {this.toggleItem(hiddenFolderIds, folder.folderId, "folders", value);}
})
})
] : null,
i == 0 && !folder ? null : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
prefix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Guild, {
className: BDFDB.disCN.listavatar,
guild: guild,
menu: false,
tooltip: false
}),
label: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: folder.folderName || `${BDFDB.LanguageUtils.LanguageStrings.SERVER_FOLDER_PLACEHOLDER} #${folders.indexOf(folder) + 1}`
children: guild.name
}),
suffix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
value: !hiddenFolderIds.includes(folder.folderId),
onChange: value => {this.toggleItem(hiddenFolderIds, folder.folderId, "folders", value);}
value: !hiddenGuildIds.includes(guild.id),
onChange: value => {this.toggleItem(hiddenGuildIds, guild.id, "servers", value);}
})
})
] : null,
i == 0 && !folder ? null : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ListRow, {
prefix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.Guild, {
className: BDFDB.disCN.listavatar,
guild: guild,
menu: false,
tooltip: false
}),
label: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextScroller, {
children: guild.name
}),
suffix: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
value: !hiddenGuildIds.includes(guild.id),
onChange: value => {this.toggleItem(hiddenGuildIds, guild.id, "servers", value);}
})
})
];
}).flat(10).filter(n => n),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.OKAY,
color: "BRAND",
close: true
}, {
contents: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL,
color: "TRANSPARENT",
look: "LINK",
click: (modal, instance) => {
let enabled = hiddenGuildIds.includes(guilds[0].id);
hiddenGuildIds = [].concat(enabled ? [] : guilds.map(n => n.id));
BDFDB.DataUtils.save(hiddenGuildIds, this, "hidden", "servers");
hiddenFolderIds = [].concat(enabled ? [] : folders.map(n => n.folderId));
BDFDB.DataUtils.save(hiddenFolderIds, this, "hidden", "folders");
let switchInstances = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_Switch", all:true, unlimited:true});
for (let switchIns of switchInstances) switchIns.props.value = enabled;
BDFDB.ReactUtils.forceUpdate(switchInstances);
BDFDB.PatchUtils.forceAllUpdates(this);
}
}]
});
}
toggleItem (array, id, type, force) {
if (!id) return;
if (force || (force === undefined && array.includes(id))) BDFDB.ArrayUtils.remove(array, id, true);
else array.push(id);
BDFDB.DataUtils.save(array, this, "hidden", type);
BDFDB.PatchUtils.forceAllUpdates(this);
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
modal_header_text: "Upravljanje popisom poslužitelja",
context_serverhider_text: "Vidljivost poslužitelj",
submenu_hideserver_text: "Sakrij poslužitelj",
submenu_hidefolder_text: "Sakrij mapu",
submenu_openhidemenu_text: "Upravljanje popisom poslužitelja"
};
case "da": //danish
return {
modal_header_text: "Styring af serverliste",
context_serverhider_text: "Server synlighed",
submenu_hideserver_text: "Skjul server",
submenu_hidefolder_text: "Skjul mappe",
submenu_openhidemenu_text: "Styre serverliste"
};
case "de": //german
return {
modal_header_text: "Verwaltung der Serverliste",
context_serverhider_text: "Serversichtbarkeit",
submenu_hideserver_text: "Server verstecken",
submenu_hidefolder_text: "Ordner verstecken",
submenu_openhidemenu_text: "Serverliste verwalten"
};
case "es": //spanish
return {
modal_header_text: "Administración de lista de servidores",
context_serverhider_text: "Visibilidad del servidor",
submenu_hideserver_text: "Ocultar servidor",
submenu_hidefolder_text: "Ocultar carpeta",
submenu_openhidemenu_text: "Administrar lista de servidores"
};
case "fr": //french
return {
modal_header_text: "Gestion de la liste des serveurs",
context_serverhider_text: "Visibilité du serveur",
submenu_hideserver_text: "Cacher le serveur",
submenu_hidefolder_text: "Cacher le dossier",
submenu_openhidemenu_text: "Gérer la liste des serveurs"
};
case "it": //italian
return {
modal_header_text: "Gestione dell'elenco dei server",
context_serverhider_text: "Visibilità del server",
submenu_hideserver_text: "Nascondi il server",
submenu_hidefolder_text: "Nascondi la cartella",
submenu_openhidemenu_text: "Gestione elenco dei server"
};
case "nl": //dutch
return {
modal_header_text: "Beheer van de Serverlijst",
context_serverhider_text: "Server zichtbaarheid",
submenu_hideserver_text: "Verberg server",
submenu_hidefolder_text: "Verberg map",
submenu_openhidemenu_text: "Beheer serverlijst"
};
case "no": //norwegian
return {
modal_header_text: "Administrasjon av serverlisten",
context_serverhider_text: "Server synlighet",
submenu_hideserver_text: "Skjul server",
submenu_hidefolder_text: "Skjul mappe",
submenu_openhidemenu_text: "Administrer serverliste"
};
case "pl": //polish
return {
modal_header_text: "Zarządzanie listą serwerów",
context_serverhider_text: "Widoczność serwera",
submenu_hideserver_text: "Ukryj serwer",
submenu_hidefolder_text: "Ukryj folder",
submenu_openhidemenu_text: "Zarządzaj listą serwerów"
};
case "pt-BR": //portuguese (brazil)
return {
modal_header_text: "Gerenciamento da lista de servidores",
context_serverhider_text: "Visibilidade do servidor",
submenu_hideserver_text: "Ocultar servidor",
submenu_hidefolder_text: "Ocultar pasta",
submenu_openhidemenu_text: "Gerenciar lista de servidores"
};
case "fi": //finnish
return {
modal_header_text: "Palvelinluettelon hallinta",
context_serverhider_text: "Palvelimen näkyvyys",
submenu_hideserver_text: "Piilota palvelin",
submenu_hidefolder_text: "Piilota kansio",
submenu_openhidemenu_text: "Hallinnoi palvelinluetteloa"
};
case "sv": //swedish
return {
modal_header_text: "Hantering av serverlistan",
context_serverhider_text: "Server sikt",
submenu_hideserver_text: "Dölj server",
submenu_hidefolder_text: "Dölj mapp",
submenu_openhidemenu_text: "Hantera serverlistan"
};
case "tr": //turkish
return {
modal_header_text: "Sunucu Listesinin Yönetimi",
context_serverhider_text: "Sunucu görünürlüğü",
submenu_hideserver_text: "Sunucuyu Gizle",
submenu_hidefolder_text: "Klasörü Gizle",
submenu_openhidemenu_text: "Sunucu Listesini Yönet"
};
case "cs": //czech
return {
modal_header_text: "Správa seznamu serverů",
context_serverhider_text: "Viditelnost serveru",
submenu_hideserver_text: "Skrýt server",
submenu_hidefolder_text: "Skrýt složky",
submenu_openhidemenu_text: "Správa seznamu serverů"
};
case "bg": //bulgarian
return {
modal_header_text: "Управление на списъка със сървъри",
context_serverhider_text: "Видимост на сървъра",
submenu_hideserver_text: "Скриване на сървър",
submenu_hidefolder_text: "Скриване на папка",
submenu_openhidemenu_text: "Управление на списъка със сървъри"
};
case "ru": //russian
return {
modal_header_text: "Управление списком серверов",
context_serverhider_text: "Видимость сервера",
submenu_hideserver_text: "Скрыть сервер",
submenu_hidefolder_text: "Скрыть папки",
submenu_openhidemenu_text: "Управление списком серверов"
};
case "uk": //ukrainian
return {
modal_header_text: "Управління списком серверів",
context_serverhider_text: "Видимість сервера",
submenu_hideserver_text: "Сховати сервер",
submenu_hidefolder_text: "Сховати папки",
submenu_openhidemenu_text: "Управління списком серверів"
};
case "ja": //japanese
return {
modal_header_text: "サーバリストの管理",
context_serverhider_text: "サーバーの可視性",
submenu_hideserver_text: "サーバーを隠す",
submenu_hidefolder_text: "フォルダーを非表示",
submenu_openhidemenu_text: "サーバーリストを管理する"
};
case "zh-TW": //chinese (traditional)
return {
modal_header_text: "管理服务器列表",
context_serverhider_text: "服務器可見性",
submenu_hideserver_text: "隐藏服务器",
submenu_hidefolder_text: "隱藏資料夾",
submenu_openhidemenu_text: "管理服务器列表"
};
case "ko": //korean
return {
modal_header_text: "서버 목록 관리",
context_serverhider_text: "서버 가시성",
submenu_hideserver_text: "서버 숨기기",
submenu_hidefolder_text: "폴더 숨기기",
submenu_openhidemenu_text: "서버 목록 관리"
};
default: //default: english
return {
modal_header_text: "Managing Serverlist",
context_serverhider_text: "Server Visibility",
submenu_hideserver_text: "Hide Server",
submenu_hidefolder_text: "Hide Folder",
submenu_openhidemenu_text: "Manage Serverlist"
};
];
}).flat(10).filter(n => n),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.OKAY,
color: "BRAND",
close: true
}, {
contents: BDFDB.LanguageUtils.LanguageStrings.FORM_LABEL_ALL,
color: "TRANSPARENT",
look: "LINK",
click: (modal, instance) => {
let enabled = hiddenGuildIds.includes(guilds[0].id);
hiddenGuildIds = [].concat(enabled ? [] : guilds.map(n => n.id));
BDFDB.DataUtils.save(hiddenGuildIds, this, "hidden", "servers");
hiddenFolderIds = [].concat(enabled ? [] : folders.map(n => n.folderId));
BDFDB.DataUtils.save(hiddenFolderIds, this, "hidden", "folders");
let switchInstances = BDFDB.ReactUtils.findOwner(instance, {name:"BDFDB_Switch", all:true, unlimited:true});
for (let switchIns of switchInstances) switchIns.props.value = enabled;
BDFDB.ReactUtils.forceUpdate(switchInstances);
BDFDB.PatchUtils.forceAllUpdates(this);
}
}]
});
}
toggleItem (array, id, type, force) {
if (!id) return;
if (force || (force === undefined && array.includes(id))) BDFDB.ArrayUtils.remove(array, id, true);
else array.push(id);
BDFDB.DataUtils.save(array, this, "hidden", type);
BDFDB.PatchUtils.forceAllUpdates(this);
}
}
}
})();
module.exports = ServerHider;
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian
return {
modal_header_text: "Upravljanje popisom poslužitelja",
context_serverhider_text: "Vidljivost poslužitelj",
submenu_hideserver_text: "Sakrij poslužitelj",
submenu_hidefolder_text: "Sakrij mapu",
submenu_openhidemenu_text: "Upravljanje popisom poslužitelja"
};
case "da": //danish
return {
modal_header_text: "Styring af serverliste",
context_serverhider_text: "Server synlighed",
submenu_hideserver_text: "Skjul server",
submenu_hidefolder_text: "Skjul mappe",
submenu_openhidemenu_text: "Styre serverliste"
};
case "de": //german
return {
modal_header_text: "Verwaltung der Serverliste",
context_serverhider_text: "Serversichtbarkeit",
submenu_hideserver_text: "Server verstecken",
submenu_hidefolder_text: "Ordner verstecken",
submenu_openhidemenu_text: "Serverliste verwalten"
};
case "es": //spanish
return {
modal_header_text: "Administración de lista de servidores",
context_serverhider_text: "Visibilidad del servidor",
submenu_hideserver_text: "Ocultar servidor",
submenu_hidefolder_text: "Ocultar carpeta",
submenu_openhidemenu_text: "Administrar lista de servidores"
};
case "fr": //french
return {
modal_header_text: "Gestion de la liste des serveurs",
context_serverhider_text: "Visibilité du serveur",
submenu_hideserver_text: "Cacher le serveur",
submenu_hidefolder_text: "Cacher le dossier",
submenu_openhidemenu_text: "Gérer la liste des serveurs"
};
case "it": //italian
return {
modal_header_text: "Gestione dell'elenco dei server",
context_serverhider_text: "Visibilità del server",
submenu_hideserver_text: "Nascondi il server",
submenu_hidefolder_text: "Nascondi la cartella",
submenu_openhidemenu_text: "Gestione elenco dei server"
};
case "nl": //dutch
return {
modal_header_text: "Beheer van de Serverlijst",
context_serverhider_text: "Server zichtbaarheid",
submenu_hideserver_text: "Verberg server",
submenu_hidefolder_text: "Verberg map",
submenu_openhidemenu_text: "Beheer serverlijst"
};
case "no": //norwegian
return {
modal_header_text: "Administrasjon av serverlisten",
context_serverhider_text: "Server synlighet",
submenu_hideserver_text: "Skjul server",
submenu_hidefolder_text: "Skjul mappe",
submenu_openhidemenu_text: "Administrer serverliste"
};
case "pl": //polish
return {
modal_header_text: "Zarządzanie listą serwerów",
context_serverhider_text: "Widoczność serwera",
submenu_hideserver_text: "Ukryj serwer",
submenu_hidefolder_text: "Ukryj folder",
submenu_openhidemenu_text: "Zarządzaj listą serwerów"
};
case "pt-BR": //portuguese (brazil)
return {
modal_header_text: "Gerenciamento da lista de servidores",
context_serverhider_text: "Visibilidade do servidor",
submenu_hideserver_text: "Ocultar servidor",
submenu_hidefolder_text: "Ocultar pasta",
submenu_openhidemenu_text: "Gerenciar lista de servidores"
};
case "fi": //finnish
return {
modal_header_text: "Palvelinluettelon hallinta",
context_serverhider_text: "Palvelimen näkyvyys",
submenu_hideserver_text: "Piilota palvelin",
submenu_hidefolder_text: "Piilota kansio",
submenu_openhidemenu_text: "Hallinnoi palvelinluetteloa"
};
case "sv": //swedish
return {
modal_header_text: "Hantering av serverlistan",
context_serverhider_text: "Server sikt",
submenu_hideserver_text: "Dölj server",
submenu_hidefolder_text: "Dölj mapp",
submenu_openhidemenu_text: "Hantera serverlistan"
};
case "tr": //turkish
return {
modal_header_text: "Sunucu Listesinin Yönetimi",
context_serverhider_text: "Sunucu görünürlüğü",
submenu_hideserver_text: "Sunucuyu Gizle",
submenu_hidefolder_text: "Klasörü Gizle",
submenu_openhidemenu_text: "Sunucu Listesini Yönet"
};
case "cs": //czech
return {
modal_header_text: "Správa seznamu serverů",
context_serverhider_text: "Viditelnost serveru",
submenu_hideserver_text: "Skrýt server",
submenu_hidefolder_text: "Skrýt složky",
submenu_openhidemenu_text: "Správa seznamu serverů"
};
case "bg": //bulgarian
return {
modal_header_text: "Управление на списъка със сървъри",
context_serverhider_text: "Видимост на сървъра",
submenu_hideserver_text: "Скриване на сървър",
submenu_hidefolder_text: "Скриване на папка",
submenu_openhidemenu_text: "Управление на списъка със сървъри"
};
case "ru": //russian
return {
modal_header_text: "Управление списком серверов",
context_serverhider_text: "Видимость сервера",
submenu_hideserver_text: "Скрыть сервер",
submenu_hidefolder_text: "Скрыть папки",
submenu_openhidemenu_text: "Управление списком серверов"
};
case "uk": //ukrainian
return {
modal_header_text: "Управління списком серверів",
context_serverhider_text: "Видимість сервера",
submenu_hideserver_text: "Сховати сервер",
submenu_hidefolder_text: "Сховати папки",
submenu_openhidemenu_text: "Управління списком серверів"
};
case "ja": //japanese
return {
modal_header_text: "サーバリストの管理",
context_serverhider_text: "サーバーの可視性",
submenu_hideserver_text: "サーバーを隠す",
submenu_hidefolder_text: "フォルダーを非表示",
submenu_openhidemenu_text: "サーバーリストを管理する"
};
case "zh-TW": //chinese (traditional)
return {
modal_header_text: "管理服务器列表",
context_serverhider_text: "服務器可見性",
submenu_hideserver_text: "隐藏服务器",
submenu_hidefolder_text: "隱藏資料夾",
submenu_openhidemenu_text: "管理服务器列表"
};
case "ko": //korean
return {
modal_header_text: "서버 목록 관리",
context_serverhider_text: "서버 가시성",
submenu_hideserver_text: "서버 숨기기",
submenu_hidefolder_text: "폴더 숨기기",
submenu_openhidemenu_text: "서버 목록 관리"
};
default: //default: english
return {
modal_header_text: "Managing Serverlist",
context_serverhider_text: "Server Visibility",
submenu_hideserver_text: "Hide Server",
submenu_hidefolder_text: "Hide Folder",
submenu_openhidemenu_text: "Manage Serverlist"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,116 +1,105 @@
//META{"name":"SteamProfileLink","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SteamProfileLink","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SteamProfileLink/SteamProfileLink.plugin.js"}*//
var SteamProfileLink = (_ => {
var settings = {};
return class SteamProfileLink {
getName () {return "SteamProfileLink";}
getVersion () {return "1.0.9";}
getAuthor () {return "DevilBro";}
getDescription () {return "Opens any Steam links in Steam instead of your internet browser.";}
constructor () {
this.changelog = {
"improved":[["Support links","Also works for support links now"]]
};
module.exports = (_ => {
const config = {
"info": {
"name": "SteamProfileLink",
"author": "DevilBro",
"version": "1.0.9",
"description": "Opens any Steam links in Steam instead of your internet browser."
}
initConstructor () {
this.defaults = {
settings: {
useChromium: {value:false, description:"Use inbuilt browser instead of default if fails to open Steam"}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [];
settingsItems = settingsItems.concat(this.createSelects(false));
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
BDFDB.ListenerUtils.add(this, document, "click", "a[href^='https://steamcommunity.'], a[href^='https://help.steampowered.'], a[href^='https://store.steampowered.'], a[href*='a.akamaihd.net/'][href*='steam']", e => {this.openInSteam(e, e.currentTarget.href);});
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {};
var urls = {
steam: ["https://steamcommunity.", "https://help.steampowered.", "https://store.steampowered.", "a.akamaihd.net/"]
};
return class SteamProfileLink extends Plugin {
onLoad() {
this.defaults = {
settings: {
useChromium: {value:false, description:"Use inbuilt browser instead of default if fails to open Steam"}
}
};
}
onStart() {
for (let key in urls) BDFDB.ListenerUtils.add(this, document, "click", urls[key].map(url => url.indexOf("http") == 0 ? `a[href^="${url}"]` : `a[href*="${url}"][href*="${key}"]`).join(", "), e => {
this.openIn(e, key, e.currentTarget.href);
});
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
onStop() {}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems = settingsItems.concat(this.createSelects(false));
for (let key in settings) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
}
openInSteam (e, url) {
BDFDB.ListenerUtils.stopEvent(e);
BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else BDFDB.DiscordUtils.openLink(response.request.href, settings.useChromium);
});
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
}
}
})();
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
}
openIn (e, key, url) {
let platform = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(key);
if (typeof this[`openIn${platform}`] == "function") {
BDFDB.ListenerUtils.stopEvent(e);
this[`openIn${platform}`](url);
return true;
}
return false;
}
module.exports = SteamProfileLink;
openInSteam (url) {
BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else BDFDB.DiscordUtils.openLink(response.request.href, settings.useChromium);
});
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,58 +1,44 @@
//META{"name":"ThemeSettings","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeSettings","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ThemeSettings/ThemeSettings.plugin.js"}*//
var ThemeSettings = (_ => {
var dir;
return class ThemeSettings {
getName () {return "ThemeSettings";}
getVersion () {return "1.2.0";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to change Theme Variables within BetterDiscord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page.";}
constructor () {
this.changelog = {
"fixed":[["Works","again"]]
};
module.exports = (_ => {
const config = {
"info": {
"name": "ThemeSettings",
"author": "DevilBro",
"version": "1.2.0",
"description": "Allows you to change Theme Variables within BetterDiscord. Adds a Settings button (similar to Plugins) to customizable Themes in your Themes Page."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
initConstructor () {
dir = BDFDB.BDUtils.getThemesFolder();
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var dir;
return class ThemeSettings extends Plugin {
onLoad() {
dir = BDFDB.BDUtils.getThemesFolder();
}
onStart() {
let cardObserver = (new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) this.appendSettingsButton(node);
if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child);
@ -63,154 +49,142 @@ var ThemeSettings = (_ => {
});}});}))}, {childList: true});
for (let child of document.querySelectorAll(BDFDB.dotCN._repocard)) this.appendSettingsButton(child);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.DOMUtils.remove(".theme-settings-button");
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
appendSettingsButton (card) {
if (card.querySelector(".theme-settings-button")) return;
let addon = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props.addon");
if (addon && !addon.plugin) {
let vars = this.getThemeVars(addon.css);
if (vars.length) {
let footer = card.querySelector("." + BDFDB.dotCN._repofooter.split(".").filter(n => n).join(",."));
if (!footer) {
footer = document.createElement("div");
footer.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repofooter);
let links = document.createElement("span");
links.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repolinks);
footer.appendChild(links);
card.appendChild(footer);
}
let settingsButton = document.createElement("button");
settingsButton.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._reposettingsbutton, "theme-settings-button");
settingsButton.innerText = BDFDB.LanguageUtils.LanguageStrings.SETTINGS;
footer.appendChild(settingsButton);
settingsButton.addEventListener("click", _ => {
BDFDB.DOMUtils.addClass(card, BDFDB.disCN._reposettingsopen);
BDFDB.DOMUtils.removeClass(card, BDFDB.disCN._reposettingsclosed);
let children = [];
while (card.childElementCount) {
children.push(card.firstChild);
card.firstChild.remove();
appendSettingsButton (card) {
if (card.querySelector(".theme-settings-button")) return;
let addon = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props.addon");
if (addon && !addon.plugin) {
let vars = this.getThemeVars(addon.css);
if (vars.length) {
let footer = card.querySelector("." + BDFDB.dotCN._repofooter.split(".").filter(n => n).join(",."));
if (!footer) {
footer = document.createElement("div");
footer.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repofooter);
let links = document.createElement("span");
links.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repolinks);
footer.appendChild(links);
card.appendChild(footer);
}
let closeButton = BDFDB.DOMUtils.create(`<div style="float: right; cursor: pointer;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" style="width: 18px; height: 18px;"><g class="background" fill="none" fill-rule="evenodd"><path d="M0 0h12v12H0"></path><path class="fill" fill="#dcddde" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path></g></svg></div>`);
card.appendChild(closeButton);
closeButton.addEventListener("click", _ => {
BDFDB.DOMUtils.removeClass(card, BDFDB.disCN._reposettingsopen);
BDFDB.DOMUtils.addClass(card, BDFDB.disCN._reposettingsclosed);
while (card.childElementCount) card.firstChild.remove();
while (children.length) card.appendChild(children.shift());
let settingsButton = document.createElement("button");
settingsButton.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._reposettingsbutton, "theme-settings-button");
settingsButton.innerText = BDFDB.LanguageUtils.LanguageStrings.SETTINGS;
footer.appendChild(settingsButton);
settingsButton.addEventListener("click", _ => {
BDFDB.DOMUtils.addClass(card, BDFDB.disCN._reposettingsopen);
BDFDB.DOMUtils.removeClass(card, BDFDB.disCN._reposettingsclosed);
let children = [];
while (card.childElementCount) {
children.push(card.firstChild);
card.firstChild.remove();
}
let closeButton = BDFDB.DOMUtils.create(`<div style="float: right; cursor: pointer;"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12" style="width: 18px; height: 18px;"><g class="background" fill="none" fill-rule="evenodd"><path d="M0 0h12v12H0"></path><path class="fill" fill="#dcddde" d="M9.5 3.205L8.795 2.5 6 5.295 3.205 2.5l-.705.705L5.295 6 2.5 8.795l.705.705L6 6.705 8.795 9.5l.705-.705L6.705 6"></path></g></svg></div>`);
card.appendChild(closeButton);
closeButton.addEventListener("click", _ => {
BDFDB.DOMUtils.removeClass(card, BDFDB.disCN._reposettingsopen);
BDFDB.DOMUtils.addClass(card, BDFDB.disCN._reposettingsclosed);
while (card.childElementCount) card.firstChild.remove();
while (children.length) card.appendChild(children.shift());
});
this.createThemeSettings(card, addon, vars);
});
this.createThemeSettings(card, addon, vars);
});
}
}
}
}
getThemeVars (css) {
let vars = css.split(":root");
if (vars.length > 1) {
vars = vars[1].replace(/\t\(/g, " (").replace(/\r|\t| {2,}/g, "").replace(/\/\*\n*((?!\/\*|\*\/).|\n)*\n+((?!\/\*|\*\/).|\n)*\n*\*\//g, "").replace(/\n\/\*.*?\*\//g, "").replace(/\n/g, "");
vars = vars.split("{");
vars.shift();
vars = vars.join("{").replace(/\s*(:|;|--|\*)\s*/g, "$1");
vars = vars.split("}")[0];
return vars.slice(2).split(/;--|\*\/--/);
getThemeVars (css) {
let vars = css.split(":root");
if (vars.length > 1) {
vars = vars[1].replace(/\t\(/g, " (").replace(/\r|\t| {2,}/g, "").replace(/\/\*\n*((?!\/\*|\*\/).|\n)*\n+((?!\/\*|\*\/).|\n)*\n*\*\//g, "").replace(/\n\/\*.*?\*\//g, "").replace(/\n/g, "");
vars = vars.split("{");
vars.shift();
vars = vars.join("{").replace(/\s*(:|;|--|\*)\s*/g, "$1");
vars = vars.split("}")[0];
return vars.slice(2).split(/;--|\*\/--/);
}
return [];
}
return [];
}
createThemeSettings (wrapper, theme, vars) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.GREEN,
label: "Update all variables",
onClick: _ => {
let path = BDFDB.LibraryRequires.path.join(dir, theme.filename);
let css = BDFDB.LibraryRequires.fs.readFileSync(path).toString();
if (css) {
let amount = 0;
for (let input of wrapper.querySelectorAll(BDFDB.dotCN.input)) {
let oldvalue = input.getAttribute("placeholder");
let newvalue = input.value;
if (newvalue && newvalue.trim() && newvalue != oldvalue) {
let varName = input.getAttribute("varName");
css = css.replace(new RegExp(`--${BDFDB.StringUtils.regEscape(varName)}(\\s*):(\\s*)${BDFDB.StringUtils.regEscape(oldvalue)}`,"g"),`--${varName}$1:$2${newvalue}`);
amount++;
createThemeSettings (wrapper, theme, vars) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.GREEN,
label: "Update all variables",
onClick: _ => {
let path = BDFDB.LibraryRequires.path.join(dir, theme.filename);
let css = BDFDB.LibraryRequires.fs.readFileSync(path).toString();
if (css) {
let amount = 0;
for (let input of wrapper.querySelectorAll(BDFDB.dotCN.input)) {
let oldvalue = input.getAttribute("placeholder");
let newvalue = input.value;
if (newvalue && newvalue.trim() && newvalue != oldvalue) {
let varName = input.getAttribute("varName");
css = css.replace(new RegExp(`--${BDFDB.StringUtils.regEscape(varName)}(\\s*):(\\s*)${BDFDB.StringUtils.regEscape(oldvalue)}`,"g"),`--${varName}$1:$2${newvalue}`);
amount++;
}
}
if (amount > 0) {
BDFDB.LibraryRequires.fs.writeFileSync(path, css);
BDFDB.NotificationUtils.toast(`Updated ${amount} variable${amount == 1 ? "" : "s"} in ${theme.filename}`, {type:"success"});
}
else BDFDB.NotificationUtils.toast(`There are no changed variables to be updated in ${theme.filename}`, {type:"warning"});
}
else BDFDB.NotificationUtils.toast(`Could not find themefile: ${theme.filename}`, {type:"error"});
},
children: "Update"
}));
for (let varStr of vars) {
varStr = varStr.split(":");
let varName = varStr.shift().trim();
varStr = varStr.join(":").split(/;[^A-z0-9]|\/\*/);
let varValue = varStr.shift().trim();
if (varValue) {
let childType = "text", childMode = "";
let isColor = BDFDB.ColorUtils.getType(varValue);
let isComp = !isColor && /^[0-9 ]+,[0-9 ]+,[0-9 ]+$/g.test(varValue);
if (isColor || isComp) {
childType = "color";
childMode = isComp && "comp";
}
else {
let isUrlFile = /url\(.+\)/gi.test(varValue);
let isFile = !isUrlFile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(varValue);
if (isFile || isUrlFile) {
childType = "file";
childMode = isUrlFile && "url";
}
}
if (amount > 0) {
BDFDB.LibraryRequires.fs.writeFileSync(path, css);
BDFDB.NotificationUtils.toast(`Updated ${amount} variable${amount == 1 ? "" : "s"} in ${theme.filename}`, {type:"success"});
}
else BDFDB.NotificationUtils.toast(`There are no changed variables to be updated in ${theme.filename}`, {type:"warning"});
let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim();
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
className: BDFDB.disCN.marginbottom20,
dividerbottom: vars[vars.length-1] != varStr,
type: "TextInput",
childProps: {
type: childType,
mode: childMode,
filter: childType == "file" && "image"
},
label: varName[0].toUpperCase() + varName.slice(1),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
varName: varName,
value: varValue,
placeholder: varValue
}));
}
else BDFDB.NotificationUtils.toast(`Could not find themefile: ${theme.filename}`, {type:"error"});
},
children: "Update"
}));
for (let varStr of vars) {
varStr = varStr.split(":");
let varName = varStr.shift().trim();
varStr = varStr.join(":").split(/;[^A-z0-9]|\/\*/);
let varValue = varStr.shift().trim();
if (varValue) {
let childType = "text", childMode = "";
let isColor = BDFDB.ColorUtils.getType(varValue);
let isComp = !isColor && /^[0-9 ]+,[0-9 ]+,[0-9 ]+$/g.test(varValue);
if (isColor || isComp) {
childType = "color";
childMode = isComp && "comp";
}
else {
let isUrlFile = /url\(.+\)/gi.test(varValue);
let isFile = !isUrlFile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(varValue);
if (isFile || isUrlFile) {
childType = "file";
childMode = isUrlFile && "url";
}
}
let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim();
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
className: BDFDB.disCN.marginbottom20,
dividerbottom: vars[vars.length-1] != varStr,
type: "TextInput",
childProps: {
type: childType,
mode: childMode,
filter: childType == "file" && "image"
},
label: varName[0].toUpperCase() + varName.slice(1),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
varName: varName,
value: varValue,
placeholder: varValue
}));
}
wrapper.appendChild(BDFDB.PluginUtils.createSettingsPanel(Object.assign({}, theme, {noLibrary: true}), settingsItems));
}
wrapper.appendChild(BDFDB.PluginUtils.createSettingsPanel(Object.assign({}, theme, {noLibrary: true}), settingsItems));
}
}
})();
module.exports = ThemeSettings;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,73 +1,59 @@
//META{"name":"TimedLightDarkMode","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/TimedLightDarkMode","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/TimedLightDarkMode/TimedLightDarkMode.plugin.js"}*//
var TimedLightDarkMode = (_ => {
var checkInterval, changeTimeout, disableChanging;
var settings = {}, values = {};
return class TimedLightDarkMode {
getName () {return "TimedLightDarkMode";}
getVersion () {return "1.0.8";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to automatically change light/dark mode depending on the time of day. Slider is added to the 'Appearance' settings.";}
constructor () {
this.changelog = {
"improved":[["Disabled Changing Time","Changing the discord native theme mode will now disable the automatic timed mode change triggered by this plugin for 10 minutes, to allow people to use the opposite theme mode for a short amount of time"]]
};
this.patchedModules = {
after: {
RadioGroup: "componentDidMount"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "TimedLightDarkMode",
"author": "DevilBro",
"version": "1.0.8",
"description": "Allows you to automatically change light/dark mode depending on the time of day. Slider is added to the 'Appearance' settings."
}
initConstructor () {
this.defaults = {
settings: {
running: {value: true}
},
values: {
timer1: {value:25},
timer2: {value:75}
}
};
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector('head script#BDFDBLibraryScript');
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var checkInterval, changeTimeout, disableChanging;
var settings = {}, values = {};
return class TimedLightDarkMode extends Plugin {
onLoad() {
this.defaults = {
settings: {
running: {value: true}
},
values: {
timer1: {value:25},
timer2: {value:75}
}
};
this.patchedModules = {
after: {
RadioGroup: "componentDidMount"
}
};
}
onStart() {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SettingsUtils, "updateLocalSettings", {after: e => {
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].theme) {
BDFDB.TimeUtils.clear(changeTimeout);
@ -82,166 +68,154 @@ var TimedLightDarkMode = (_ => {
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
onStop() {
BDFDB.TimeUtils.clear(checkInterval);
BDFDB.DOMUtils.remove(BDFDB.dotCN._timedlightdarkmodetimersettings);
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
processRadioGroup (e) {
if (e.instance.props && Array.isArray(e.instance.props.options) && e.instance.props.options[0] && (e.instance.props.options[0].value == "light" || e.instance.props.options[0].value == "dark") && e.instance.props.options[1] && (e.instance.props.options[1].value == "light" || e.instance.props.options[1].value == "dark") && e.node.parentElement.firstElementChild.innerText && e.node.parentElement.firstElementChild.innerText.toUpperCase() == BDFDB.LanguageUtils.LanguageStrings.THEME.toUpperCase()) {
let slider, settingsBox = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS._timedlightdarkmodetimersettings + BDFDB.disCN.margintop8}"></div>`);
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(BDFDB.ReactUtils.Fragment, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: this,
keys: ["settings", "running"],
value: settings.running,
label: `${BDFDB.LanguageUtils.LanguageStrings.THEME} Timer`,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5,
onChange: (value, instance) => {
this.startInterval();
if (slider) BDFDB.DOMUtils.toggleClass(slider, BDFDB.disCN.sliderdisabled, !value);
}
}),
BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.slider + BDFDB.disCN.margintop20}${!settings.running ? (" " + BDFDB.disCN.sliderdisabled): ""}"><input type="number" timer="timer1" class="${BDFDB.disCN.sliderinput}" value="${values.timer1}" readonly=""><input type="number" timer="timer2" class="${BDFDB.disCN.sliderinput}" value="${values.timer2}" readonly=""><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCN.slidermark}" style="left: 0%;"><div class="${BDFDB.disCN.slidermarkvalue}">00:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 12.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">03:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 25%;"><div class="${BDFDB.disCN.slidermarkvalue}">06:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 37.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">09:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 50%;"><div class="${BDFDB.disCN.slidermarkvalue}">12:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 62.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">15:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 75%;"><div class="${BDFDB.disCN.slidermarkvalue}">18:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 87.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">21:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 100%;"><div class="${BDFDB.disCN.slidermarkvalue}">24:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div></div><div class="${BDFDB.disCN.sliderbar}"><div class="${BDFDB.disCN.sliderbarfill}"></div></div><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer1" style="left: ${values.timer1}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer2" style="left: ${values.timer2}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodedategrabber}" timer="current" style="left: ${this.getPercent(new Date())}%; cursor: help !important; height: 12px; margin-top: -7px;"></div></div></div>`), node => {
if (Node.prototype.isPrototypeOf(node)) {
slider = node;
this.updateSlider(slider, values);
BDFDB.ListenerUtils.addToChildren(slider, "mousedown", BDFDB.dotCN._timedlightdarkmodetimergrabber, event => {this.dragSlider(event.currentTarget);});
BDFDB.ListenerUtils.addToChildren(slider, "mouseenter", BDFDB.dotCN._timedlightdarkmodedategrabber, event => {this.showCurrentTime(event.currentTarget);});
}
})
]
}), settingsBox);
e.node.parentElement.appendChild(settingsBox);
processRadioGroup (e) {
if (e.instance.props && Array.isArray(e.instance.props.options) && e.instance.props.options[0] && (e.instance.props.options[0].value == "light" || e.instance.props.options[0].value == "dark") && e.instance.props.options[1] && (e.instance.props.options[1].value == "light" || e.instance.props.options[1].value == "dark") && e.node.parentElement.firstElementChild.innerText && e.node.parentElement.firstElementChild.innerText.toUpperCase() == BDFDB.LanguageUtils.LanguageStrings.THEME.toUpperCase()) {
let slider, settingsBox = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS._timedlightdarkmodetimersettings + BDFDB.disCN.margintop8}"></div>`);
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(BDFDB.ReactUtils.Fragment, {
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: this,
keys: ["settings", "running"],
value: settings.running,
label: `${BDFDB.LanguageUtils.LanguageStrings.THEME} Timer`,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H5,
onChange: (value, instance) => {
this.startInterval();
if (slider) BDFDB.DOMUtils.toggleClass(slider, BDFDB.disCN.sliderdisabled, !value);
}
}),
BDFDB.ReactUtils.elementToReact(BDFDB.DOMUtils.create(`<div class="${BDFDB.disCNS.slider + BDFDB.disCN.margintop20}${!settings.running ? (" " + BDFDB.disCN.sliderdisabled): ""}"><input type="number" timer="timer1" class="${BDFDB.disCN.sliderinput}" value="${values.timer1}" readonly=""><input type="number" timer="timer2" class="${BDFDB.disCN.sliderinput}" value="${values.timer2}" readonly=""><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCN.slidermark}" style="left: 0%;"><div class="${BDFDB.disCN.slidermarkvalue}">00:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 12.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">03:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 25%;"><div class="${BDFDB.disCN.slidermarkvalue}">06:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 37.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">09:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 50%;"><div class="${BDFDB.disCN.slidermarkvalue}">12:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 62.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">15:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 75%;"><div class="${BDFDB.disCN.slidermarkvalue}">18:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 87.5%;"><div class="${BDFDB.disCN.slidermarkvalue}">21:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div><div class="${BDFDB.disCN.slidermark}" style="left: 100%;"><div class="${BDFDB.disCN.slidermarkvalue}">24:00</div><div class="${BDFDB.disCN.slidermarkdash}"></div></div></div><div class="${BDFDB.disCN.sliderbar}"><div class="${BDFDB.disCN.sliderbarfill}"></div></div><div class="${BDFDB.disCN.slidertrack}"><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer1" style="left: ${values.timer1}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodetimergrabber}" timer="timer2" style="left: ${values.timer2}%;"></div><div class="${BDFDB.disCNS.slidergrabber + BDFDB.disCN._timedlightdarkmodedategrabber}" timer="current" style="left: ${this.getPercent(new Date())}%; cursor: help !important; height: 12px; margin-top: -7px;"></div></div></div>`), node => {
if (Node.prototype.isPrototypeOf(node)) {
slider = node;
this.updateSlider(slider, values);
BDFDB.ListenerUtils.addToChildren(slider, "mousedown", BDFDB.dotCN._timedlightdarkmodetimergrabber, event => {this.dragSlider(event.currentTarget);});
BDFDB.ListenerUtils.addToChildren(slider, "mouseenter", BDFDB.dotCN._timedlightdarkmodedategrabber, event => {this.showCurrentTime(event.currentTarget);});
}
})
]
}), settingsBox);
e.node.parentElement.appendChild(settingsBox);
}
}
}
startInterval () {
BDFDB.TimeUtils.clear(checkInterval);
settings = BDFDB.DataUtils.get(this, "settings");
values = BDFDB.DataUtils.get(this, "values");
if (settings.running) {
let inverted = values.timer1 > values.timer2;
let timer1LOW = this.getTime(values.timer1), timer2LOW = this.getTime(values.timer2);
let timer1HIGH = this.getHighTime(timer2LOW), timer2HIGH = this.getHighTime(timer1LOW);
let check = _ => {
if (disableChanging) return;
let currentTime = new Date();
let currentHours = currentTime.getHours();
let currentMinutes = currentTime.getMinutes();
if (inverted) this.changeTheme(!(this.checkTime(timer1LOW, timer1HIGH, [currentHours, currentMinutes])));
else this.changeTheme(this.checkTime(timer2LOW, timer2HIGH, [currentHours, currentMinutes]));
startInterval () {
BDFDB.TimeUtils.clear(checkInterval);
settings = BDFDB.DataUtils.get(this, "settings");
values = BDFDB.DataUtils.get(this, "values");
if (settings.running) {
let inverted = values.timer1 > values.timer2;
let timer1LOW = this.getTime(values.timer1), timer2LOW = this.getTime(values.timer2);
let timer1HIGH = this.getHighTime(timer2LOW), timer2HIGH = this.getHighTime(timer1LOW);
let check = _ => {
if (disableChanging) return;
let currentTime = new Date();
let currentHours = currentTime.getHours();
let currentMinutes = currentTime.getMinutes();
if (inverted) this.changeTheme(!(this.checkTime(timer1LOW, timer1HIGH, [currentHours, currentMinutes])));
else this.changeTheme(this.checkTime(timer2LOW, timer2HIGH, [currentHours, currentMinutes]));
};
check();
checkInterval = BDFDB.TimeUtils.interval(_ => {check();}, 1000*60*1);
}
}
checkTime (timerLOW, timerHIGH, time) {
return timerHIGH[0] > time[0] || timerHIGH[0] == time[0] && timerHIGH[1] >= time[1] || time[0] > timerLOW[0] || time[0] == timerLOW[0] && time[1] >= timerLOW[1];
}
changeTheme (dark) {
let theme = BDFDB.DiscordUtils.getTheme();
if (dark && theme == BDFDB.disCN.themelight) BDFDB.LibraryModules.SettingsUtils.updateLocalSettings({theme:"dark"});
else if (!dark && theme == BDFDB.disCN.themedark) BDFDB.LibraryModules.SettingsUtils.updateLocalSettings({theme:"light"});
}
showCurrentTime (grabber) {
let currentTime = new Date();
let currentHours = currentTime.getHours();
let currentMinutes = currentTime.getMinutes();
grabber.style.setProperty("left", `${this.getPercent(currentTime)}%`);
BDFDB.TooltipUtils.create(grabber, (currentHours > 9 ? currentHours : ("0" + currentHours)) + ":" + (currentMinutes > 9 ? currentMinutes : ("0" + currentMinutes)), {color: "grey"});
}
dragSlider (grabber) {
let track = grabber.parentNode;
if (BDFDB.DOMUtils.containsClass(track.parentNode, BDFDB.disCN.sliderdisabled)) return;
let timer = grabber.getAttribute("timer");
let input = track.parentNode.querySelector(`${BDFDB.dotCN.sliderinput}[timer="${timer}"]`);
BDFDB.DOMUtils.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
let value = values[timer];
let sY = 0;
let sHalfW = BDFDB.DOMUtils.getRects(grabber).width/2;
let sMinX = BDFDB.DOMUtils.getRects(track).left;
let sMaxX = sMinX + BDFDB.DOMUtils.getRects(track).width;
let tooltip = BDFDB.TooltipUtils.create(grabber, this.getTime(value, true), {color: "grey", perssist: true});
let tooltipContent = tooltip.querySelector(BDFDB.dotCN.tooltipcontent);
let mouseup = _ => {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("mousemove", mousemove);
BDFDB.DOMUtils.removeLocalStyle("disableTextSelection");
BDFDB.DataUtils.save(value, this, "values", timer);
BDFDB.DOMUtils.remove(tooltip);
this.startInterval();
};
check();
checkInterval = BDFDB.TimeUtils.interval(_ => {check();}, 1000*60*1);
let mousemove = e => {
sY = e.clientX > sMaxX ? sMaxX - sHalfW : (e.clientX < sMinX ? sMinX - sHalfW : e.clientX - sHalfW);
value = BDFDB.NumberUtils.mapRange([sMinX - sHalfW, sMaxX - sHalfW], [0, 100], sY);
input.value = value;
grabber.style.setProperty("left", value + "%");
tooltipContent.innerText = this.getTime(value, true);
tooltip.update();
values[timer] = value;
this.updateSlider(track.parentNode, values);
};
document.addEventListener("mouseup", mouseup);
document.addEventListener("mousemove", mousemove);
}
}
checkTime (timerLOW, timerHIGH, time) {
return timerHIGH[0] > time[0] || timerHIGH[0] == time[0] && timerHIGH[1] >= time[1] || time[0] > timerLOW[0] || time[0] == timerLOW[0] && time[1] >= timerLOW[1];
}
changeTheme (dark) {
let theme = BDFDB.DiscordUtils.getTheme();
if (dark && theme == BDFDB.disCN.themelight) BDFDB.LibraryModules.SettingsUtils.updateLocalSettings({theme:"dark"});
else if (!dark && theme == BDFDB.disCN.themedark) BDFDB.LibraryModules.SettingsUtils.updateLocalSettings({theme:"light"});
}
showCurrentTime (grabber) {
let currentTime = new Date();
let currentHours = currentTime.getHours();
let currentMinutes = currentTime.getMinutes();
grabber.style.setProperty("left", `${this.getPercent(currentTime)}%`);
BDFDB.TooltipUtils.create(grabber, (currentHours > 9 ? currentHours : ("0" + currentHours)) + ":" + (currentMinutes > 9 ? currentMinutes : ("0" + currentMinutes)), {color: "grey"});
}
dragSlider (grabber) {
let track = grabber.parentNode;
if (BDFDB.DOMUtils.containsClass(track.parentNode, BDFDB.disCN.sliderdisabled)) return;
let timer = grabber.getAttribute("timer");
let input = track.parentNode.querySelector(`${BDFDB.dotCN.sliderinput}[timer="${timer}"]`);
BDFDB.DOMUtils.appendLocalStyle("disableTextSelection", `*{user-select: none !important;}`);
let value = values[timer];
let sY = 0;
let sHalfW = BDFDB.DOMUtils.getRects(grabber).width/2;
let sMinX = BDFDB.DOMUtils.getRects(track).left;
let sMaxX = sMinX + BDFDB.DOMUtils.getRects(track).width;
let tooltip = BDFDB.TooltipUtils.create(grabber, this.getTime(value, true), {color: "grey", perssist: true});
let tooltipContent = tooltip.querySelector(BDFDB.dotCN.tooltipcontent);
let mouseup = _ => {
document.removeEventListener("mouseup", mouseup);
document.removeEventListener("mousemove", mousemove);
BDFDB.DOMUtils.removeLocalStyle("disableTextSelection");
BDFDB.DataUtils.save(value, this, "values", timer);
BDFDB.DOMUtils.remove(tooltip);
this.startInterval();
};
let mousemove = e => {
sY = e.clientX > sMaxX ? sMaxX - sHalfW : (e.clientX < sMinX ? sMinX - sHalfW : e.clientX - sHalfW);
value = BDFDB.NumberUtils.mapRange([sMinX - sHalfW, sMaxX - sHalfW], [0, 100], sY);
input.value = value;
grabber.style.setProperty("left", value + "%");
tooltipContent.innerText = this.getTime(value, true);
tooltip.update();
values[timer] = value;
this.updateSlider(track.parentNode, values);
};
document.addEventListener("mouseup", mouseup);
document.addEventListener("mousemove", mousemove);
}
updateSlider (slider, values) {
let bar = slider.querySelector(BDFDB.dotCN.sliderbar);
let fill = slider.querySelector(BDFDB.dotCN.sliderbarfill);
let inverted = values.timer1 > values.timer2;
fill.style.setProperty("width", (inverted ? (values.timer1 - values.timer2) : (values.timer2 - values.timer1)) + "%");
fill.style.setProperty("margin-left", (inverted ? values.timer2 : values.timer1) + "%");
fill.style.setProperty("background-color", inverted ? "#66757F" : "#E0C460", "important");
bar.style.setProperty("background-color", inverted ? "#E0C460" : "#66757F", "important");
}
getTime (percent, stringify) {
let time = BDFDB.NumberUtils.mapRange([0, 100], [0, 1440], percent)/60;
let hours = Math.floor(time);
let minutes = Math.floor((time - hours) * 60);
return stringify ? (hours > 9 ? hours : ("0" + hours)) + ":" + (minutes > 9 ? minutes : ("0" + minutes)) : [hours,minutes];
}
getPercent (time) {
if (!time) return 0;
let hours = Array.isArray(time) ? time[0] : (typeof time == "object" && typeof time.getHours == "function" ? time.getHours() : 0);
let minutes = Array.isArray(time) ? time[1] : (typeof time == "object" && typeof time.getMinutes == "function" ? time.getMinutes() : 0);
return BDFDB.NumberUtils.mapRange([0, 1440], [0, 100], (hours * 60) + minutes);
}
getHighTime (timer) {
let hours = timer[0];
let minutes = timer[1] - 1;
if (minutes < 0) {
minutes = 59;
hours -= 1;
updateSlider (slider, values) {
let bar = slider.querySelector(BDFDB.dotCN.sliderbar);
let fill = slider.querySelector(BDFDB.dotCN.sliderbarfill);
let inverted = values.timer1 > values.timer2;
fill.style.setProperty("width", (inverted ? (values.timer1 - values.timer2) : (values.timer2 - values.timer1)) + "%");
fill.style.setProperty("margin-left", (inverted ? values.timer2 : values.timer1) + "%");
fill.style.setProperty("background-color", inverted ? "#66757F" : "#E0C460", "important");
bar.style.setProperty("background-color", inverted ? "#E0C460" : "#66757F", "important");
}
if (hours < 0) hours = 0;
return [hours, minutes];
}
}
})();
module.exports = TimedLightDarkMode;
getTime (percent, stringify) {
let time = BDFDB.NumberUtils.mapRange([0, 100], [0, 1440], percent)/60;
let hours = Math.floor(time);
let minutes = Math.floor((time - hours) * 60);
return stringify ? (hours > 9 ? hours : ("0" + hours)) + ":" + (minutes > 9 ? minutes : ("0" + minutes)) : [hours,minutes];
}
getPercent (time) {
if (!time) return 0;
let hours = Array.isArray(time) ? time[0] : (typeof time == "object" && typeof time.getHours == "function" ? time.getHours() : 0);
let minutes = Array.isArray(time) ? time[1] : (typeof time == "object" && typeof time.getMinutes == "function" ? time.getMinutes() : 0);
return BDFDB.NumberUtils.mapRange([0, 1440], [0, 100], (hours * 60) + minutes);
}
getHighTime (timer) {
let hours = timer[0];
let minutes = timer[1] - 1;
if (minutes < 0) {
minutes = 59;
hours -= 1;
}
if (hours < 0) hours = 0;
return [hours, minutes];
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,250 +1,230 @@
//META{"name":"TopRoleEverywhere","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/TopRoleEverywhere","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/TopRoleEverywhere/TopRoleEverywhere.plugin.js"}*//
var TopRoleEverywhere = (_ => {
var settings = {};
return class TopRoleEverywhere {
getName () {return "TopRoleEverywhere";}
getVersion () {return "3.0.3";}
getAuthor () {return "DevilBro";}
getDescription () {return "Adds the highest role of a user as a tag.";}
constructor () {
this.changelog = {
"improved":[["Chat Role Tag & Id Tag","The tags for the role and id in the message history now use their own settings separately, so you can disable the role tag in the chat but still show the id tag"]]
};
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "TopRoleEverywhere",
"author": "DevilBro",
"version": "3.0.3",
"description": "Adds the highest role of a user as a tag."
}
initConstructor () {
this.css = `
${BDFDB.dotCNS.member + BDFDB.dotCN.namecontainercontent} {
overflow: visible;
}
${BDFDB.dotCN._toproleseverywheretag} {
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
${BDFDB.dotCN._toproleseverywheremembertag} {
max-width: 50%;
}
${BDFDB.dotCN._toproleseverywherebadgestyle} {
margin-left: 0.3rem;
}
${BDFDB.dotCNS.themelight + BDFDB.dotCN._toproleseverywhererolestyle} {
color: rgba(79, 84, 92, 0.8);
}
${BDFDB.dotCNS.themedark + BDFDB.dotCN._toproleseverywhererolestyle} {
color: hsla(0, 0%, 100%, 0.8);
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywherebadgestyle} {
margin-left: 0.1rem;
margin-right: 0.2rem;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywhererolestyle} {
margin-right: 0.3rem;
}
${BDFDB.dotCN._toproleseverywhererolestyle} {
display: inline-flex;
margin: 0 0 0 0.3rem;
}
${BDFDB.dotCNS._toproleseverywhererolestyle + BDFDB.dotCN.userpopoutrolecircle} {
flex: 0 0 auto;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywhererolestyle} {
text-indent: 0;
}`;
this.defaults = {
settings: {
showInChat: {value:true, inner:true, description:"Chat Window"},
showInMemberList: {value:true, inner:true, description:"Member List"},
useOtherStyle: {value:false, inner:false, description:"Use BotTag Style instead of the Role Style."},
useBlackFont: {value:false, inner:false, description:"Instead of darkening the color for BotTag Style on bright colors use black font."},
includeColorless: {value:false, inner:false, description:"Include colorless roles."},
showOwnerRole: {value:false, inner:false, description:`Display Role Tag of Serverowner as "${BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER}".`},
disableForBots: {value:false, inner:false, description:"Disable Role Tag for Bots."},
addUserID: {value:false, inner:false, description:"Add the UserID as a Tag to the Chat Window."}
}
};
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settings = BDFDB.DataUtils.get(this, "settings");
let settingsPanel, settingsItems = [], innerItems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsItems : innerItems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Add Role Tags in:",
first: settingsItems.length == 0,
last: true,
children: innerItems
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
this.forceUpdateAll();
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
this.forceUpdateAll();
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
processMemberListItem (e) {
if (e.instance.props.user && settings.showInMemberList) {
this.injectRoleTag(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "member", {
tagClass: BDFDB.disCN.bottagmember
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
}
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
var settings = {};
return class TopRoleEverywhere extends Plugin {
onLoad() {
this.defaults = {
settings: {
showInChat: {value:true, inner:true, description:"Chat Window"},
showInMemberList: {value:true, inner:true, description:"Member List"},
useOtherStyle: {value:false, inner:false, description:"Use BotTag Style instead of the Role Style."},
useBlackFont: {value:false, inner:false, description:"Instead of darkening the color for BotTag Style on bright colors use black font."},
includeColorless: {value:false, inner:false, description:"Include colorless roles."},
showOwnerRole: {value:false, inner:false, description:`Display Role Tag of Serverowner as "${BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER}".`},
disableForBots: {value:false, inner:false, description:"Disable Role Tag for Bots."},
addUserID: {value:false, inner:false, description:"Add the UserID as a Tag to the Chat Window."}
}
};
this.patchedModules = {
after: {
MemberListItem: "render",
MessageHeader: "default"
}
};
this.css = `
${BDFDB.dotCNS.member + BDFDB.dotCN.namecontainercontent} {
overflow: visible;
}
${BDFDB.dotCN._toproleseverywheretag} {
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
${BDFDB.dotCN._toproleseverywheremembertag} {
max-width: 50%;
}
${BDFDB.dotCN._toproleseverywherebadgestyle} {
margin-left: 0.3rem;
}
${BDFDB.dotCNS.themelight + BDFDB.dotCN._toproleseverywhererolestyle} {
color: rgba(79, 84, 92, 0.8);
}
${BDFDB.dotCNS.themedark + BDFDB.dotCN._toproleseverywhererolestyle} {
color: hsla(0, 0%, 100%, 0.8);
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywherebadgestyle} {
margin-left: 0.1rem;
margin-right: 0.2rem;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywhererolestyle} {
margin-right: 0.3rem;
}
${BDFDB.dotCN._toproleseverywhererolestyle} {
display: inline-flex;
margin: 0 0 0 0.3rem;
}
${BDFDB.dotCNS._toproleseverywhererolestyle + BDFDB.dotCN.userpopoutrolecircle} {
flex: 0 0 auto;
}
${BDFDB.dotCNS.messagecompact + BDFDB.dotCNS.messageheader + BDFDB.dotCN._toproleseverywhererolestyle} {
text-indent: 0;
}
`;
}
onStart() {
this.forceUpdateAll();
}
onStop() {
this.forceUpdateAll();
}
processMessageHeader (e) {
if (e.instance.props.message) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) {
if (settings.showInChat) this.injectRoleTag(children, e.instance.props.message.author, "chat", {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
});
if (settings.addUserID) this.injectIdTag(children, e.instance.props.message.author, "chat", {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
for (let key in settings) if (!this.defaults.settings[key].inner) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}));
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Add Role Tags in:",
first: settingsItems.length == 0,
last: true,
children: Object.keys(settings).map(key => this.defaults.settings[key].inner && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
className: BDFDB.disCN.marginbottom8,
type: "Switch",
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key]
}))
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onSettingsClosed () {
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
processMemberListItem (e) {
if (e.instance.props.user && settings.showInMemberList) {
this.injectRoleTag(BDFDB.ObjectUtils.get(e.returnvalue, "props.decorators.props.children"), e.instance.props.user, "member", {
tagClass: BDFDB.disCN.bottagmember
});
}
}
}
injectRoleTag (children, user, type, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
let guild = BDFDB.LibraryModules.GuildStore.getGuild(BDFDB.LibraryModules.LastGuildStore.getGuildId());
if (!guild || user.bot && settings.disableForBots) return;
let role = BDFDB.LibraryModules.PermissionRoleUtils.getHighestRole(guild, user.id);
if (role && !role.colorString && !settings.includeColorless) {
let member = BDFDB.LibraryModules.MemberStore.getMember(guild.id, user.id);
if (member) for (let sortedRole of BDFDB.ArrayUtils.keySort(member.roles.map(roleId => guild.getRole(roleId)), "position").reverse()) if (sortedRole.colorString) {
role = sortedRole;
break;
processMessageHeader (e) {
if (e.instance.props.message) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue.props.children.slice(1), {name: "Popout", props: [["className", BDFDB.disCN.messageusername]]});
if (index > -1) {
if (settings.showInChat) this.injectRoleTag(children, e.instance.props.message.author, "chat", {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
});
if (settings.addUserID) this.injectIdTag(children, e.instance.props.message.author, "chat", {
tagClass: e.instance.props.compact ? BDFDB.disCN.messagebottagcompact : BDFDB.disCN.messagebottagcozy,
useRem: true
});
}
}
}
if (role && (role.colorString || settings.includeColorless)) children.push(this.createTag(Object.assign({}, role, {
name: settings.showOwnerRole && user.id == guild.ownerId ? BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER : role.name
}), type, config));
}
injectIdTag (children, user, type, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
children.push(this.createTag({
name: user.id
}, type, config));
}
createTag (role, type, config = {}) {
if (settings.useOtherStyle) {
let tagColor = BDFDB.ColorUtils.convert(role.colorString || BDFDB.DiscordConstants.Colors.PRIMARY_DARK_500, "RGB")
let isBright = role.colorString && BDFDB.ColorUtils.isBright(tagColor);
tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor;
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywherebadgestyle, config.tagClass),
useRemSizes: config.useRem,
invertColor: config.inverted,
style: {
backgroundColor: tagColor,
color: isBright && settings.useBlackFont ? "black" : null
},
tag: role.name,
injectRoleTag (children, user, type, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
let guild = BDFDB.LibraryModules.GuildStore.getGuild(BDFDB.LibraryModules.LastGuildStore.getGuildId());
if (!guild || user.bot && settings.disableForBots) return;
let role = BDFDB.LibraryModules.PermissionRoleUtils.getHighestRole(guild, user.id);
if (role && !role.colorString && !settings.includeColorless) {
let member = BDFDB.LibraryModules.MemberStore.getMember(guild.id, user.id);
if (member) for (let sortedRole of BDFDB.ArrayUtils.keySort(member.roles.map(roleId => guild.getRole(roleId)), "position").reverse()) if (sortedRole.colorString) {
role = sortedRole;
break;
}
}
if (role && (role.colorString || settings.includeColorless)) children.push(this.createTag(Object.assign({}, role, {
name: settings.showOwnerRole && user.id == guild.ownerId ? BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER : role.name
}), type, config));
}
injectIdTag (children, user, type, config = {}) {
if (!BDFDB.ArrayUtils.is(children) || !user) return;
children.push(this.createTag({
name: user.id
}, type, config));
}
createTag (role, type, config = {}) {
if (settings.useOtherStyle) {
let tagColor = BDFDB.ColorUtils.convert(role.colorString || BDFDB.DiscordConstants.Colors.PRIMARY_DARK_500, "RGB")
let isBright = role.colorString && BDFDB.ColorUtils.isBright(tagColor);
tagColor = isBright ? (settings.useBlackFont ? tagColor : BDFDB.ColorUtils.change(tagColor, -0.3)) : tagColor;
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.BotTag, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywherebadgestyle, config.tagClass),
useRemSizes: config.useRem,
invertColor: config.inverted,
style: {
backgroundColor: tagColor,
color: isBright && settings.useBlackFont ? "black" : null
},
tag: role.name,
onContextMenu: role.id ? e => {this.openRoleContextMenu(e, role);} : null
});
}
else return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MemberRole, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywhererolestyle),
role: role,
onContextMenu: role.id ? e => {this.openRoleContextMenu(e, role);} : null
});
}
else return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MemberRole, {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._toproleseverywheretag, BDFDB.disCN[`_toproleseverywhere${type}tag`], BDFDB.disCN._toproleseverywhererolestyle),
role: role,
onContextMenu: role.id ? e => {this.openRoleContextMenu(e, role);} : null
});
}
openRoleContextMenu (e, role) {
BDFDB.LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e, {id: role.id}));
});
}
forceUpdateAll () {
settings = BDFDB.DataUtils.get(this, "settings");
BDFDB.PatchUtils.forceAllUpdates(this);
BDFDB.MessageUtils.rerenderAll();
}
}
})();
module.exports = TopRoleEverywhere;
openRoleContextMenu (e, role) {
BDFDB.LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) {
return BDFDB.ReactUtils.createElement(BDFDB.ModuleUtils.findByName("DeveloperContextMenu"), Object.assign({}, e, {id: role.id}));
});
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,137 +1,110 @@
//META{"name":"UserNotes","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/UserNotes","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/UserNotes/UserNotes.plugin.js"}*//
var UserNotes = (_ => {
return class UserNotes {
getName () {return "UserNotes";}
getVersion () {return "1.0.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Allows you to write your own user notes wihtout a character limit.";}
module.exports = (_ => {
const config = {
"info": {
"name": "UserNotes",
"author": "DevilBro",
"version": "1.0.5",
"description": "Allows you to write your own user notes wihtout a character limit."
}
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
constructor () {
this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
};
}
initConstructor () {
this.css = `
.${this.name}-modal textarea {
height: 50vh;
}`;
}
getSettingsPanel (collapseStates = {}) {
if (!window.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Delete all Usernotes",
onClick: _ => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all usernotes?", _ => {
BDFDB.DataUtils.remove(this, "notes");
});
},
children: BDFDB.LanguageUtils.LanguageStrings.DELETE
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
}
}
// Begin of own functions
onUserContextMenu (e) {
if (e.instance.props.user) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "user-note"),
action: _ => {
this.openNotesModal(e.instance.props.user);
}
})
}));
}
}
openNotesModal (user) {
let note = BDFDB.DataUtils.load(this, "notes", user.id);
BDFDB.ModalUtils.open(this, {
size: "LARGE",
header: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE,
subheader: user.username,
scroller: false,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextArea, {
value: note,
placeholder: note,
autoFocus: true
})
],
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.SAVE,
color: "BRAND",
close: true,
click: modal => {
note = modal.querySelector("textarea").value;
if (note) BDFDB.DataUtils.save(note, this, "notes", user.id);
else BDFDB.DataUtils.remove(this, "notes", user.id);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class UserNotes extends Plugin {
onLoad() {
this.css = `
.${this.name}-modal textarea {
height: 50vh;
}
}]
});
}
}
})();
`;
}
onStart() {}
onStop() {}
module.exports = UserNotes;
getSettingsPanel (collapseStates = {}) {
let settingsPanel, settingsItems = [];
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Delete all Usernotes",
onClick: _ => {
BDFDB.ModalUtils.confirm(this, "Are you sure you want to remove all usernotes?", _ => {
BDFDB.DataUtils.remove(this, "notes");
});
},
children: BDFDB.LanguageUtils.LanguageStrings.DELETE
}));
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, settingsItems);
}
onUserContextMenu (e) {
if (e.instance.props.user) {
let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true});
children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE,
id: BDFDB.ContextMenuUtils.createItemId(this.name, "user-note"),
action: _ => {
this.openNotesModal(e.instance.props.user);
}
})
}));
}
}
openNotesModal (user) {
let note = BDFDB.DataUtils.load(this, "notes", user.id);
BDFDB.ModalUtils.open(this, {
size: "LARGE",
header: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE,
subheader: user.username,
scroller: false,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextArea, {
value: note,
placeholder: note,
autoFocus: true
})
],
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.SAVE,
color: "BRAND",
close: true,
click: modal => {
note = modal.querySelector("textarea").value;
if (note) BDFDB.DataUtils.save(note, this, "notes", user.id);
else BDFDB.DataUtils.remove(this, "notes", user.id);
}
}]
});
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();

View File

@ -1,91 +1,68 @@
//META{"name":"WriteUpperCase","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/WriteUpperCase","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/WriteUpperCase/WriteUpperCase.plugin.js"}*//
var WriteUpperCase = (_ => {
return class WriteUpperCase {
getName () {return "WriteUpperCase";}
getVersion () {return "1.2.5";}
getAuthor () {return "DevilBro";}
getDescription () {return "Changes first letter in message input to uppercase.";}
constructor () {
this.changelog = {
"fixed":[["New WYSIWYG Textarea","Fixed for the new WYSIWYG Textarea that is hidden by experiments"]],
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
};
this.patchedModules = {
before: {
ChannelEditorContainer: "render"
}
};
module.exports = (_ => {
const config = {
"info": {
"name": "WriteUpperCase",
"author": "DevilBro",
"version": "1.2.5",
"description": "Changes first letter in message input to uppercase."
}
// Legacy
load () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) BDFDB.PluginUtils.load(this);
}
start () {
if (!window.BDFDB) window.BDFDB = {myPlugins:{}};
if (window.BDFDB && window.BDFDB.myPlugins && typeof window.BDFDB.myPlugins == "object") window.BDFDB.myPlugins[this.getName()] = this;
let libraryScript = document.querySelector("head script#BDFDBLibraryScript");
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
if (libraryScript) libraryScript.remove();
libraryScript = document.createElement("script");
libraryScript.setAttribute("id", "BDFDBLibraryScript");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
libraryScript.setAttribute("date", performance.now());
libraryScript.addEventListener("load", _ => {this.initialize();});
document.head.appendChild(libraryScript);
};
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
getName () {return config.info.name;}
getAuthor () {return config.info.author;}
getVersion () {return config.info.version;}
getDescription () {return config.info.description;}
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.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",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
onConfirm: _ => {delete window.BDFDB_Global.downloadModal;require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (error, response, body) => {require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), body, _ => {});});}
});
}
else if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
this.startTimeout = setTimeout(_ => {
try {return this.initialize();}
catch (err) {console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not initiate plugin! " + err);}
}, 30000);
}
initialize () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return;
BDFDB.PluginUtils.init(this);
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
}
start() {}
stop() {}
} : (([Plugin, BDFDB]) => {
return class WriteUpperCase extends Plugin {
onLoad() {
this.patchedModules = {
before: {
ChannelEditorContainer: "render"
}
};
}
onStart() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
else console.error(`%c[${this.getName()}]%c`, "color: #3a71c1; font-weight: 700;", "", "Fatal Error: Could not load BD functions!");
}
stop () {
if (window.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.PluginUtils.clear(this);
onStop() {
BDFDB.PatchUtils.forceAllUpdates(this);
}
}
// Begin of own functions
processChannelEditorContainer (e) {
if (e.instance.props.textValue && e.instance.state.focused) {
let string = e.instance.props.textValue;
if (string.length > 0) {
let newstring = string;
let first = string.charAt(0);
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) newstring = string.charAt(0).toUpperCase() + string.slice(1);
if (string != newstring) {
e.instance.props.textValue = newstring;
if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.copyRichValue(newstring, e.instance.props.richValue);
processChannelEditorContainer (e) {
if (e.instance.props.textValue && e.instance.state.focused) {
let string = e.instance.props.textValue;
if (string.length > 0) {
let newstring = string;
let first = string.charAt(0);
if (first === first.toUpperCase() && (string.toLowerCase().indexOf("http") == 0 || string.toLowerCase().indexOf("s/") == 0)) newstring = string.charAt(0).toLowerCase() + string.slice(1);
else if (first === first.toLowerCase() && first !== first.toUpperCase() && string.toLowerCase().indexOf("http") != 0 && string.toLowerCase().indexOf("s/") != 0) newstring = string.charAt(0).toUpperCase() + string.slice(1);
if (string != newstring) {
e.instance.props.textValue = newstring;
if (e.instance.props.richValue) e.instance.props.richValue = BDFDB.SlateUtils.copyRichValue(newstring, e.instance.props.richValue);
}
}
}
}
}
}
})();
module.exports = WriteUpperCase;
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();