This commit is contained in:
Mirco Wittrien 2019-10-22 18:55:25 +02:00
parent ff2f700d94
commit ab2e9fb033
52 changed files with 1002 additions and 1150 deletions

View File

@ -1,7 +1,7 @@
if (window.BDFDB && BDFDB.ListenerUtils && typeof BDFDB.ListenerUtils.remove == "function") BDFDB.ListenerUtils.remove(BDFDB); if (window.BDFDB && BDFDB.ListenerUtils && typeof BDFDB.ListenerUtils.remove == "function") BDFDB.ListenerUtils.remove(BDFDB);
if (window.BDFDB && BDFDB.ObserverUtils && typeof BDFDB.ObserverUtils.disconnect == "function") BDFDB.ObserverUtils.disconnect(BDFDB); if (window.BDFDB && BDFDB.ObserverUtils && typeof BDFDB.ObserverUtils.disconnect == "function") BDFDB.ObserverUtils.disconnect(BDFDB);
if (window.BDFDB && BDFDB.ModuleUtils && typeof BDFDB.ModuleUtils.unpatch == "function") BDFDB.ModuleUtils.unpatch(BDFDB); if (window.BDFDB && BDFDB.ModuleUtils && typeof BDFDB.ModuleUtils.unpatch == "function") BDFDB.ModuleUtils.unpatch(BDFDB);
var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB.cleanUps || {}, BDv2Api: BDFDB && BDFDB.BDv2Api || undefined, creationTime: performance.now(), cachedData: {}, pressedKeys: [], mousePosition: {pageX: 0, pageY: 0}, name: "$BDFDB"}; var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.BDv2Api || undefined, creationTime: performance.now(), cachedData: {}, pressedKeys: [], mousePosition: {pageX: 0, pageY: 0}, name: "$BDFDB"};
(_ => { (_ => {
var id = Math.round(Math.random() * 10000000000000000), InternalBDFDB = {}; var id = Math.round(Math.random() * 10000000000000000), InternalBDFDB = {};
BDFDB.id = id; BDFDB.id = id;
@ -79,7 +79,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
if (BDFDB.ObjectUtils.isEmpty(window.PluginUpdates.plugins)) BDFDB.removeEles("#bd-settingspane-container .bd-updatebtn" + BDFDB.dotCN._repofolderbutton); if (BDFDB.ObjectUtils.isEmpty(window.PluginUpdates.plugins)) BDFDB.removeEles("#bd-settingspane-container .bd-updatebtn" + BDFDB.dotCN._repofolderbutton);
delete plugin.started; delete plugin.started;
BDFDB.cleanUps[plugin.name] = setImmediate(() => { setImmediate(() => {
BDFDB.ModuleUtils.unpatch(plugin); BDFDB.ModuleUtils.unpatch(plugin);
delete plugin.stopping; delete plugin.stopping;
}); });
@ -244,8 +244,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
delete plugin.startTimeout; delete plugin.startTimeout;
clearTimeout(plugin.libLoadTimeout); clearTimeout(plugin.libLoadTimeout);
delete plugin.libLoadTimeout; delete plugin.libLoadTimeout;
clearImmediate(BDFDB.cleanUps[plugin.name]);
delete BDFDB.cleanUps[plugin.name];
}; };
InternalBDFDB.addOnSwitchListener = function (plugin) { InternalBDFDB.addOnSwitchListener = function (plugin) {
if (BDFDB.ObjectUtils.is(plugin) && typeof plugin.onSwitch === "function") { if (BDFDB.ObjectUtils.is(plugin) && typeof plugin.onSwitch === "function") {
@ -1460,6 +1458,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}}); }});
BDFDB.ModuleUtils.patch(BDFDB, module.prototype, "render", {after: e => { BDFDB.ModuleUtils.patch(BDFDB, module.prototype, "render", {after: e => {
if (e.thisObject.props.BDFDBcontextMenu && e.thisObject.props.children && e.returnValue && e.returnValue.props) { if (e.thisObject.props.BDFDBcontextMenu && e.thisObject.props.children && e.returnValue && e.returnValue.props) {
console.log(e);
e.returnValue.props.children = e.thisObject.props.children; e.returnValue.props.children = e.thisObject.props.children;
delete e.thisObject.props.value; delete e.thisObject.props.value;
delete e.thisObject.props.children; delete e.thisObject.props.children;
@ -1512,9 +1511,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}}); }});
} }
}; };
for (let type of NoFluxContextMenus) InternalBDFDB.patchContextMenuLib(BDFDB.ModuleUtils.findByName(type), false);
for (let type of NoFluxPopouts) InternalBDFDB.patchPopoutLib(BDFDB.ModuleUtils.findByName(type), false);
for (let type of FluxContextMenus) InternalBDFDB.patchContextMenuLib(BDFDB.ModuleUtils.findByName(`FluxContainer(${type})`), true);
BDFDB.equals = function (mainA, mainB, sorted) { BDFDB.equals = function (mainA, mainB, sorted) {
var i = -1; var i = -1;
@ -1795,7 +1791,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}; };
BDFDB.FolderUtils.getDiv = function (eleOrInfoOrId) { BDFDB.FolderUtils.getDiv = function (eleOrInfoOrId) {
if (!eleOrInfoOrId) return null; if (!eleOrInfoOrId) return null;
let info = BDFDB.getFolderData(eleOrInfoOrId); let info = BDFDB.FolderUtils.getData(eleOrInfoOrId);
return info ? info.div : null; return info ? info.div : null;
}; };
BDFDB.FolderUtils.getData = function (eleOrInfoOrId) { BDFDB.FolderUtils.getData = function (eleOrInfoOrId) {
@ -1814,12 +1810,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}; };
BDFDB.ChannelUtils = {}; BDFDB.ChannelUtils = {};
BDFDB.ChannelUtils.getIcon = function (id) {
var channel = LibraryModules.ChannelStore.getChannel(id = typeof id == "number" ? id.toFixed() : id);
if (!channel) return null;
if (!channel.icon) return channel.type == 1 ? BDFDB.UserUtils.getAvatar(channel.recipients[0]) : (channel.type == 3 ? "https://discordapp.com/assets/f046e2247d730629309457e902d5c5b3.svg" : null);
return LibraryModules.IconUtils.getChannelIconURL(channel).split("?")[0];
};
BDFDB.ChannelUtils.getId = function (div) { BDFDB.ChannelUtils.getId = function (div) {
if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return; if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return;
div = BDFDB.getParentEle(BDFDB.dotCNC.categorycontainerdefault + BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.dmchannel, div); div = BDFDB.getParentEle(BDFDB.dotCNC.categorycontainerdefault + BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.dmchannel, div);
@ -1874,6 +1864,12 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}; };
BDFDB.DmUtils = {}; BDFDB.DmUtils = {};
BDFDB.DmUtils.getIcon = function (id) {
var channel = LibraryModules.ChannelStore.getChannel(id = typeof id == "number" ? id.toFixed() : id);
if (!channel) return null;
if (!channel.icon) return channel.type == 1 ? BDFDB.UserUtils.getAvatar(channel.recipients[0]) : (channel.type == 3 ? "https://discordapp.com/assets/f046e2247d730629309457e902d5c5b3.svg" : null);
return LibraryModules.IconUtils.getChannelIconURL(channel).split("?")[0];
};
BDFDB.DmUtils.getId = function (div) { BDFDB.DmUtils.getId = function (div) {
if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return; if (!Node.prototype.isPrototypeOf(div) || !BDFDB.ReactUtils.getInstance(div)) return;
let dmdiv = BDFDB.getParentEle(BDFDB.dotCN.guildouter, div); let dmdiv = BDFDB.getParentEle(BDFDB.dotCN.guildouter, div);
@ -7111,6 +7107,10 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
}; };
InternalBDFDB.patchPlugin(BDFDB); InternalBDFDB.patchPlugin(BDFDB);
for (let type of NoFluxContextMenus) InternalBDFDB.patchContextMenuLib(BDFDB.ModuleUtils.findByName(type), false);
for (let type of NoFluxPopouts) InternalBDFDB.patchPopoutLib(BDFDB.ModuleUtils.findByName(type), false);
for (let type of FluxContextMenus) InternalBDFDB.patchContextMenuLib(BDFDB.ModuleUtils.findByName(`FluxContainer(${type})`), true);
BDFDB.ModuleUtils.forceAllUpdates(BDFDB); BDFDB.ModuleUtils.forceAllUpdates(BDFDB);
@ -7294,9 +7294,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.sortObject = BDFDB.ObjectUtils.sort; BDFDB.sortObject = BDFDB.ObjectUtils.sort;
BDFDB.reverseObject = BDFDB.ObjectUtils.reverse; BDFDB.reverseObject = BDFDB.ObjectUtils.reverse;
BDFDB.filterObject = BDFDB.ObjectUtils.filter; BDFDB.filterObject = BDFDB.ObjectUtils.filter;
BDFDB.pushToObject = BDFDB.ObjectUtils.push;
BDFDB.mapObject = BDFDB.ObjectUtils.map; BDFDB.mapObject = BDFDB.ObjectUtils.map;
BDFDB.deepAssign = BDFDB.ObjectUtils.deepAssign;
BDFDB.isObjectEmpty = BDFDB.ObjectUtils.isEmpty; BDFDB.isObjectEmpty = BDFDB.ObjectUtils.isEmpty;
BDFDB.sortArrayByKey = BDFDB.ArrayUtils.keySort; BDFDB.sortArrayByKey = BDFDB.ArrayUtils.keySort;
@ -7315,7 +7313,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.WebModules = Object.assign({}, BDFDB.ModuleUtils); BDFDB.WebModules = Object.assign({}, BDFDB.ModuleUtils);
BDFDB.WebModules.patch = (module, modulefunctions, plugin, patchfunctions) => {return BDFDB.ModuleUtils.patch(plugin, module, modulefunctions, patchfunctions)}; BDFDB.WebModules.patch = (module, modulefunctions, plugin, patchfunctions) => {return BDFDB.ModuleUtils.patch(plugin, module, modulefunctions, patchfunctions)};
BDFDB.WebModules.unpatchall = BDFDB.ModuleUtils.unpatch;
BDFDB.ModuleUtils.initiateProcess = InternalBDFDB.initiateProcess; BDFDB.ModuleUtils.initiateProcess = InternalBDFDB.initiateProcess;
BDFDB.WebModules.initiateProcess = InternalBDFDB.initiateProcess; BDFDB.WebModules.initiateProcess = InternalBDFDB.initiateProcess;
@ -7327,7 +7324,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.getGuildIcon = BDFDB.GuildUtils.getIcon; BDFDB.getGuildIcon = BDFDB.GuildUtils.getIcon;
BDFDB.getGuildBanner = BDFDB.GuildUtils.getBanner; BDFDB.getGuildBanner = BDFDB.GuildUtils.getBanner;
BDFDB.getServerID = BDFDB.GuildUtils.getId;
BDFDB.getServerDiv = BDFDB.GuildUtils.getDiv; BDFDB.getServerDiv = BDFDB.GuildUtils.getDiv;
BDFDB.getServerData = BDFDB.GuildUtils.getData; BDFDB.getServerData = BDFDB.GuildUtils.getData;
BDFDB.readServerList = BDFDB.GuildUtils.getAll; BDFDB.readServerList = BDFDB.GuildUtils.getAll;
@ -7341,21 +7337,14 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.getFolderID = BDFDB.FolderUtils.getId; BDFDB.getFolderID = BDFDB.FolderUtils.getId;
BDFDB.getFolderDiv = BDFDB.FolderUtils.getDiv; BDFDB.getFolderDiv = BDFDB.FolderUtils.getDiv;
BDFDB.getFolderData = BDFDB.FolderUtils.getData;
BDFDB.readFolderList = BDFDB.FolderUtils.getAll;
BDFDB.getChannelIcon = BDFDB.ChannelUtils.getIcon;
BDFDB.getChannelID = BDFDB.ChannelUtils.getId;
BDFDB.getChannelDiv = BDFDB.ChannelUtils.getDiv; BDFDB.getChannelDiv = BDFDB.ChannelUtils.getDiv;
BDFDB.getChannelData = BDFDB.ChannelUtils.getData;
BDFDB.readChannelList = BDFDB.ChannelUtils.getAll;
BDFDB.getSelectedChannel = BDFDB.ChannelUtils.getSelected; BDFDB.getSelectedChannel = BDFDB.ChannelUtils.getSelected;
BDFDB.openChannelContextMenu = BDFDB.ChannelUtils.openMenu; BDFDB.openChannelContextMenu = BDFDB.ChannelUtils.openMenu;
BDFDB.markChannelAsRead = BDFDB.ChannelUtils.markAsRead; BDFDB.markChannelAsRead = BDFDB.ChannelUtils.markAsRead;
BDFDB.getDmID = BDFDB.DmUtils.getId;
BDFDB.getDmDiv = BDFDB.DmUtils.getDiv; BDFDB.getDmDiv = BDFDB.DmUtils.getDiv;
BDFDB.getDmData = BDFDB.DmUtils.getData; BDFDB.getChannelIcon = BDFDB.DmUtils.getIcon;
BDFDB.readDmList = BDFDB.DmUtils.getAll; BDFDB.readDmList = BDFDB.DmUtils.getAll;
BDFDB.saveAllData = (data, plugin, key) => {BDFDB.DataUtils.save(data, plugin, key)}; BDFDB.saveAllData = (data, plugin, key) => {BDFDB.DataUtils.save(data, plugin, key)};
@ -7367,9 +7356,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.getAllData = (plugin, key) => {return BDFDB.DataUtils.get(plugin, key)}; BDFDB.getAllData = (plugin, key) => {return BDFDB.DataUtils.get(plugin, key)};
BDFDB.getData = (id, plugin, key) => {return BDFDB.DataUtils.get(plugin, key, id)}; BDFDB.getData = (id, plugin, key) => {return BDFDB.DataUtils.get(plugin, key, id)};
BDFDB.getDiscordFolder = BDFDB.DiscordUtils.getFolder;
BDFDB.getDiscordBuilt = BDFDB.DiscordUtils.getBuilt;
BDFDB.getDiscordVersion = BDFDB.DiscordUtils.getVersion;
BDFDB.getDiscordTheme = BDFDB.DiscordUtils.getTheme; BDFDB.getDiscordTheme = BDFDB.DiscordUtils.getTheme;
BDFDB.getDiscordMode = BDFDB.DiscordUtils.getMode; BDFDB.getDiscordMode = BDFDB.DiscordUtils.getMode;
BDFDB.getDiscordZoomFactor = BDFDB.DiscordUtils.getZoomFactor; BDFDB.getDiscordZoomFactor = BDFDB.DiscordUtils.getZoomFactor;
@ -7377,8 +7363,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, cleanUps: BDFDB && BDFDB
BDFDB.getPluginsFolder = BDFDB.BdUtils.getPluginsFolder; BDFDB.getPluginsFolder = BDFDB.BdUtils.getPluginsFolder;
BDFDB.getThemesFolder = BDFDB.BdUtils.getThemesFolder; BDFDB.getThemesFolder = BDFDB.BdUtils.getThemesFolder;
BDFDB.checkWhichRepoPage = BDFDB.BdUtils.checkRepoPage;
BDFDB.isBDv2 = BDFDB.BdUtils.isBDv2;
BDFDB.isPluginEnabled = BDFDB.BdUtils.isPluginEnabled; BDFDB.isPluginEnabled = BDFDB.BdUtils.isPluginEnabled;
BDFDB.getPlugin = BDFDB.BdUtils.getPlugin; BDFDB.getPlugin = BDFDB.BdUtils.getPlugin;
BDFDB.isThemeEnabled = BDFDB.BdUtils.isThemeEnabled; BDFDB.isThemeEnabled = BDFDB.BdUtils.isThemeEnabled;

File diff suppressed because one or more lines are too long

View File

@ -130,41 +130,41 @@ class BadgesEverywhere {
var indicators = BDFDB.getAllData(this, "indicators"); var indicators = BDFDB.getAllData(this, "indicators");
var settingsitems = [], inneritems = []; var settingsitems = [], inneritems = [];
for (let key in settings) settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["settings", key], keys: ["settings", key],
label: this.defaults.settings[key].description, label: this.defaults.settings[key].description,
value: settings[key] value: settings[key]
})); }));
for (let flag in badges) inneritems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let flag in badges) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["badges", flag], keys: ["badges", flag],
label: this.defaults.badges[flag].name, label: this.defaults.badges[flag].name,
value: badges[flag], value: badges[flag],
labelchildren: [ labelchildren: [
BDFDB.React.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionplaying}" style="all: unset !important;">${Array.isArray(this.defaults.badges[flag].types) ? this.defaults.badges[flag].types.map(rank => this.createBadge("settings", flag, rank)).join("") : this.createBadge("settings", flag)}</span>`)), BDFDB.ReactUtils.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionplaying}" style="all: unset !important;">${Array.isArray(this.defaults.badges[flag].types) ? this.defaults.badges[flag].types.map(rank => this.createBadge("settings", flag, rank)).join("") : this.createBadge("settings", flag)}</span>`)),
BDFDB.React.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;">${Array.isArray(this.defaults.badges[flag].types) ? this.defaults.badges[flag].types.map(rank => this.createBadge("settings", flag, rank)).join("") : this.createBadge("settings", flag)}</span>`)) BDFDB.ReactUtils.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;">${Array.isArray(this.defaults.badges[flag].types) ? this.defaults.badges[flag].types.map(rank => this.createBadge("settings", flag, rank)).join("") : this.createBadge("settings", flag)}</span>`))
] ]
})); }));
for (let flag in indicators) inneritems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let flag in indicators) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["indicators", flag], keys: ["indicators", flag],
label: this.defaults.indicators[flag].name, label: this.defaults.indicators[flag].name,
value: indicators[flag], value: indicators[flag],
labelchildren: [ labelchildren: [
BDFDB.React.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionplaying}" style="all: unset !important;">${this.createBadge("settings", flag)}</span>`)), BDFDB.ReactUtils.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionplaying}" style="all: unset !important;">${this.createBadge("settings", flag)}</span>`)),
BDFDB.React.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;">${this.createBadge("settings", flag)}</span>`)) BDFDB.ReactUtils.elementToReact(BDFDB.htmlToElement(`<span class="BE-badges BE-badges-settings ${BDFDB.disCN.userprofiletopsectionnormal}" style="all: unset !important;">${this.createBadge("settings", flag)}</span>`))
] ]
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Display Badges:", title: "Display Badges:",
children: inneritems children: inneritems
})); }));
return BDFDB.createSettingsPanel(this, settingsitems); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
} }
//legacy //legacy
@ -191,15 +191,13 @@ class BadgesEverywhere {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.BadgeClasses = BDFDB.WebModules.findByProperties("profileBadgeStaff", "profileBadgePremium"); this.BadgeClasses = BDFDB.ModuleUtils.findByProperties("profileBadgeStaff", "profileBadgePremium");
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -207,7 +205,7 @@ class BadgesEverywhere {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".BE-badges"); BDFDB.removeEles(".BE-badges");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -219,7 +217,7 @@ class BadgesEverywhere {
} }
processMessageUsername (instance, wrapper, returnvalue) { processMessageUsername (instance, wrapper, returnvalue) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message) { if (message) {
let username = wrapper.querySelector(BDFDB.dotCN.messageusername); let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
if (username && BDFDB.getData("showInChat", this, "settings")) this.addBadges(message.author, wrapper, "chat"); if (username && BDFDB.getData("showInChat", this, "settings")) this.addBadges(message.author, wrapper, "chat");
@ -233,7 +231,7 @@ class BadgesEverywhere {
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -260,10 +258,8 @@ class BadgesEverywhere {
} }
else if (!this.loadedusers[info.id]) { else if (!this.loadedusers[info.id]) {
this.requestedusers[info.id].push([wrapper,type]); this.requestedusers[info.id].push([wrapper,type]);
} });
else { else this.addToWrapper(info, wrapper, type);
this.addToWrapper(info, wrapper, type);
}
} }
addToWrapper (info, wrapper, type) { addToWrapper (info, wrapper, type) {
@ -281,7 +277,7 @@ class BadgesEverywhere {
let text = this.defaults.badges[flag].name; let text = this.defaults.badges[flag].name;
if (flag == this.nitroflag && settings.showNitroDate) text = BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_BADGE_TOOLTIP", new Date(this.loadedusers[info.id].premium_since)); if (flag == this.nitroflag && settings.showNitroDate) text = BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_BADGE_TOOLTIP", new Date(this.loadedusers[info.id].premium_since));
else if (flag == this.boostflag && settings.showNitroDate) text = BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(this.loadedusers[info.id].premium_guild_since)); else if (flag == this.boostflag && settings.showNitroDate) text = BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(this.loadedusers[info.id].premium_guild_since));
BDFDB.createTooltip(text, badge, {type:"top", style:"white-space: nowrap; max-width: unset"}); BDFDB.TooltipUtils.create(badge, text, {type:"top", style:"white-space: nowrap; max-width: unset"});
}); });
} }
} }
@ -289,7 +285,9 @@ class BadgesEverywhere {
if (indicators.CURRENT_GUILD_BOOST && member && member.premiumSince) { if (indicators.CURRENT_GUILD_BOOST && member && member.premiumSince) {
let badge = BDFDB.htmlToElement(this.createBadge(type, "CURRENT_GUILD_BOOST")); let badge = BDFDB.htmlToElement(this.createBadge(type, "CURRENT_GUILD_BOOST"));
badgewrapper.appendChild(badge); badgewrapper.appendChild(badge);
badge.addEventListener("mouseenter", () => {BDFDB.createTooltip(settings.showNitroDate ? BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(member.premiumSince)) : "Boosting current server", badge, {type:"top", style:"white-space: nowrap; max-width: unset"});}); badge.addEventListener("mouseenter", () => {
BDFDB.TooltipUtils.create(badge, settings.showNitroDate ? BDFDB.LanguageUtils.LanguageStringsFormat("PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP", new Date(member.premiumSince)) : "Boosting current server", {type:"top", style:"white-space: nowrap; max-width: unset"});
});
} }
if (badgewrapper.firstChild) { if (badgewrapper.firstChild) {
if (header) { if (header) {

View File

@ -49,13 +49,11 @@ class BetterFriendCount {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this, 'TabBar'); BDFDB.ModuleUtils.forceAllUpdates(this, 'TabBar');
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -63,7 +61,7 @@ class BetterFriendCount {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".betterfriendcount-badge"); BDFDB.removeEles(".betterfriendcount-badge");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -79,29 +77,29 @@ class BetterFriendCount {
let newchildren = [Array.isArray(child.props.children) ? child.props.children[0] : child.props.children]; let newchildren = [Array.isArray(child.props.children) ? child.props.children[0] : child.props.children];
switch (child.props.id) { switch (child.props.id) {
case "ALL": case "ALL":
newchildren.push(BDFDB.React.createElement(BDFDB.LibraryComponents.NumberBadge, { newchildren.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.NumberBadge, {
className: BDFDB.disCN.settingstabbarbadge, className: BDFDB.disCN.settingstabbarbadge,
count: relationshipCount.FRIEND count: relationshipCount.FRIEND
})); }));
break; break;
case "ONLINE": case "ONLINE":
newchildren.push(BDFDB.React.createElement(BDFDB.LibraryComponents.NumberBadge, { newchildren.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.NumberBadge, {
className: BDFDB.disCN.settingstabbarbadge, className: BDFDB.disCN.settingstabbarbadge,
count: BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount() count: BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount()
})); }));
break; break;
case "PENDING": case "PENDING":
newchildren.push(BDFDB.React.createElement(BDFDB.LibraryComponents.NumberBadge, { newchildren.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.NumberBadge, {
className: BDFDB.disCN.settingstabbarbadge, className: BDFDB.disCN.settingstabbarbadge,
count: relationshipCount.PENDING_INCOMING count: relationshipCount.PENDING_INCOMING
})); }));
newchildren.push(BDFDB.React.createElement(BDFDB.LibraryComponents.NumberBadge, { newchildren.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.NumberBadge, {
className: BDFDB.disCN.settingstabbarbadge, className: BDFDB.disCN.settingstabbarbadge,
count: relationshipCount.PENDING_OUTGOING count: relationshipCount.PENDING_OUTGOING
})); }));
break; break;
case "BLOCKED": case "BLOCKED":
newchildren.push(BDFDB.React.createElement(BDFDB.LibraryComponents.NumberBadge, { newchildren.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.NumberBadge, {
className: BDFDB.disCN.settingstabbarbadge, className: BDFDB.disCN.settingstabbarbadge,
count: relationshipCount.BLOCKED count: relationshipCount.BLOCKED
})); }));
@ -116,7 +114,7 @@ class BetterFriendCount {
clearTimeout(this.rerenderTimeout); clearTimeout(this.rerenderTimeout);
this.rerenderTimeout = setTimeout(() => { this.rerenderTimeout = setTimeout(() => {
delete this.rerenderTimeout; delete this.rerenderTimeout;
BDFDB.WebModules.forceAllUpdates(this, 'TabBar'); BDFDB.ModuleUtils.forceAllUpdates(this, 'TabBar');
}, 1000); }, 1000);
} }
} }

View File

@ -43,13 +43,11 @@ class BetterNsfwTag {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -57,7 +55,7 @@ class BetterNsfwTag {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".NSFW-tag"); BDFDB.removeEles(".NSFW-tag");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }

View File

@ -106,13 +106,11 @@ class BetterSearchPage {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -120,7 +118,7 @@ class BetterSearchPage {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".BSP-pagination",".BSP-pagination-button",".BSP-pagination-jumpinput"); BDFDB.removeEles(".BSP-pagination",".BSP-pagination-button",".BSP-pagination-jumpinput");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -135,7 +133,7 @@ class BetterSearchPage {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.removeEles(".BSP-pagination",".BSP-pagination-button",".BSP-pagination-jumpinput"); BDFDB.removeEles(".BSP-pagination",".BSP-pagination-button",".BSP-pagination-jumpinput");
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -151,7 +149,7 @@ class BetterSearchPage {
currentpage = currentpage < maxpage ? currentpage : maxpage; currentpage = currentpage < maxpage ? currentpage : maxpage;
maxpage = temppage < maxpage ? maxpage : temppage; maxpage = temppage < maxpage ? maxpage : temppage;
if (maxpage > 201) { if (maxpage > 201) {
if (currentpage == 201) BDFDB.showToast("Discord doesn't allow you to go further than page 201.",{type:"error"}); if (currentpage == 201) BDFDB.NotificationUtils.toast("Discord doesn't allow you to go further than page 201.",{type:"error"});
maxpage = 201; maxpage = 201;
} }
if (currentpage == maxpage && maxpage == 201) BDFDB.addClass(pagination.querySelector(BDFDB.dotCN.searchresultspaginationnext), BDFDB.disCN.searchresultspaginationdisabled); if (currentpage == maxpage && maxpage == 201) BDFDB.addClass(pagination.querySelector(BDFDB.dotCN.searchresultspaginationnext), BDFDB.disCN.searchresultspaginationdisabled);
@ -176,7 +174,7 @@ class BetterSearchPage {
let value = input.value; let value = input.value;
if (value < 1 || value > maxpage) { if (value < 1 || value > maxpage) {
input.value = currentpage; input.value = currentpage;
if (maxpage == 201 && value > maxpage) BDFDB.showToast("Discord doesn't allow you to go further than page 201.",{type:"error"}); if (maxpage == 201 && value > maxpage) BDFDB.NotificationUtils.toast("Discord doesn't allow you to go further than page 201.",{type:"error"});
} }
else if (value < currentpage) { else if (value < currentpage) {
for (; currentpage - value > 0; value++) { for (; currentpage - value > 0; value++) {
@ -189,31 +187,31 @@ class BetterSearchPage {
} }
} }
}; };
BDFDB.addEventListener(this, searchResultsWrapper, "click", BDFDB.dotCN.searchresultspaginationdisabled, e => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", BDFDB.dotCN.searchresultspaginationdisabled, e => {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationprevious + BDFDB.notCN.searchresultspaginationdisabled}`, () => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationprevious + BDFDB.notCN.searchresultspaginationdisabled}`, () => {
BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(searchId); BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(searchId);
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationnext + BDFDB.notCN.searchresultspaginationdisabled}`, () => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", `.BSP-pagination ${BDFDB.dotCN.searchresultspaginationnext + BDFDB.notCN.searchresultspaginationdisabled}`, () => {
BDFDB.LibraryModules.SearchPageUtils.searchNextPage(searchId); BDFDB.LibraryModules.SearchPageUtils.searchNextPage(searchId);
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-first${BDFDB.notCN.searchresultspaginationdisabled}`, () => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", `.BSP-pagination-first${BDFDB.notCN.searchresultspaginationdisabled}`, () => {
for (let i = 0; currentpage - 1 - i > 0; i++) BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(searchId); for (let i = 0; currentpage - 1 - i > 0; i++) BDFDB.LibraryModules.SearchPageUtils.searchPreviousPage(searchId);
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-last${BDFDB.notCN.searchresultspaginationdisabled}`, () => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", `.BSP-pagination-last${BDFDB.notCN.searchresultspaginationdisabled}`, () => {
for (let i = 0; maxpage - currentpage - i > 0; i++) BDFDB.LibraryModules.SearchPageUtils.searchNextPage(searchId); for (let i = 0; maxpage - currentpage - i > 0; i++) BDFDB.LibraryModules.SearchPageUtils.searchNextPage(searchId);
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "click", `.BSP-pagination-jump${BDFDB.notCN.searchresultspaginationdisabled}`, e => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "click", `.BSP-pagination-jump${BDFDB.notCN.searchresultspaginationdisabled}`, e => {
doJump(e.currentTarget.parentElement.querySelector(`.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`)); doJump(e.currentTarget.parentElement.querySelector(`.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`));
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "keydown", `.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`, e => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "keydown", `.BSP-pagination-jumpinput ${BDFDB.dotCN.inputmini}`, e => {
let label = e.currentTarget.getAttribute("aria-label"); let label = e.currentTarget.getAttribute("aria-label");
if (label) BDFDB.createTooltip(label, e.currentTarget, {type:"top"}); if (label) BDFDB.TooltipUtils.create(e.currentTarget, label, {type:"top"});
}); });
BDFDB.addEventListener(this, searchResultsWrapper, "mouseenter", `.pagination-button${BDFDB.notCN.searchresultspaginationdisabled}`, e => { BDFDB.ListenerUtils.add(this, searchResultsWrapper, "mouseenter", `.pagination-button${BDFDB.notCN.searchresultspaginationdisabled}`, e => {
let label = e.currentTarget.getAttribute("aria-label"); let label = e.currentTarget.getAttribute("aria-label");
if (label) BDFDB.createTooltip(label, e.currentTarget, {type:"top"}); if (label) BDFDB.TooltipUtils.create(e.currentTarget, label, {type:"top"});
}); });
} }
} }

View File

@ -109,13 +109,11 @@ class CharCounter {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -125,7 +123,7 @@ class CharCounter {
BDFDB.removeEles(".charcounter"); BDFDB.removeEles(".charcounter");
BDFDB.removeClasses("charcounter-added"); BDFDB.removeClasses("charcounter-added");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -168,25 +166,25 @@ class CharCounter {
BDFDB.addClass(input.parentElement.parentElement, "charcounter-added"); BDFDB.addClass(input.parentElement.parentElement, "charcounter-added");
if (type == "nickname") input.setAttribute("maxlength", 32); if (type == "nickname") input.setAttribute("maxlength", 32);
BDFDB.addEventListener(this, input, "keydown click change", e => { BDFDB.ListenerUtils.add(this, input, "keydown click change", e => {
clearTimeout(input.charcountertimeout); clearTimeout(input.charcountertimeout);
input.charcountertimeout = setTimeout(() => {updateCounter();},100); input.charcountertimeout = setTimeout(() => {updateCounter();},100);
}); });
BDFDB.addEventListener(this, input, "mousedown", e => { BDFDB.ListenerUtils.add(this, input, "mousedown", e => {
BDFDB.addEventListener(this, document, "mouseup", () => { BDFDB.ListenerUtils.add(this, document, "mouseup", () => {
BDFDB.removeEventListener(this, document); BDFDB.ListenerUtils.remove(this, document);
if (input.selectionEnd - input.selectionStart) setImmediate(() => {BDFDB.addEventListener(this, document, "click", () => { if (input.selectionEnd - input.selectionStart) setImmediate(() => {BDFDB.ListenerUtils.add(this, document, "click", () => {
var contexttype = BDFDB.getReactValue(document.querySelector(BDFDB.dotCN.contextmenu), "return.stateNode.props.type"); var contexttype = BDFDB.ReactUtils.getValue(document.querySelector(BDFDB.dotCN.contextmenu), "return.stateNode.props.type");
if (!contexttype || !contexttype.startsWith("CHANNEL_TEXT_AREA")) { if (!contexttype || !contexttype.startsWith("CHANNEL_TEXT_AREA")) {
input.selectionStart = 0; input.selectionStart = 0;
input.selectionEnd = 0; input.selectionEnd = 0;
updateCounter(); updateCounter();
} }
else setTimeout(() => {updateCounter();},100); else setTimeout(() => {updateCounter();},100);
BDFDB.removeEventListener(this, document); BDFDB.ListenerUtils.remove(this, document);
});}); });});
}); });
BDFDB.addEventListener(this, document, "mousemove", () => {setTimeout(() => {updateCounter();},10);}); BDFDB.ListenerUtils.add(this, document, "mousemove", () => {setTimeout(() => {updateCounter();},10);});
}); });
updateCounter(); updateCounter();

View File

@ -74,7 +74,7 @@ class ChatAliases {
<input id="input-file" type="file" style="display:none!important;"> <input id="input-file" type="file" style="display:none!important;">
</button> </button>
</div> </div>
${BDFDB.removeFromArray(Object.keys(this.defaults.configs), "file").map((key, i) => ${BDFDB.ArrayUtils.remove(Object.keys(this.defaults.configs), "file").map((key, i) =>
`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"> `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">
<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.configs[key].description}</h3> <h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.configs[key].description}</h3>
<div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"> <div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;">
@ -128,11 +128,11 @@ class ChatAliases {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.gamenameinput, e => {this.updateWord(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.gamenameinput, e => {this.updateWord(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
return settingspanel; return settingspanel;
} }
@ -160,19 +160,17 @@ class ChatAliases {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.aliases = BDFDB.loadAllData(this, "words"); this.aliases = BDFDB.loadAllData(this, "words");
BDFDB.addEventListener(document, "click", e => { BDFDB.ListenerUtils.add(document, "click", e => {
if (!e.target.tagName === "TEXTAREA") BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow"); if (!e.target.tagName === "TEXTAREA") BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
}); });
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -180,7 +178,7 @@ class ChatAliases {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow"); BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -305,10 +303,10 @@ class ChatAliases {
appendItem (menu, returnvalue, text) { appendItem (menu, returnvalue, text) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: "Add to ChatAliases", label: "Add to ChatAliases",
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addalias-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addalias-contextMenuItem`,
action: e => { action: e => {
@ -325,7 +323,7 @@ class ChatAliases {
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -334,7 +332,7 @@ class ChatAliases {
var textarea = wrapper.querySelector("textarea"); var textarea = wrapper.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
BDFDB.addEventListener(this, textarea, "input", () => { BDFDB.ListenerUtils.add(this, textarea, "input", () => {
if (this.format) { if (this.format) {
this.format = false; this.format = false;
textarea.focus(); textarea.focus();
@ -346,18 +344,18 @@ class ChatAliases {
if (messageInput.text != null) { if (messageInput.text != null) {
document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : ""); document.execCommand("insertText", false, messageInput.text ? messageInput.text + " " : "");
} }
if (messageInput.files.length > 0 && (instance.props.channel.type == 1 || BDFDB.isUserAllowedTo("ATTACH_FILES"))) { if (messageInput.files.length > 0 && (instance.props.channel.type == 1 || BDFDB.UserUtils.can("ATTACH_FILES"))) {
BDFDB.LibraryModules.UploadUtils.instantBatchUpload(instance.props.channel.id, messageInput.files); BDFDB.LibraryModules.UploadUtils.instantBatchUpload(instance.props.channel.id, messageInput.files);
} }
} }
} }
} }
}); });
BDFDB.addEventListener(this, textarea, "keydown", e => { BDFDB.ListenerUtils.add(this, textarea, "keydown", e => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if (autocompletemenu && (e.which == 9 || e.which == 13)) { if (autocompletemenu && (e.which == 9 || e.which == 13)) {
if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteAliasesRow")) { if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteAliasesRow")) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
this.swapWordWithAlias(textarea); this.swapWordWithAlias(textarea);
} }
} }
@ -365,7 +363,7 @@ class ChatAliases {
let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteAliasesSelector)"); let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteAliasesSelector)");
let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected); let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected);
if (BDFDB.containsClass(selected, "autocompleteAliasesSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) { if (BDFDB.containsClass(selected, "autocompleteAliasesSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true); let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
@ -383,7 +381,7 @@ class ChatAliases {
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow"); if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteAliases", ".autocompleteAliasesRow");
}); });
BDFDB.addEventListener(this, textarea, "click", e => { BDFDB.ListenerUtils.add(this, textarea, "click", e => {
if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea);}); if (settings.addAutoComplete && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea);});
}); });
} }
@ -393,7 +391,7 @@ class ChatAliases {
if (!textarea.value || textarea.parentElement.querySelector(".autocompleteAliasesRow")) return; if (!textarea.value || textarea.parentElement.querySelector(".autocompleteAliasesRow")) return;
let words = textarea.value.split(/\s/); let words = textarea.value.split(/\s/);
let lastword = words[words.length-1].trim(); let lastword = words[words.length-1].trim();
if (words.length == 1 && BDFDB.isPluginEnabled("WriteUpperCase")) { if (words.length == 1 && BDFDB.BdUtils.isPluginEnabled("WriteUpperCase")) {
let first = lastword.charAt(0); let first = lastword.charAt(0);
if (first === first.toUpperCase() && lastword.toLowerCase().indexOf("http") == 0) { if (first === first.toUpperCase() && lastword.toLowerCase().indexOf("http") == 0) {
lastword = lastword.charAt(0).toLowerCase() + lastword.slice(1); lastword = lastword.charAt(0).toLowerCase() + lastword.slice(1);
@ -417,7 +415,7 @@ class ChatAliases {
} }
} }
} }
if (!BDFDB.isObjectEmpty(matchedaliases)) { if (!BDFDB.ObjectUtils.isEmpty(matchedaliases)) {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15; let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15;
if (!autocompletemenu) { if (!autocompletemenu) {
autocompletemenu = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocomplete + BDFDB.disCN.autocomplete2} autocompleteAliases"><div class="${BDFDB.disCN.autocompleteinner}"></div></div>`); autocompletemenu = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocomplete + BDFDB.disCN.autocomplete2} autocompleteAliases"><div class="${BDFDB.disCN.autocompleteinner}"></div></div>`);
@ -429,7 +427,7 @@ class ChatAliases {
} }
let autocompleterowheader = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCN.autocompleteselector} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.autocompletecontenttitle + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.weightsemibold}">Aliases: <strong class="lastword">${BDFDB.encodeToHTML(lastword)}</strong></div></div></div>`); let autocompleterowheader = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteAliasesRow"><div class="${BDFDB.disCN.autocompleteselector} autocompleteAliasesSelector"><div class="${BDFDB.disCNS.autocompletecontenttitle + BDFDB.disCNS.small + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCN.weightsemibold}">Aliases: <strong class="lastword">${BDFDB.encodeToHTML(lastword)}</strong></div></div></div>`);
autocompletemenu.appendChild(autocompleterowheader); autocompletemenu.appendChild(autocompleterowheader);
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => { BDFDB.ListenerUtils.add(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected); var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
@ -537,12 +535,12 @@ class ChatAliases {
let invalidinputs = []; let invalidinputs = [];
let type = ""; let type = "";
if (!wordvalueinput.value.trim()) { if (!wordvalueinput.value.trim()) {
BDFDB.removeFromArray(validinputs, wordvalueinput); BDFDB.ArrayUtils.remove(validinputs, wordvalueinput);
invalidinputs.push(wordvalueinput); invalidinputs.push(wordvalueinput);
type += "Wordvalue"; type += "Wordvalue";
} }
if (!replacevalueinput.value.trim()) { if (!replacevalueinput.value.trim()) {
BDFDB.removeFromArray(validinputs, replacevalueinput); BDFDB.ArrayUtils.remove(validinputs, replacevalueinput);
invalidinputs.push(replacevalueinput); invalidinputs.push(replacevalueinput);
type += ((type ? " and " : "") + "Replacevalue"); type += ((type ? " and " : "") + "Replacevalue");
} }
@ -559,12 +557,12 @@ class ChatAliases {
addbutton.disabled = true; addbutton.disabled = true;
BDFDB.addClass(invalidinputs, "invalid"); BDFDB.addClass(invalidinputs, "invalid");
addbutton.style.setProperty("pointer-events", "none", "important"); addbutton.style.setProperty("pointer-events", "none", "important");
BDFDB.createTooltip("Choose a " + type, addbutton, {type: "right", color: "red", selector: "chataliases-disabled-tooltip"}); BDFDB.TooltipUtils.create(addbutton, "Choose a " + type, {type: "right", color: "red", selector: "chataliases-disabled-tooltip"});
}; };
wordvalueinput.addEventListener("input", checkInputs); wordvalueinput.addEventListener("input", checkInputs);
replacevalueinput.addEventListener("input", checkInputs); replacevalueinput.addEventListener("input", checkInputs);
BDFDB.addChildEventListener(chataliasesAddModal, "click", BDFDB.dotCNC.backdrop + BDFDB.dotCNC.modalclose + ".btn-add", () => { BDFDB.ListenerUtils.addToChildren(chataliasesAddModal, "click", BDFDB.dotCNC.backdrop + BDFDB.dotCNC.modalclose + ".btn-add", () => {
BDFDB.removeEles(".chataliases-disabled-tooltip"); BDFDB.removeEles(".chataliases-disabled-tooltip");
}); });

View File

@ -143,11 +143,11 @@ class ChatFilter {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "keypress", ".wordInputs", e => {if (e.which == 13) this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "keyup", ".defaultInputs", e => {this.saveReplace(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", ".defaultInputs", e => {this.saveReplace(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-addword, .remove-word, .remove-all", e => {this.updateContainer(settingspanel, e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {this.updateConfig(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
return settingspanel; return settingspanel;
} }
@ -176,16 +176,14 @@ class ChatFilter {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.words = BDFDB.loadAllData(this, "words"); this.words = BDFDB.loadAllData(this, "words");
for (let rtype in this.defaults.replaces) if (!BDFDB.isObject(this.words[rtype])) this.words[rtype] = {}; for (let rtype in this.defaults.replaces) if (!BDFDB.ObjectUtils.is(this.words[rtype])) this.words[rtype] = {};
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -194,7 +192,7 @@ class ChatFilter {
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);}); document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -297,10 +295,10 @@ class ChatFilter {
appendItem (menu, returnvalue, text) { appendItem (menu, returnvalue, text) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: "Add to ChatFilter", label: "Add to ChatFilter",
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addalias-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addalias-contextMenuItem`,
action: e => { action: e => {
@ -322,7 +320,7 @@ class ChatFilter {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);}); document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -484,7 +482,7 @@ class ChatFilter {
addbutton.disabled = true; addbutton.disabled = true;
BDFDB.addClass(wordvalueinput, "invalid"); BDFDB.addClass(wordvalueinput, "invalid");
addbutton.style.setProperty("pointer-events", "none", "important"); addbutton.style.setProperty("pointer-events", "none", "important");
BDFDB.createTooltip("Choose a Wordvalue", {type: "right", color: "red", selector: "chatfilter-disabled-tooltip"}); BDFDB.TooltipUtils.create(wordvalueinput, "Choose a Wordvalue", {type: "right", color: "red", selector: "chatfilter-disabled-tooltip"});
} }
else { else {
addbutton.disabled = false; addbutton.disabled = false;
@ -494,7 +492,7 @@ class ChatFilter {
} }
}); });
BDFDB.addChildEventListener(chatfilterAddModal, "click", BDFDB.dotCNC.backdrop + BDFDB.dotCNC.modalclose + ".btn-add", () => { BDFDB.ListenerUtils.addToChildren(chatfilterAddModal, "click", BDFDB.dotCNC.backdrop + BDFDB.dotCNC.modalclose + ".btn-add", () => {
BDFDB.removeEles(".chatfilter-disabled-tooltip"); BDFDB.removeEles(".chatfilter-disabled-tooltip");
}); });
@ -508,7 +506,7 @@ class ChatFilter {
this.saveWord(wordvalueinput.value.trim(), replacevalueinput.value.trim(), rtype, configs); this.saveWord(wordvalueinput.value.trim(), replacevalueinput.value.trim(), rtype, configs);
BDFDB.saveAllData(this.words, this, "words"); BDFDB.saveAllData(this.words, this, "words");
document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);}); document.querySelectorAll(`${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored, ${BDFDB.dotCN.messagemarkup}.blocked, ${BDFDB.dotCN.messageaccessory}.censored`).forEach(message => {this.resetMessage(message);});
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}); });
wordvalueinput.focus(); wordvalueinput.focus();
} }

View File

@ -70,10 +70,10 @@ class CompleteTimestamps {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
}); });
return settingspanel; return settingspanel;
@ -104,11 +104,11 @@ class CompleteTimestamps {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.languages); this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.LanguageUtils.languages);
BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagecontent, e => { BDFDB.ListenerUtils.add(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messagecontent, e => {
if (BDFDB.getData("showOnHover", this, "settings")) { if (BDFDB.getData("showOnHover", this, "settings")) {
let message = e.currentTarget; let message = e.currentTarget;
let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, message); let messagegroup = BDFDB.getParentEle(BDFDB.dotCN.messagegroup, message);
@ -116,24 +116,22 @@ class CompleteTimestamps {
let info = this.getMessageData(message, messagegroup); let info = this.getMessageData(message, messagegroup);
if (!info || !info.timestamp || !info.timestamp._i) return; if (!info || !info.timestamp || !info.timestamp._i) return;
let choice = BDFDB.getData("creationDateLang", this, "choices"); let choice = BDFDB.getData("creationDateLang", this, "choices");
BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, info.timestamp._i), message, {type:"left", selector:"completetimestamp-tooltip"}); BDFDB.TooltipUtils.create(message, this.getTimestamp(this.languages[choice].id, info.timestamp._i), {type:"left", selector:"completetimestamp-tooltip"});
} }
}); });
BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messageedited, e => { BDFDB.ListenerUtils.add(this, document, "mouseenter", BDFDB.dotCNS.messagegroup + BDFDB.dotCN.messageedited, e => {
if (BDFDB.getData("changeForEdit", this, "settings")) { if (BDFDB.getData("changeForEdit", this, "settings")) {
let marker = e.currentTarget; let marker = e.currentTarget;
let time = marker.getAttribute("datetime"); let time = marker.getAttribute("datetime");
if (!time) return; if (!time) return;
let choice = BDFDB.getData("creationDateLang", this, "choices"); let choice = BDFDB.getData("creationDateLang", this, "choices");
BDFDB.createTooltip(this.getTimestamp(this.languages[choice].id, time), marker, {type:"top", selector:"completetimestampedit-tooltip"}); BDFDB.TooltipUtils.create(marker, this.getTimestamp(this.languages[choice].id, time), {type:"top", selector:"completetimestampedit-tooltip"});
} }
}); });
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -146,7 +144,7 @@ class CompleteTimestamps {
BDFDB.removeLocalStyle(this.name + "CompactCorrection"); BDFDB.removeLocalStyle(this.name + "CompactCorrection");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -193,7 +191,7 @@ class CompleteTimestamps {
} }
processEmbed (instance, wrapper, returnvalue) { processEmbed (instance, wrapper, returnvalue) {
let embed = BDFDB.getReactValue(instance, "props.embed"); let embed = BDFDB.ReactUtils.getValue(instance, "props.embed");
let footer = wrapper.querySelector(BDFDB.dotCN.embedfootertext); let footer = wrapper.querySelector(BDFDB.dotCN.embedfootertext);
if (footer && embed && embed.timestamp && BDFDB.getData("showInEmbed", this, "settings")) { if (footer && embed && embed.timestamp && BDFDB.getData("showInEmbed", this, "settings")) {
footer.lastChild.textContent = this.getTimestamp(this.languages[BDFDB.getData("creationDateLang", this, "choices")].id, embed.timestamp._i); footer.lastChild.textContent = this.getTimestamp(this.languages[BDFDB.getData("creationDateLang", this, "choices")].id, embed.timestamp._i);
@ -203,7 +201,7 @@ class CompleteTimestamps {
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -220,7 +218,7 @@ class CompleteTimestamps {
getMessageData (div, messagegroup) { getMessageData (div, messagegroup) {
let pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div); let pos = Array.from(messagegroup.querySelectorAll("." + div.className.replace(/ /g, "."))).indexOf(div);
let instance = BDFDB.getReactInstance(messagegroup); let instance = BDFDB.ReactUtils.getInstance(messagegroup);
if (!instance) return; if (!instance) return;
let info = instance.return.stateNode.props.messages; let info = instance.return.stateNode.props.messages;
return info && pos > -1 ? info[pos] : null; return info && pos > -1 ? info[pos] : null;
@ -281,8 +279,8 @@ class CompleteTimestamps {
} }
setMaxWidth () { setMaxWidth () {
if (this.currentMode != BDFDB.getDiscordMode()) { if (this.currentMode != BDFDB.DiscordUtils.getMode()) {
this.currentMode = BDFDB.getDiscordMode(); this.currentMode = BDFDB.DiscordUtils.getMode();
let timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact); let timestamp = document.querySelector(BDFDB.dotCN.messagetimestampcompact);
if (timestamp) { if (timestamp) {
let choice = BDFDB.getData("creationDateLang", this, "choices"); let choice = BDFDB.getData("creationDateLang", this, "choices");

View File

@ -43,18 +43,16 @@ class CopyRawMessage {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -64,10 +62,10 @@ class CopyRawMessage {
onMessageContextMenu (instance, menu, returnvalue) { onMessageContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.message && instance.props.message.content && instance.props.target && !menu.querySelector(`${this.name}-contextMenuItem`)) { if (instance.props && instance.props.message && instance.props.message.content && instance.props.target && !menu.querySelector(`${this.name}-contextMenuItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)", label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-copyraw-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-copyraw-contextMenuItem`,
action: e => { action: e => {
@ -85,7 +83,7 @@ class CopyRawMessage {
onMessageOptionPopout (instance, popout, returnvalue) { onMessageOptionPopout (instance, popout, returnvalue) {
if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !popout.querySelector(".copyrawmessage-itembtn")) { if (instance.props.message && instance.props.channel && instance._reactInternalFiber.memoizedProps.target && !popout.querySelector(".copyrawmessage-itembtn")) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, BDFDB.LanguageUtils.LanguageStrings.DELETE); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, BDFDB.LanguageUtils.LanguageStrings.DELETE);
const copyItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const copyItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)", label: BDFDB.LanguageUtils.LanguageStrings.COPY_TEXT + " (Raw)",
className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-copyraw-popoutMenuItem`, className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-copyraw-popoutMenuItem`,
action: e => { action: e => {
@ -98,7 +96,7 @@ class CopyRawMessage {
} }
processMessage (instance, wrapper, returnvalue) { processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.getReactValue(instance, "props.message.author.id") != 1) { if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer); let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) { if (buttonwrap) {
let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`); let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);

View File

@ -90,10 +90,10 @@ class CreationDate {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
}); });
return settingspanel; return settingspanel;
@ -123,15 +123,13 @@ class CreationDate {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.languages); this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.LanguageUtils.languages);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -140,7 +138,7 @@ class CreationDate {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".creationDate"); BDFDB.removeEles(".creationDate");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -198,7 +196,7 @@ class CreationDate {
let addTimestamp = (timestamp) => { let addTimestamp = (timestamp) => {
if (document.contains(container)) { if (document.contains(container)) {
BDFDB.removeEles(container.querySelectorAll(".creationDate")); BDFDB.removeEles(container.querySelectorAll(".creationDate"));
if (BDFDB.isObject(container.CreationDateObserver)) container.CreationDateObserver.disconnect(); if (BDFDB.ObjectUtils.is(container.CreationDateObserver)) container.CreationDateObserver.disconnect();
let choice = BDFDB.getData("creationDateLang", this, "choices"); let choice = BDFDB.getData("creationDateLang", this, "choices");
let nametag = container.querySelector(BDFDB.dotCN.nametag); let nametag = container.querySelector(BDFDB.dotCN.nametag);
container.insertBefore(BDFDB.htmlToElement(`<div class="creationDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 8 !important;"><div class="BDFDB-textscroll">${this.labels.createdat_text.replace("{{time}}", this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null); container.insertBefore(BDFDB.htmlToElement(`<div class="creationDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 8 !important;"><div class="BDFDB-textscroll">${this.labels.createdat_text.replace("{{time}}", this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null);

View File

@ -80,24 +80,22 @@ class DisplayServersAsChannels {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.addClass(document.body, "DSAC-styled"); BDFDB.addClass(document.body, "DSAC-styled");
this.addCSS(); this.addCSS();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
BDFDB.addEventListener(this, document, "mouseenter", BDFDB.dotCN.guildouter, e => { BDFDB.ListenerUtils.add(this, document, "mouseenter", BDFDB.dotCN.guildouter, e => {
if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *")) BDFDB.appendLocalStyle("HideAllToolTips" + this.name, `${BDFDB.dotCN.tooltip} {display: none !important;}`); if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *")) BDFDB.appendLocalStyle("HideAllToolTips" + this.name, `${BDFDB.dotCN.tooltip} {display: none !important;}`);
}); });
BDFDB.addEventListener(this, document, "mouseleave", BDFDB.dotCN.guildouter, e => { BDFDB.ListenerUtils.add(this, document, "mouseleave", BDFDB.dotCN.guildouter, e => {
if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *") && !document.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *:hover")) BDFDB.removeLocalStyle("HideAllToolTips" + this.name); if (e.currentTarget.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *") && !document.querySelector(BDFDB.dotCN.guildpillwrapper + BDFDB.notCN.dmpill + "+ *:hover")) BDFDB.removeLocalStyle("HideAllToolTips" + this.name);
}); });
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
@ -116,7 +114,7 @@ class DisplayServersAsChannels {
changedSVG.removeAttribute("DSAC-oldViewBox"); changedSVG.removeAttribute("DSAC-oldViewBox");
} }
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -126,7 +124,7 @@ class DisplayServersAsChannels {
processGuilds (instance, wrapper, returnvalue) { processGuilds (instance, wrapper, returnvalue) {
var observer = new MutationObserver((changes, _) => {changes.forEach((change, i) => {if (change.addedNodes) {change.addedNodes.forEach((node) => { var observer = new MutationObserver((changes, _) => {changes.forEach((change, i) => {if (change.addedNodes) {change.addedNodes.forEach((node) => {
if (node && BDFDB.containsClass(node, BDFDB.disCN.guildouter) && !node.querySelector(BDFDB.dotCN.guildserror)) { if (node && BDFDB.containsClass(node, BDFDB.disCN.guildouter) && !node.querySelector(BDFDB.dotCN.guildserror)) {
this.changeServer(BDFDB.getServerData(node)); this.changeServer(BDFDB.GuildUtils.getData(node));
} }
if (node && node.tagName && (node = node.querySelector(BDFDB.dotCN.guildbuttoncontainer)) != null) { if (node && node.tagName && (node = node.querySelector(BDFDB.dotCN.guildbuttoncontainer)) != null) {
this.changeButton(node); this.changeButton(node);
@ -135,9 +133,9 @@ class DisplayServersAsChannels {
this.changeError(node); this.changeError(node);
} }
});}});}); });}});});
BDFDB.addObserver(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilter: ["class", "draggable"], attributeOldValue: true}); BDFDB.ObserverUtils.connect(this, BDFDB.dotCN.guilds, {name:"serverListObserver",instance:observer}, {childList: true, subtree:true, attributes:true, attributeFilter: ["class", "draggable"], attributeOldValue: true});
BDFDB.readServerList().forEach(info => {this.changeServer(info);}); BDFDB.GuildUtils.getAll().forEach(info => {this.changeServer(info);});
document.querySelectorAll(BDFDB.dotCN.homebuttonpill + " + *").forEach(homebuttoncontainer => {this.changeHome(homebuttoncontainer);}); document.querySelectorAll(BDFDB.dotCN.homebuttonpill + " + *").forEach(homebuttoncontainer => {this.changeHome(homebuttoncontainer);});
document.querySelectorAll(BDFDB.dotCN.guildbuttonpill + " + *").forEach(guildbuttoncontainer => {this.changeButton(guildbuttoncontainer);}); document.querySelectorAll(BDFDB.dotCN.guildbuttonpill + " + *").forEach(guildbuttoncontainer => {this.changeButton(guildbuttoncontainer);});
document.querySelectorAll(BDFDB.dotCN.guildserror).forEach(guildserror => {this.changeError(guildserror);}); document.querySelectorAll(BDFDB.dotCN.guildserror).forEach(guildserror => {this.changeError(guildserror);});

View File

@ -58,18 +58,18 @@ class EditChannels {
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
var settingsitems = [], inneritems = []; var settingsitems = [], inneritems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["settings", key], keys: ["settings", key],
label: this.defaults.settings[key].description, label: this.defaults.settings[key].description,
value: settings[key] value: settings[key]
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Change Channels in:", title: "Change Channels in:",
children: inneritems children: inneritems
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button", type: "Button",
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED, color: BDFDB.LibraryComponents.Button.Colors.RED,
@ -83,7 +83,7 @@ class EditChannels {
children: BDFDB.LanguageUtils.LanguageStrings.RESET children: BDFDB.LanguageUtils.LanguageStrings.RESET
})); }));
return BDFDB.createSettingsPanel(this, settingsitems); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
} }
//legacy //legacy
@ -110,16 +110,14 @@ class EditChannels {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
var observer = new MutationObserver(() => {this.changeAppTitle();}); var observer = new MutationObserver(() => {this.changeAppTitle();});
BDFDB.addObserver(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true}); BDFDB.ObserverUtils.connect(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true});
this.forceUpdateAll(); this.forceUpdateAll();
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
@ -133,7 +131,7 @@ class EditChannels {
BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow"); BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -143,16 +141,16 @@ class EditChannels {
onChannelContextMenu (instance, menu, returnvalue) { onChannelContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.channel && !BDFDB.getParentEle(".container-hidden", instance.props.target) && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (instance.props && instance.props.channel && !BDFDB.getParentEle(".container-hidden", instance.props.target) && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_localchannelsettings_text, label: this.labels.context_localchannelsettings_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-channelsettings-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-channelsettings-contextMenuSubItem`,
render: [BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { render: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_channelsettings_text, label: this.labels.submenu_channelsettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-channelsettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-channelsettings-ContextMenuItem`,
action: e => { action: e => {
@ -160,7 +158,7 @@ class EditChannels {
this.showChannelSettings(instance.props.channel); this.showChannelSettings(instance.props.channel);
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_resetsettings_text, label: this.labels.submenu_resetsettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`,
disabled: !BDFDB.loadData(instance.props.channel.id, this, "channels"), disabled: !BDFDB.loadData(instance.props.channel.id, this, "channels"),
@ -182,7 +180,7 @@ class EditChannels {
forceUpdateAll () { forceUpdateAll () {
this.changeAppTitle(); this.changeAppTitle();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
showChannelSettings (info) { showChannelSettings (info) {
@ -193,31 +191,31 @@ class EditChannels {
header: this.labels.modal_header_text, header: this.labels.modal_header_text,
subheader: info.name, subheader: info.name,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_channelname_text, title: this.labels.modal_channelname_text,
className: BDFDB.disCN.marginbottom20 + " input-channelname", className: BDFDB.disCN.marginbottom20 + " input-channelname",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.name, value: data.name,
placeholder: info.name, placeholder: info.name,
autoFocus: true autoFocus: true
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.dividerdefault className: BDFDB.disCN.dividerdefault
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker1_text, title: this.labels.modal_colorpicker1_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color, color: data.color,
number: 1 number: 1
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
className: BDFDB.disCN.marginbottom20 + " input-inheritcolor", className: BDFDB.disCN.marginbottom20 + " input-inheritcolor",
label: this.labels.modal_inheritcolor_text, label: this.labels.modal_inheritcolor_text,
@ -239,7 +237,7 @@ class EditChannels {
data.color = BDFDB.getSwatchColor(modal, 1); data.color = BDFDB.getSwatchColor(modal, 1);
console.log(data.color); console.log(data.color);
if (data.color != null && !BDFDB.isObject(data.color)) { if (data.color != null && !BDFDB.ObjectUtils.is(data.color)) {
if (data.color[0] < 30 && data.color[1] < 30 && data.color[2] < 30) data.color = BDFDB.colorCHANGE(data.color, 30); if (data.color[0] < 30 && data.color[1] < 30 && data.color[2] < 30) data.color = BDFDB.colorCHANGE(data.color, 30);
else if (data.color[0] > 225 && data.color[1] > 225 && data.color[2] > 225) data.color = BDFDB.colorCHANGE(data.color, -30); else if (data.color[0] > 225 && data.color[1] > 225 && data.color[2] > 225) data.color = BDFDB.colorCHANGE(data.color, -30);
} }
@ -256,7 +254,7 @@ class EditChannels {
} }
processChannelTextArea (instance, wrapper, returnvalue) { processChannelTextArea (instance, wrapper, returnvalue) {
let channel = BDFDB.getReactValue(instance, "props.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "props.channel");
if (channel) { if (channel) {
var textarea = wrapper.querySelector("textarea"); var textarea = wrapper.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
@ -264,13 +262,13 @@ class EditChannels {
let data = this.getChannelData(channel.id, wrapper); let data = this.getChannelData(channel.id, wrapper);
wrapper.querySelector("textarea").setAttribute("placeholder", BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", "#" + (data.name || channel.name))); wrapper.querySelector("textarea").setAttribute("placeholder", BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", "#" + (data.name || channel.name)));
} }
BDFDB.removeEventListener(this, textarea); BDFDB.ListenerUtils.remove(this, textarea);
if (BDFDB.getData("changeInAutoComplete", this, "settings")) { if (BDFDB.getData("changeInAutoComplete", this, "settings")) {
BDFDB.addEventListener(this, textarea, "keydown", e => { BDFDB.ListenerUtils.add(this, textarea, "keydown", e => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if (autocompletemenu && (e.which == 9 || e.which == 13)) { if (autocompletemenu && (e.which == 9 || e.which == 13)) {
if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteEditChannelsRow")) { if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteEditChannelsRow")) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
this.swapWordWithMention(textarea); this.swapWordWithMention(textarea);
} }
} }
@ -278,7 +276,7 @@ class EditChannels {
let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteEditChannelsSelector)"); let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteEditChannelsSelector)");
let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected); let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected);
if (BDFDB.containsClass(selected, "autocompleteEditChannelsSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) { if (BDFDB.containsClass(selected, "autocompleteEditChannelsSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true); let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
@ -296,7 +294,7 @@ class EditChannels {
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow"); if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditChannels", ".autocompleteEditChannelsRow");
}); });
BDFDB.addEventListener(this, textarea, "click", e => { BDFDB.ListenerUtils.add(this, textarea, "click", e => {
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);}); if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);});
}); });
} }
@ -304,7 +302,7 @@ class EditChannels {
} }
processAuditLog (instance, wrapper, returnvalue) { processAuditLog (instance, wrapper, returnvalue) {
let channel = BDFDB.getReactValue(instance, "props.log.options.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "props.log.options.channel");
if (channel) { if (channel) {
let hooks = wrapper.querySelectorAll(`${BDFDB.dotCN.flexchild} > span${BDFDB.notCN.auditloguserhook}`); let hooks = wrapper.querySelectorAll(`${BDFDB.dotCN.flexchild} > span${BDFDB.notCN.auditloguserhook}`);
if (hooks.length > 0) this.changeChannel2(channel, hooks[0].firstChild); if (hooks.length > 0) this.changeChannel2(channel, hooks[0].firstChild);
@ -312,7 +310,7 @@ class EditChannels {
} }
processInviteCard (instance, wrapper, returnvalue) { processInviteCard (instance, wrapper, returnvalue) {
let invite = BDFDB.getReactValue(instance, "props.invite"); let invite = BDFDB.ReactUtils.getValue(instance, "props.invite");
if (invite && invite.inviter && invite.channel) { if (invite && invite.inviter && invite.channel) {
let channelname = wrapper.querySelector(BDFDB.dotCN.guildsettingsinvitechannelname); let channelname = wrapper.querySelector(BDFDB.dotCN.guildsettingsinvitechannelname);
if (channelname) this.changeChannel2(invite.channel, channelname); if (channelname) this.changeChannel2(invite.channel, channelname);
@ -336,7 +334,7 @@ class EditChannels {
} }
processHeaderBar (instance, wrapper, returnvalue) { processHeaderBar (instance, wrapper, returnvalue) {
let channel_id = BDFDB.getReactValue(instance, "props.channelId") || BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channelId"); let channel_id = BDFDB.ReactUtils.getValue(instance, "props.channelId") || BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.channelId");
if (channel_id) { if (channel_id) {
let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderheaderbartitle); let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderheaderbartitle);
if (channelname) { if (channelname) {
@ -346,7 +344,7 @@ class EditChannels {
else { else {
if (channel.type == 1) channel = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]) || channel; if (channel.type == 1) channel = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]) || channel;
if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect(); if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect();
if (BDFDB.isPluginEnabled("EditUsers")) BDFDB.getPlugin("EditUsers").changeName(channel, channelname); if (BDFDB.BdUtils.isPluginEnabled("EditUsers")) BDFDB.BdUtils.getPlugin("EditUsers").changeName(channel, channelname);
else { else {
channelname.style.removeProperty("color"); channelname.style.removeProperty("color");
channelname.style.removeProperty("background"); channelname.style.removeProperty("background");
@ -361,10 +359,10 @@ class EditChannels {
processClickable (instance, wrapper, returnvalue) { processClickable (instance, wrapper, returnvalue) {
if (!instance.props || !instance.props.className) return; if (!instance.props || !instance.props.className) return;
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mentionwrapper) > -1 && instance.props.className.indexOf(BDFDB.disCN.mention) == -1) { else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mentionwrapper) > -1 && instance.props.className.indexOf(BDFDB.disCN.mention) == -1) {
let children = BDFDB.getReactValue(instance, "_reactInternalFiber.memoizedProps.children"); let children = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.memoizedProps.children");
if (children && typeof children[0] == "string") { if (children && typeof children[0] == "string") {
let channelname = children[0].slice(1); let channelname = children[0].slice(1);
let categoryname = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.type.displayName") == "Tooltip" ? BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.text") : null let categoryname = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.type.displayName") == "Tooltip" ? BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.text") : null
let channelid = BDFDB.LibraryModules.LastGuildStore.getGuildId(); let channelid = BDFDB.LibraryModules.LastGuildStore.getGuildId();
let channels = channelid ? (BDFDB.LibraryModules.GuildChannelStore.getChannels(channelid)[0] || BDFDB.LibraryModules.GuildChannelStore.getChannels(channelid).SELECTABLE) : null; let channels = channelid ? (BDFDB.LibraryModules.GuildChannelStore.getChannels(channelid)[0] || BDFDB.LibraryModules.GuildChannelStore.getChannels(channelid).SELECTABLE) : null;
if (Array.isArray(channels)) for (let channel of channels) { if (Array.isArray(channels)) for (let channel of channels) {
@ -379,22 +377,22 @@ class EditChannels {
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) {
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.channel");
if (channel) { if (channel) {
this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch)); this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
if (channel.parent_id) this.changeChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.parent_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultnote)); if (channel.parent_id) this.changeChannel(BDFDB.LibraryModules.ChannelStore.getChannel(channel.parent_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultnote));
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) {
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.channel");
if (channel) { if (channel) {
this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.marginleft4)); this.changeChannel(channel, wrapper.querySelector(BDFDB.dotCN.marginleft4));
let category = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.category"); let category = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.category");
if (category) this.changeChannel(category, wrapper.querySelector(BDFDB.dotCN.autocompletedescription)); if (category) this.changeChannel(category, wrapper.querySelector(BDFDB.dotCN.autocompletedescription));
} }
} }
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.messagespopoutchannelname) > -1) { else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.messagespopoutchannelname) > -1) {
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.sibling.child.child.memoizedProps.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.sibling.child.child.memoizedProps.channel");
if (channel) this.changeChannel2(channel, wrapper); if (channel) this.changeChannel2(channel, wrapper);
} }
} }
@ -421,7 +419,7 @@ class EditChannels {
if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect(); if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect();
let data = this.getChannelData(info.id, info.parent_id, channelname); let data = this.getChannelData(info.id, info.parent_id, channelname);
if (data.name || data.color || channelname.parentElement.getAttribute("changed-by-editchannels")) { if (data.name || data.color || channelname.parentElement.getAttribute("changed-by-editchannels")) {
let isgradient = data.color && BDFDB.isObject(data.color); let isgradient = data.color && BDFDB.ObjectUtils.is(data.color);
let color = this.chooseColor(channelname, data.color); let color = this.chooseColor(channelname, data.color);
if (isgradient) { if (isgradient) {
channelname.style.setProperty("color", BDFDB.colorCONVERT(data.color[Object.keys(data.color)[0]], "RGBA"), "important"); channelname.style.setProperty("color", BDFDB.colorCONVERT(data.color[Object.keys(data.color)[0]], "RGBA"), "important");
@ -491,7 +489,7 @@ class EditChannels {
if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect(); if (channelname.EditChannelsChangeObserver && typeof channelname.EditChannelsChangeObserver.disconnect == "function") channelname.EditChannelsChangeObserver.disconnect();
let data = this.getChannelData(info.id, info.parent_id, channelname); let data = this.getChannelData(info.id, info.parent_id, channelname);
if (data.name || data.color || channelname.getAttribute("changed-by-editchannels")) { if (data.name || data.color || channelname.getAttribute("changed-by-editchannels")) {
if (BDFDB.isObject(data.color)) { if (BDFDB.ObjectUtils.is(data.color)) {
channelname.style.setProperty("color", BDFDB.colorCONVERT(data.color[Object.keys(data.color)[0]], "RGBA"), "important"); channelname.style.setProperty("color", BDFDB.colorCONVERT(data.color[Object.keys(data.color)[0]], "RGBA"), "important");
BDFDB.setInnerText(channelname, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(this.chooseColor(channelname, data.color))} !important;">${BDFDB.encodeToHTML("#" + (data.name || info.name))}</span>`)); BDFDB.setInnerText(channelname, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(this.chooseColor(channelname, data.color))} !important;">${BDFDB.encodeToHTML("#" + (data.name || info.name))}</span>`));
} }
@ -525,7 +523,7 @@ class EditChannels {
let data = this.getChannelData(info.id, info.parent_id, mention); let data = this.getChannelData(info.id, info.parent_id, mention);
let name = "#" + (data.name || info.name); let name = "#" + (data.name || info.name);
let isgradient = data.color && BDFDB.isObject(data.color); let isgradient = data.color && BDFDB.ObjectUtils.is(data.color);
let color = isgradient ? BDFDB.colorGRADIENT(data.color) : BDFDB.colorCONVERT(data.color, "RGBA"); let color = isgradient ? BDFDB.colorGRADIENT(data.color) : BDFDB.colorCONVERT(data.color, "RGBA");
let color0_1 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color, 0.1, "RGBA")) : BDFDB.colorSETALPHA(data.color, 0.1, "RGBA"); let color0_1 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color, 0.1, "RGBA")) : BDFDB.colorSETALPHA(data.color, 0.1, "RGBA");
let color0_7 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color, 0.7, "RGBA")) : BDFDB.colorSETALPHA(data.color, 0.7, "RGBA"); let color0_7 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color, 0.7, "RGBA")) : BDFDB.colorSETALPHA(data.color, 0.7, "RGBA");
@ -536,7 +534,7 @@ class EditChannels {
mention.EditChannelsHovered = true; mention.EditChannelsHovered = true;
colorHover(); colorHover();
let categorydata = this.getChannelData(categoryinfo.id, null, mention); let categorydata = this.getChannelData(categoryinfo.id, null, mention);
if (categorydata.name) BDFDB.createTooltip(categorydata.name, mention, {type:"top", selector:"EditChannels-tooltip", hide:true}); if (categorydata.name) BDFDB.TooltipUtils.create(mention, categorydata.name, {type:"top", selector:"EditChannels-tooltip", hide:true});
}; };
mention.mouseoutListenerEditChannels = () => { mention.mouseoutListenerEditChannels = () => {
delete mention.EditChannelsHovered; delete mention.EditChannelsHovered;
@ -574,7 +572,7 @@ class EditChannels {
let classname = channelname.className ? channelname.className.toLowerCase() : ""; let classname = channelname.className ? channelname.className.toLowerCase() : "";
if (classname.indexOf("muted") > -1 || classname.indexOf("locked") > -1) color = BDFDB.colorCHANGE(color, -0.5); if (classname.indexOf("muted") > -1 || classname.indexOf("locked") > -1) color = BDFDB.colorCHANGE(color, -0.5);
else if (hovered || classname.indexOf("selected") > -1 || classname.indexOf("hovered") > -1 || classname.indexOf("unread") > -1 || classname.indexOf("connected") > -1) color = BDFDB.colorCHANGE(color, 0.5); else if (hovered || classname.indexOf("selected") > -1 || classname.indexOf("hovered") > -1 || classname.indexOf("unread") > -1 || classname.indexOf("connected") > -1) color = BDFDB.colorCHANGE(color, 0.5);
return BDFDB.isObject(color) ? color : BDFDB.colorCONVERT(color, "RGBA"); return BDFDB.ObjectUtils.is(color) ? color : BDFDB.colorCONVERT(color, "RGBA");
} }
return null; return null;
} }
@ -619,7 +617,7 @@ class EditChannels {
let catdata = (category ? channels[category.id] : null) || {}; let catdata = (category ? channels[category.id] : null) || {};
if (channel && channel.type == 0) channelarray.push(Object.assign({lowercasename:channels[id].name.toLowerCase(),lowercasecatname:(catdata && catdata.name ? catdata.name.toLowerCase() : null),channel,category,catdata},channels[id])); if (channel && channel.type == 0) channelarray.push(Object.assign({lowercasename:channels[id].name.toLowerCase(),lowercasecatname:(catdata && catdata.name ? catdata.name.toLowerCase() : null),channel,category,catdata},channels[id]));
} }
channelarray = BDFDB.sortArrayByKey(channelarray.filter(n => n.lowercasename.indexOf(lastword.toLowerCase().slice(1)) != -1 || (n.lowercasecatname && n.lowercasecatname.indexOf(lastword.toLowerCase().slice(1)) != -1)), "lowercasename"); channelarray = BDFDB.ArrayUtils.keySort(channelarray.filter(n => n.lowercasename.indexOf(lastword.toLowerCase().slice(1)) != -1 || (n.lowercasecatname && n.lowercasecatname.indexOf(lastword.toLowerCase().slice(1)) != -1)), "lowercasename");
if (channelarray.length) { if (channelarray.length) {
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15; let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15;
@ -632,7 +630,7 @@ class EditChannels {
amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length; amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length;
} }
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => { BDFDB.ListenerUtils.add(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected); var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);

View File

@ -41,18 +41,18 @@ class EditServers {
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
var settingsitems = [], inneritems = []; var settingsitems = [], inneritems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["settings", key], keys: ["settings", key],
label: this.defaults.settings[key].description, label: this.defaults.settings[key].description,
value: settings[key] value: settings[key]
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Change Servers in:", title: "Change Servers in:",
children: inneritems children: inneritems
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button", type: "Button",
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED, color: BDFDB.LibraryComponents.Button.Colors.RED,
@ -66,7 +66,7 @@ class EditServers {
children: BDFDB.LanguageUtils.LanguageStrings.RESET children: BDFDB.LanguageUtils.LanguageStrings.RESET
})); }));
return BDFDB.createSettingsPanel(this, settingsitems); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
} }
//legacy //legacy
@ -93,9 +93,9 @@ class EditServers {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.patch(BDFDB.LibraryModules.IconUtils, 'getGuildBannerURL', this, {instead:e => { BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.IconUtils, 'getGuildBannerURL', {instead:e => {
let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.methodArguments[0].id); let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.methodArguments[0].id);
if (guild) { if (guild) {
if (e.methodArguments[0].id == "410787888507256842") return guild.banner; if (e.methodArguments[0].id == "410787888507256842") return guild.banner;
@ -107,9 +107,7 @@ class EditServers {
this.forceUpdateAll(); this.forceUpdateAll();
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
@ -121,11 +119,11 @@ class EditServers {
try {this.forceUpdateAll();} catch (err) {} try {this.forceUpdateAll();} catch (err) {}
BDFDB.saveAllData(data, this, "servers"); BDFDB.saveAllData(data, this, "servers");
for (let guildobj of BDFDB.readServerList()) if (guildobj.instance) { for (let guildobj of BDFDB.GuildUtils.getAll()) if (guildobj.instance) {
delete guildobj.instance.props.guild.EditServersCachedBanner; delete guildobj.instance.props.guild.EditServersCachedBanner;
} }
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -134,16 +132,16 @@ class EditServers {
onGuildContextMenu (instance, menu, returnvalue) { onGuildContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.guild && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (instance.props && instance.props.guild && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_localserversettings_text, label: this.labels.context_localserversettings_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-serversettings-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-serversettings-contextMenuSubItem`,
render: [BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { render: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_serversettings_text, label: this.labels.submenu_serversettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-serversettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-serversettings-ContextMenuItem`,
action: e => { action: e => {
@ -151,7 +149,7 @@ class EditServers {
this.showServerSettings(instance.props.guild); this.showServerSettings(instance.props.guild);
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_resetsettings_text, label: this.labels.submenu_resetsettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`,
disabled: !BDFDB.loadData(instance.props.guild.id, this, "servers"), disabled: !BDFDB.loadData(instance.props.guild.id, this, "servers"),
@ -198,16 +196,16 @@ class EditServers {
processClickable (instance, wrapper, returnvalue) { processClickable (instance, wrapper, returnvalue) {
if (!wrapper || !instance.props || !instance.props.className) return; if (!wrapper || !instance.props || !instance.props.className) return;
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.userprofilelistrow) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.userprofilelistrow) > -1) {
let guild = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.guild"); let guild = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.guild");
if (guild && BDFDB.getReactValue(instance, "_reactInternalFiber.return.type.displayName") == "GuildRow") { if (guild && BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.type.displayName") == "GuildRow") {
this.changeGuildName(guild, wrapper.querySelector(BDFDB.dotCN.userprofilelistname)); this.changeGuildName(guild, wrapper.querySelector(BDFDB.dotCN.userprofilelistname));
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) {
let guild = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.guild"); let guild = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.guild");
if (guild) this.changeGuildName(guild, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch)); if (guild) this.changeGuildName(guild, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
else { else {
let channel = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.channel");
if (channel && channel.guild_id) this.changeGuildName(BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultmisccontainer)); if (channel && channel.guild_id) this.changeGuildName(BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id), wrapper.querySelector(BDFDB.dotCN.quickswitchresultmisccontainer));
} }
} }
@ -215,9 +213,9 @@ class EditServers {
forceUpdateAll (guildid) { forceUpdateAll (guildid) {
this.updateGuildSidebar(); this.updateGuildSidebar();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
if (guildid) { if (guildid) {
let ServerFolders = BDFDB.getPlugin("ServerFolders", true); let ServerFolders = BDFDB.BdUtils.getPlugin("ServerFolders", true);
if (ServerFolders) { if (ServerFolders) {
let folder = ServerFolders.getFolderOfGuildId(guildid); let folder = ServerFolders.getFolderOfGuildId(guildid);
if (folder) ServerFolders.updateGuildInFolderContent(folder.folderId, guildid); if (folder) ServerFolders.updateGuildInFolderContent(folder.folderId, guildid);
@ -233,39 +231,39 @@ class EditServers {
header: this.labels.modal_header_text, header: this.labels.modal_header_text,
subheader: info.name, subheader: info.name,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader1_text, tab: this.labels.modal_tabheader1_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_guildname_text, title: this.labels.modal_guildname_text,
className: BDFDB.disCN.marginbottom20 + " input-guildname", className: BDFDB.disCN.marginbottom20 + " input-guildname",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.name, value: data.name,
placeholder: info.name, placeholder: info.name,
autoFocus: true autoFocus: true
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_guildacronym_text, title: this.labels.modal_guildacronym_text,
className: BDFDB.disCN.marginbottom20 + " input-guildacronym", className: BDFDB.disCN.marginbottom20 + " input-guildacronym",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.shortName, value: data.shortName,
placeholder: info.acronym placeholder: info.acronym
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_guildicon_text, title: this.labels.modal_guildicon_text,
className: BDFDB.disCN.marginbottom8 + " input-guildicon", className: BDFDB.disCN.marginbottom8 + " input-guildicon",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null, inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null,
inputId: "GUILDICON", inputId: "GUILDICON",
value: data.url, value: data.url,
placeholder: BDFDB.getGuildIcon(info.id), placeholder: BDFDB.GuildUtils.getIcon(info.id),
disabled: data.removeIcon, disabled: data.removeIcon,
onFocus: e => { onFocus: e => {
this.createNoticeTooltip(e.target); this.createNoticeTooltip(e.target);
@ -276,7 +274,7 @@ class EditServers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
className: BDFDB.disCN.marginbottom20 + " input-removeicon", className: BDFDB.disCN.marginbottom20 + " input-removeicon",
label: this.labels.modal_removeicon_text, label: this.labels.modal_removeicon_text,
@ -290,15 +288,15 @@ class EditServers {
} }
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_guildbanner_text, title: this.labels.modal_guildbanner_text,
className: BDFDB.disCN.marginbottom8 + " input-guildbanner", className: BDFDB.disCN.marginbottom8 + " input-guildbanner",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
inputClassName: !data.removeBanner && data.banner ? BDFDB.disCN.inputsuccess : null, inputClassName: !data.removeBanner && data.banner ? BDFDB.disCN.inputsuccess : null,
inputId: "GUILDBANNER", inputId: "GUILDBANNER",
value: data.banner, value: data.banner,
placeholder: BDFDB.getGuildBanner(info.id), placeholder: BDFDB.GuildUtils.getBanner(info.id),
disabled: data.removeBanner || info.id == "410787888507256842", disabled: data.removeBanner || info.id == "410787888507256842",
onFocus: e => { onFocus: e => {
this.createNoticeTooltip(e.target); this.createNoticeTooltip(e.target);
@ -309,7 +307,7 @@ class EditServers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
className: BDFDB.disCN.marginbottom20 + " input-removebanner", className: BDFDB.disCN.marginbottom20 + " input-removebanner",
label: this.labels.modal_removebanner_text, label: this.labels.modal_removebanner_text,
@ -326,24 +324,24 @@ class EditServers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader2_text, tab: this.labels.modal_tabheader2_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker1_text, title: this.labels.modal_colorpicker1_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color1, color: data.color1,
number: 1 number: 1
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker2_text, title: this.labels.modal_colorpicker2_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color2, color: data.color2,
number: 2 number: 2
}) })
@ -351,24 +349,24 @@ class EditServers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader3_text, tab: this.labels.modal_tabheader3_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker3_text, title: this.labels.modal_colorpicker3_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color3, color: data.color3,
number: 3 number: 3
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker4_text, title: this.labels.modal_colorpicker4_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color4, color: data.color4,
number: 4 number: 4
}) })
@ -413,7 +411,7 @@ class EditServers {
} }
checkUrl (url, instance) { checkUrl (url, instance) {
let input = BDFDB.React.findDOMNode(instance).firstElementChild; let input = BDFDB.ReactUtils.findDOMNode(instance).firstElementChild;
clearTimeout(instance.checkTimeout); clearTimeout(instance.checkTimeout);
if (url == null || !url.trim()) { if (url == null || !url.trim()) {
if (input) BDFDB.removeEles(input.tooltip); if (input) BDFDB.removeEles(input.tooltip);
@ -441,7 +439,7 @@ class EditServers {
BDFDB.removeEles(input.tooltip); BDFDB.removeEles(input.tooltip);
var invalid = isinvalid || BDFDB.containsClass(input, BDFDB.disCN.inputerror); var invalid = isinvalid || BDFDB.containsClass(input, BDFDB.disCN.inputerror);
var valid = invalid ? false : BDFDB.containsClass(input, BDFDB.disCN.inputsuccess); var valid = invalid ? false : BDFDB.containsClass(input, BDFDB.disCN.inputsuccess);
if (invalid || valid) input.tooltip = BDFDB.createTooltip(invalid ? this.labels.modal_invalidurl_text : this.labels.modal_validurl_text, input, {type:"right", selector:"notice-tooltip", color: invalid ? "red" : "green"}); if (invalid || valid) input.tooltip = BDFDB.TooltipUtils.create(input, invalid ? this.labels.modal_invalidurl_text : this.labels.modal_validurl_text, {type:"right", selector:"notice-tooltip", color: invalid ? "red" : "green"});
} }
changeGuildName (info, guildname) { changeGuildName (info, guildname) {
@ -450,7 +448,7 @@ class EditServers {
guildname.removeEventListener("mouseenter", guildname.mouseenterListenerEditChannels); guildname.removeEventListener("mouseenter", guildname.mouseenterListenerEditChannels);
let data = this.getGuildData(info.id, guildname); let data = this.getGuildData(info.id, guildname);
if (data.name || data.color2 || guildname.getAttribute("changed-by-editservers")) { if (data.name || data.color2 || guildname.getAttribute("changed-by-editservers")) {
if (BDFDB.isObject(data.color2)) { if (BDFDB.ObjectUtils.is(data.color2)) {
guildname.style.setProperty("color", BDFDB.colorCONVERT(data.color2[Object.keys(data.color2)[0]], "RGBA"), "important"); guildname.style.setProperty("color", BDFDB.colorCONVERT(data.color2[Object.keys(data.color2)[0]], "RGBA"), "important");
BDFDB.setInnerText(guildname, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(data.name || info.name)}</span>`)); BDFDB.setInnerText(guildname, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(data.name || info.name)}</span>`));
} }
@ -460,7 +458,7 @@ class EditServers {
} }
if (data.name && BDFDB.containsClass(guildname, BDFDB.disCN.guildheadername) && BDFDB.getData("addOriginalTooltip", this, "settings")) { if (data.name && BDFDB.containsClass(guildname, BDFDB.disCN.guildheadername) && BDFDB.getData("addOriginalTooltip", this, "settings")) {
guildname.mouseenterListenerEditChannels = () => { guildname.mouseenterListenerEditChannels = () => {
BDFDB.createTooltip(info.name, guildname.parentElement, {type:"right", selector:"EditServers-tooltip", hide:true}); BDFDB.TooltipUtils.create(guildname.parentElement, info.name, {type:"right", selector:"EditServers-tooltip", hide:true});
}; };
guildname.addEventListener("mouseenter", guildname.mouseenterListenerEditChannels); guildname.addEventListener("mouseenter", guildname.mouseenterListenerEditChannels);
} }
@ -481,7 +479,7 @@ class EditServers {
if (icon.EditServersChangeObserver && typeof icon.EditServersChangeObserver.disconnect == "function") icon.EditServersChangeObserver.disconnect(); if (icon.EditServersChangeObserver && typeof icon.EditServersChangeObserver.disconnect == "function") icon.EditServersChangeObserver.disconnect();
let data = this.getGuildData(info.id, icon); let data = this.getGuildData(info.id, icon);
if (data.url || data.name || data.shortName || data.removeIcon || icon.getAttribute("changed-by-editservers")) { if (data.url || data.name || data.shortName || data.removeIcon || icon.getAttribute("changed-by-editservers")) {
let url = data.url || BDFDB.getGuildIcon(info.id); let url = data.url || BDFDB.GuildUtils.getIcon(info.id);
let name = data.name || info.name || ""; let name = data.name || info.name || "";
let shortname = data.url ? "" : (data.shortName || (info.icon && !data.removeIcon ? "" : info.acronym)); let shortname = data.url ? "" : (data.shortName || (info.icon && !data.removeIcon ? "" : info.acronym));
if (BDFDB.containsClass(icon.parentElement, BDFDB.disCN.guildiconwrapper)) icon.parentElement.setAttribute("aria-label", name); if (BDFDB.containsClass(icon.parentElement, BDFDB.disCN.guildiconwrapper)) icon.parentElement.setAttribute("aria-label", name);
@ -493,11 +491,11 @@ class EditServers {
if (removeicon) { if (removeicon) {
let fakeicon = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.guildiconchildwrapper + BDFDB.disCN.guildiconacronym} fake-guildacronym" aria-label="Server Acronym"></div>`); let fakeicon = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.guildiconchildwrapper + BDFDB.disCN.guildiconacronym} fake-guildacronym" aria-label="Server Acronym"></div>`);
if (data.color1) { if (data.color1) {
if (BDFDB.isObject(data.color1)) fakeicon.style.setProperty("background-image", BDFDB.colorGRADIENT(data.color1)); if (BDFDB.ObjectUtils.is(data.color1)) fakeicon.style.setProperty("background-image", BDFDB.colorGRADIENT(data.color1));
else fakeicon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGBA")); else fakeicon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGBA"));
} }
if (data.color2) fakeicon.style.setProperty("color", BDFDB.colorCONVERT(BDFDB.isObject(data.color2) ? data.color2[Object.keys(data.color2)[0]] : data.color2, "RGBA")); if (data.color2) fakeicon.style.setProperty("color", BDFDB.colorCONVERT(BDFDB.ObjectUtils.is(data.color2) ? data.color2[Object.keys(data.color2)[0]] : data.color2, "RGBA"));
BDFDB.setInnerText(fakeicon, BDFDB.isObject(data.color2) ? BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(shortname)}</span>`) : shortname); BDFDB.setInnerText(fakeicon, BDFDB.ObjectUtils.is(data.color2) ? BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(shortname)}</span>`) : shortname);
icon.parentElement.appendChild(fakeicon); icon.parentElement.appendChild(fakeicon);
fakeicon.style.setProperty("font-size", this.getFontSize(fakeicon)); fakeicon.style.setProperty("font-size", this.getFontSize(fakeicon));
} }
@ -509,18 +507,18 @@ class EditServers {
} }
else { else {
if (data.color1) { if (data.color1) {
if (BDFDB.isObject(data.color1)) icon.style.setProperty("background-image", BDFDB.colorGRADIENT(data.color1)); if (BDFDB.ObjectUtils.is(data.color1)) icon.style.setProperty("background-image", BDFDB.colorGRADIENT(data.color1));
else icon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGBA")); else icon.style.setProperty("background-color", BDFDB.colorCONVERT(data.color1, "RGBA"));
} }
else { else {
icon.style.removeProperty("background-image"); icon.style.removeProperty("background-image");
icon.style.removeProperty("background-color"); icon.style.removeProperty("background-color");
} }
if (data.color2) icon.style.setProperty("color", BDFDB.colorCONVERT(BDFDB.isObject(data.color2) ? data.color2[Object.keys(data.color2)[0]] : data.color2, "RGBA")); if (data.color2) icon.style.setProperty("color", BDFDB.colorCONVERT(BDFDB.ObjectUtils.is(data.color2) ? data.color2[Object.keys(data.color2)[0]] : data.color2, "RGBA"));
BDFDB.setInnerText(icon, BDFDB.isObject(data.color2) ? BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(shortname)}</span>`) : shortname); BDFDB.setInnerText(icon, BDFDB.ObjectUtils.is(data.color2) ? BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color2)} !important;">${BDFDB.encodeToHTML(shortname)}</span>`) : shortname);
} }
icon.style.setProperty("font-size", this.getFontSize(icon)); icon.style.setProperty("font-size", this.getFontSize(icon));
BDFDB.toggleClass(icon, this.getNoIconClasses(icon), !icon.style.getPropertyValue("background-image") || BDFDB.isObject(data.color1)); BDFDB.toggleClass(icon, this.getNoIconClasses(icon), !icon.style.getPropertyValue("background-image") || BDFDB.ObjectUtils.is(data.color1));
if (data.url && !data.removeIcon) { if (data.url && !data.removeIcon) {
icon.style.setProperty("background-position", "center"); icon.style.setProperty("background-position", "center");
icon.style.setProperty("background-size", "cover"); icon.style.setProperty("background-size", "cover");
@ -548,17 +546,17 @@ class EditServers {
let data = this.getGuildData(info.id, wrapper); let data = this.getGuildData(info.id, wrapper);
wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditServers); wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditServers);
if (data.name || data.color3 || data.color4) { if (data.name || data.color3 || data.color4) {
let ServerFolders = BDFDB.getPlugin("ServerFolders", true); let ServerFolders = BDFDB.BdUtils.getPlugin("ServerFolders", true);
let folder = ServerFolders ? ServerFolders.getFolderOfGuildId(info.id) : null; let folder = ServerFolders ? ServerFolders.getFolderOfGuildId(info.id) : null;
let folderData = folder ? BDFDB.loadData(folder.folderId, "ServerFolders", "folders") : null; let folderData = folder ? BDFDB.loadData(folder.folderId, "ServerFolders", "folders") : null;
let color3 = data.color3 || (folderData && folderData.copyTooltipColor ? folderData.color3 : null); let color3 = data.color3 || (folderData && folderData.copyTooltipColor ? folderData.color3 : null);
let color4 = data.color4 || (folderData && folderData.copyTooltipColor ? folderData.color4 : null); let color4 = data.color4 || (folderData && folderData.copyTooltipColor ? folderData.color4 : null);
var isgradient3 = color3 && BDFDB.isObject(color3); var isgradient3 = color3 && BDFDB.ObjectUtils.is(color3);
var isgradient4 = color4 && BDFDB.isObject(color4); var isgradient4 = color4 && BDFDB.ObjectUtils.is(color4);
var bgColor = color3 ? (!isgradient3 ? BDFDB.colorCONVERT(color3, "RGBA") : BDFDB.colorGRADIENT(color3)) : ""; var bgColor = color3 ? (!isgradient3 ? BDFDB.colorCONVERT(color3, "RGBA") : BDFDB.colorGRADIENT(color3)) : "";
var fontColor = color4 ? (!isgradient4 ? BDFDB.colorCONVERT(color4, "RGBA") : BDFDB.colorGRADIENT(color4)) : ""; var fontColor = color4 ? (!isgradient4 ? BDFDB.colorCONVERT(color4, "RGBA") : BDFDB.colorGRADIENT(color4)) : "";
wrapper.tooltipListenerEditServers = () => { wrapper.tooltipListenerEditServers = () => {
BDFDB.createTooltip(isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(data.name || info.name)}</span>` : (data.name || info.name), wrapper, {type, selector:"EditServers-tooltip", style:`${isgradient4 ? '' : 'color: ' + fontColor + ' !important; '}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(color3[0], "RGBA") : bgColor} !important;`, html:isgradient3}); BDFDB.TooltipUtils.create(wrapper, isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(data.name || info.name)}</span>` : (data.name || info.name), {type, selector:"EditServers-tooltip", style:`${isgradient4 ? '' : 'color: ' + fontColor + ' !important; '}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(color3[0], "RGBA") : bgColor} !important;`, html:isgradient3});
}; };
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditServers); wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditServers);
if (document.querySelector(BDFDB.dotCN.guildcontainer + ":hover") == wrapper) wrapper.tooltipListenerEditServers(); if (document.querySelector(BDFDB.dotCN.guildcontainer + ":hover") == wrapper) wrapper.tooltipListenerEditServers();

View File

@ -104,18 +104,18 @@ class EditUsers {
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
var settingsitems = [], inneritems = []; var settingsitems = [], inneritems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["settings", key], keys: ["settings", key],
label: this.defaults.settings[key].description, label: this.defaults.settings[key].description,
value: settings[key] value: settings[key]
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "Change Users in:", title: "Change Users in:",
children: inneritems children: inneritems
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Button", type: "Button",
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED, color: BDFDB.LibraryComponents.Button.Colors.RED,
@ -129,7 +129,7 @@ class EditUsers {
children: BDFDB.LanguageUtils.LanguageStrings.RESET children: BDFDB.LanguageUtils.LanguageStrings.RESET
})); }));
return BDFDB.createSettingsPanel(this, settingsitems); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
} }
//legacy //legacy
@ -156,16 +156,14 @@ class EditUsers {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
var observer = new MutationObserver(() => {this.changeAppTitle();}); var observer = new MutationObserver(() => {this.changeAppTitle();});
BDFDB.addObserver(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true}); BDFDB.ObserverUtils.connect(this, document.head.querySelector("title"), {name:"appTitleObserver",instance:observer}, {childList:true});
this.forceUpdateAll(); this.forceUpdateAll();
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
@ -180,7 +178,7 @@ class EditUsers {
BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow"); BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -190,16 +188,16 @@ class EditUsers {
onUserContextMenu (instance, menu, returnvalue) { onUserContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_localusersettings_text, label: this.labels.context_localusersettings_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-usersettings-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-usersettings-contextMenuSubItem`,
render: [BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { render: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_usersettings_text, label: this.labels.submenu_usersettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-usersettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-usersettings-ContextMenuItem`,
action: e => { action: e => {
@ -207,7 +205,7 @@ class EditUsers {
this.showUserSettings(instance.props.user); this.showUserSettings(instance.props.user);
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_resetsettings_text, label: this.labels.submenu_resetsettings_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-resetsettings-ContextMenuItem`,
disabled: !BDFDB.loadData(instance.props.user.id, this, "users"), disabled: !BDFDB.loadData(instance.props.user.id, this, "users"),
@ -229,7 +227,7 @@ class EditUsers {
forceUpdateAll () { forceUpdateAll () {
this.changeAppTitle(); this.changeAppTitle();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
showUserSettings (info) { showUserSettings (info) {
@ -241,38 +239,38 @@ class EditUsers {
header: this.labels.modal_header_text, header: this.labels.modal_header_text,
subheader: member.nick || info.username, subheader: member.nick || info.username,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader1_text, tab: this.labels.modal_tabheader1_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_username_text, title: this.labels.modal_username_text,
className: BDFDB.disCN.marginbottom20 + " input-username", className: BDFDB.disCN.marginbottom20 + " input-username",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.name, value: data.name,
placeholder: member.nick || info.username, placeholder: member.nick || info.username,
autoFocus: true autoFocus: true
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_usertag_text, title: this.labels.modal_usertag_text,
className: BDFDB.disCN.marginbottom20 + " input-usertag", className: BDFDB.disCN.marginbottom20 + " input-usertag",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
value: data.tag value: data.tag
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_useravatar_text, title: this.labels.modal_useravatar_text,
className: BDFDB.disCN.marginbottom8 + " input-useravatar", className: BDFDB.disCN.marginbottom8 + " input-useravatar",
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.TextInput, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextInput, {
inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null, inputClassName: !data.removeIcon && data.url ? BDFDB.disCN.inputsuccess : null,
inputId: "USERAVATAR", inputId: "USERAVATAR",
value: data.url, value: data.url,
placeholder: BDFDB.getUserAvatar(info.id), placeholder: BDFDB.UserUtils.getAvatar(info.id),
disabled: data.removeIcon, disabled: data.removeIcon,
onFocus: e => { onFocus: e => {
this.createNoticeTooltip(e.target); this.createNoticeTooltip(e.target);
@ -283,7 +281,7 @@ class EditUsers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
className: BDFDB.disCN.marginbottom20 + " input-removeicon", className: BDFDB.disCN.marginbottom20 + " input-removeicon",
label: this.labels.modal_removeicon_text, label: this.labels.modal_removeicon_text,
@ -299,24 +297,24 @@ class EditUsers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader2_text, tab: this.labels.modal_tabheader2_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker1_text, title: this.labels.modal_colorpicker1_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color1, color: data.color1,
number: 1 number: 1
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker2_text, title: this.labels.modal_colorpicker2_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color2, color: data.color2,
number: 2 number: 2
}) })
@ -324,32 +322,32 @@ class EditUsers {
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ModalTabContent, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalTabContent, {
tab: this.labels.modal_tabheader3_text, tab: this.labels.modal_tabheader3_text,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker3_text, title: this.labels.modal_colorpicker3_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color3, color: data.color3,
number: 3, number: 3,
disabled: data.ignoreTagColor disabled: data.ignoreTagColor
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormItem, {
title: this.labels.modal_colorpicker4_text, title: this.labels.modal_colorpicker4_text,
className: BDFDB.disCN.marginbottom20, className: BDFDB.disCN.marginbottom20,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ColorSwatches, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ColorSwatches, {
color: data.color4, color: data.color4,
number: 4, number: 4,
disabled: data.ignoreTagColor disabled: data.ignoreTagColor
}) })
] ]
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Switch", type: "Switch",
className: BDFDB.disCN.marginbottom20 + " input-ignoretagcolor", className: BDFDB.disCN.marginbottom20 + " input-ignoretagcolor",
label: this.labels.modal_ignoretagcolor_text, label: this.labels.modal_ignoretagcolor_text,
@ -398,7 +396,7 @@ class EditUsers {
} }
processChannelTextArea (instance, wrapper, returnvalue) { processChannelTextArea (instance, wrapper, returnvalue) {
let channel = BDFDB.getReactValue(instance, "props.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "props.channel");
if (channel) { if (channel) {
var textarea = wrapper.querySelector("textarea"); var textarea = wrapper.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
@ -409,13 +407,13 @@ class EditUsers {
textarea.setAttribute("placeholder", BDFDB.LanguageUtils.LanguageStrings.TEXTAREA_PLACEHOLDER.replace("{{channel}}", "@" + (data.name || user.username))); textarea.setAttribute("placeholder", BDFDB.LanguageUtils.LanguageStrings.TEXTAREA_PLACEHOLDER.replace("{{channel}}", "@" + (data.name || user.username)));
} }
} }
BDFDB.removeEventListener(this, textarea); BDFDB.ListenerUtils.remove(this, textarea);
if (BDFDB.getData("changeInAutoComplete", this, "settings")) { if (BDFDB.getData("changeInAutoComplete", this, "settings")) {
BDFDB.addEventListener(this, textarea, "keydown", e => { BDFDB.ListenerUtils.add(this, textarea, "keydown", e => {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete); let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCN.autocomplete);
if (autocompletemenu && (e.which == 9 || e.which == 13)) { if (autocompletemenu && (e.which == 9 || e.which == 13)) {
if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteEditUsersRow")) { if (BDFDB.containsClass(autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected).parentElement, "autocompleteEditUsersRow")) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
this.swapWordWithMention(textarea); this.swapWordWithMention(textarea);
} }
} }
@ -423,7 +421,7 @@ class EditUsers {
let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteEditUsersSelector)"); let autocompleteitems = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable + ":not(.autocompleteEditUsersSelector)");
let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected); let selected = autocompletemenu.querySelector(BDFDB.dotCN.autocompleteselected);
if (BDFDB.containsClass(selected, "autocompleteEditUsersSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) { if (BDFDB.containsClass(selected, "autocompleteEditUsersSelector") || autocompleteitems[e.which == 38 ? 0 : (autocompleteitems.length-1)] == selected) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true); let next = this.getNextSelection(autocompletemenu, null, e.which == 38 ? false : true);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
@ -441,7 +439,7 @@ class EditUsers {
if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow"); if (!e.ctrlKey && e.which != 38 && e.which != 40 && !(e.which == 39 && textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length)) BDFDB.removeEles(".autocompleteEditUsers", ".autocompleteEditUsersRow");
}); });
BDFDB.addEventListener(this, textarea, "click", e => { BDFDB.ListenerUtils.add(this, textarea, "click", e => {
if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);}); if (textarea.selectionStart == textarea.selectionEnd && textarea.selectionEnd == textarea.value.length) setImmediate(() => {this.addAutoCompleteMenu(textarea, channel);});
}); });
} }
@ -492,7 +490,7 @@ class EditUsers {
} }
processAccount (instance, wrapper, returnvalue) { processAccount (instance, wrapper, returnvalue) {
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.child.stateNode.props.currentUser"); let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.child.stateNode.props.currentUser");
if (user) { if (user) {
this.changeName(user, wrapper.querySelector(BDFDB.dotCN.accountinfodetails).firstElementChild); this.changeName(user, wrapper.querySelector(BDFDB.dotCN.accountinfodetails).firstElementChild);
this.changeAvatar(user, this.getAvatarDiv(wrapper)); this.changeAvatar(user, this.getAvatarDiv(wrapper));
@ -500,7 +498,7 @@ class EditUsers {
} }
processMessageUsername (instance, wrapper, returnvalue) { processMessageUsername (instance, wrapper, returnvalue) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message) { if (message) {
let username = wrapper.querySelector(BDFDB.dotCN.messageusername); let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
if (username) { if (username) {
@ -514,10 +512,10 @@ class EditUsers {
} }
processAuditLog (instance, wrapper, returnvalue) { processAuditLog (instance, wrapper, returnvalue) {
let log = BDFDB.getReactValue(instance, "props.log"); let log = BDFDB.ReactUtils.getValue(instance, "props.log");
if (log && log.user) { if (log && log.user) {
let hooks = wrapper.querySelectorAll(BDFDB.dotCN.auditloguserhook); let hooks = wrapper.querySelectorAll(BDFDB.dotCN.auditloguserhook);
let guild_id = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.guildId"); let guild_id = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.guildId");
if (hooks.length > 0) this.changeName2(log.user, hooks[0].firstChild, guild_id); if (hooks.length > 0) this.changeName2(log.user, hooks[0].firstChild, guild_id);
if (hooks.length > 1 && log.targetType == "USER") this.changeName2(log.target, hooks[1].firstChild, guild_id); if (hooks.length > 1 && log.targetType == "USER") this.changeName2(log.target, hooks[1].firstChild, guild_id);
} }
@ -534,7 +532,7 @@ class EditUsers {
} }
processInviteCard (instance, wrapper, returnvalue) { processInviteCard (instance, wrapper, returnvalue) {
let invite = BDFDB.getReactValue(instance, "props.invite"); let invite = BDFDB.ReactUtils.getValue(instance, "props.invite");
if (invite && invite.inviter && invite.guild) { if (invite && invite.inviter && invite.guild) {
let username = wrapper.querySelector(BDFDB.dotCN.username); let username = wrapper.querySelector(BDFDB.dotCN.username);
if (username) { if (username) {
@ -565,14 +563,14 @@ class EditUsers {
} }
processTypingUsers (instance, wrapper, returnvalue) { processTypingUsers (instance, wrapper, returnvalue) {
let users = !instance.props.typingUsers ? [] : Object.keys(instance.props.typingUsers).filter(id => id != BDFDB.myData.id).filter(id => !BDFDB.LibraryModules.FriendUtils.isBlocked(id)).map(id => BDFDB.LibraryModules.UserStore.getUser(id)).filter(id => id != null); let users = !instance.props.typingUsers ? [] : Object.keys(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(id => id != null);
wrapper.querySelectorAll(BDFDB.dotCNS.typing + "strong").forEach((username, i) => { wrapper.querySelectorAll(BDFDB.dotCNS.typing + "strong").forEach((username, i) => {
if (users[i] && username) this.changeName2(users[i], username); if (users[i] && username) this.changeName2(users[i], username);
}); });
} }
processDirectMessage (instance, wrapper, returnvalue) { processDirectMessage (instance, wrapper, returnvalue) {
let channel = BDFDB.getReactValue(instance, "props.channel"); let channel = BDFDB.ReactUtils.getValue(instance, "props.channel");
if (channel && channel.type == 1) { if (channel && channel.type == 1) {
let user = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]); let user = BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]);
if (user) { if (user) {
@ -627,7 +625,7 @@ class EditUsers {
} }
processHeaderBar (instance, wrapper, returnvalue) { processHeaderBar (instance, wrapper, returnvalue) {
let channel_id = BDFDB.getReactValue(instance, "props.channelId") || BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.channelId"); let channel_id = BDFDB.ReactUtils.getValue(instance, "props.channelId") || BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.channelId");
if (channel_id) { if (channel_id) {
let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderheaderbartitle); let channelname = wrapper.querySelector(BDFDB.dotCN.channelheaderheaderbartitle);
if (channelname) { if (channelname) {
@ -636,7 +634,7 @@ class EditUsers {
if (channel.type == 1) this.changeName(BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]), channelname); if (channel.type == 1) this.changeName(BDFDB.LibraryModules.UserStore.getUser(channel.recipients[0]), channelname);
else { else {
if (channelname.EditUsersChangeObserver && typeof channelname.EditUsersChangeObserver.disconnect == "function") channelname.EditUsersChangeObserver.disconnect(); if (channelname.EditUsersChangeObserver && typeof channelname.EditUsersChangeObserver.disconnect == "function") channelname.EditUsersChangeObserver.disconnect();
if (BDFDB.isPluginEnabled("EditChannels")) BDFDB.getPlugin("EditChannels").changeChannel(channel, channelname); if (BDFDB.BdUtils.isPluginEnabled("EditChannels")) BDFDB.BdUtils.getPlugin("EditChannels").changeChannel(channel, channelname);
else { else {
channelname.style.removeProperty("color"); channelname.style.removeProperty("color");
channelname.style.removeProperty("background"); channelname.style.removeProperty("background");
@ -660,7 +658,7 @@ class EditUsers {
} }
} }
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) { else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) {
let render = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.stateNode.props.render"); let render = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.stateNode.props.render");
if (typeof render == "function") { if (typeof render == "function") {
var props = render().props; var props = render().props;
if (props && props.user) this.changeMention(props.user, wrapper); if (props && props.user) this.changeMention(props.user, wrapper);
@ -668,21 +666,21 @@ class EditUsers {
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.quickswitchresult) > -1) {
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.user"); let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.user");
if (user) { if (user) {
this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch)); this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.quickswitchresultmatch));
this.changeAvatar(user, this.getAvatarDiv(wrapper)); this.changeAvatar(user, this.getAvatarDiv(wrapper));
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) {
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.user"); let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.user");
if (user) { if (user) {
this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.marginleft8)); this.changeName2(user, wrapper.querySelector(BDFDB.dotCN.marginleft8));
this.changeAvatar(user, this.getAvatarDiv(wrapper)); this.changeAvatar(user, this.getAvatarDiv(wrapper));
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.searchpopoutuser) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.searchpopoutuser) > -1) {
let result = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.result"); let result = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.result");
if (result && result.user) { if (result && result.user) {
this.changeName3(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayednick)); this.changeName3(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayednick));
this.changeAvatar(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayavatar)); this.changeAvatar(result.user, wrapper.querySelector(BDFDB.dotCN.searchpopoutdisplayavatar));
@ -691,14 +689,14 @@ class EditUsers {
} }
processMessageContent (instance, wrapper, returnvalue) { processMessageContent (instance, wrapper, returnvalue) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message && message.author) { if (message && message.author) {
let markup = wrapper.querySelector(BDFDB.dotCN.messagemarkup); let markup = wrapper.querySelector(BDFDB.dotCN.messagemarkup);
if (markup) { if (markup) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id) || {}; let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id) || {};
let member = BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, message.author.id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, message.author.id) || {};
let data = this.getUserData(message.author.id, wrapper); let data = this.getUserData(message.author.id, wrapper);
markup.style.setProperty("color", window.settingsCookie["bda-gs-7"] ? BDFDB.colorCONVERT(data.color1 && !BDFDB.isObject(data.color1) ? data.color1 : member.colorString, "RGBA") : null, "important"); markup.style.setProperty("color", window.settingsCookie["bda-gs-7"] ? BDFDB.colorCONVERT(data.color1 && !BDFDB.ObjectUtils.is(data.color1) ? data.color1 : member.colorString, "RGBA") : null, "important");
} }
} }
} }
@ -711,7 +709,7 @@ class EditUsers {
} }
checkUrl (url, instance) { checkUrl (url, instance) {
let input = BDFDB.React.findDOMNode(instance).firstElementChild; let input = BDFDB.ReactUtils.findDOMNode(instance).firstElementChild;
clearTimeout(instance.checkTimeout); clearTimeout(instance.checkTimeout);
if (url == null || !url.trim()) { if (url == null || !url.trim()) {
if (input) BDFDB.removeEles(input.tooltip); if (input) BDFDB.removeEles(input.tooltip);
@ -739,7 +737,7 @@ class EditUsers {
BDFDB.removeEles(input.tooltip); BDFDB.removeEles(input.tooltip);
var invalid = isinvalid || BDFDB.containsClass(input, BDFDB.disCN.inputerror); var invalid = isinvalid || BDFDB.containsClass(input, BDFDB.disCN.inputerror);
var valid = invalid ? false : BDFDB.containsClass(input, BDFDB.disCN.inputsuccess); var valid = invalid ? false : BDFDB.containsClass(input, BDFDB.disCN.inputsuccess);
if (invalid || valid) input.tooltip = BDFDB.createTooltip(invalid ? this.labels.modal_invalidurl_text : this.labels.modal_validurl_text, input, {type:"right", selector:"notice-tooltip", color: invalid ? "red" : "green"}); if (invalid || valid) input.tooltip = BDFDB.TooltipUtils.create(input, invalid ? this.labels.modal_invalidurl_text : this.labels.modal_validurl_text, {type:"right", selector:"notice-tooltip", color: invalid ? "red" : "green"});
} }
changeAppTitle () { changeAppTitle () {
@ -761,11 +759,11 @@ class EditUsers {
let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {};
this.changeBotTags(data, username, member); this.changeBotTags(data, username, member);
if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) { if (data.name || data.color1 || data.color2 || username.getAttribute("changed-by-editusers")) {
let isBRCenabled = BDFDB.isPluginEnabled("BetterRoleColors"); let isBRCenabled = BDFDB.BdUtils.isPluginEnabled("BetterRoleColors");
let usenick = !BDFDB.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname, BDFDB.disCN.accountinfodetails, false) && member.nick; let usenick = !BDFDB.containsClass(username, BDFDB.disCN.userprofileusername) && !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname, BDFDB.disCN.accountinfodetails, false) && member.nick;
let usemembercolor = !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname) && (BDFDB.containsClass(username, BDFDB.disCN.memberusername, BDFDB.disCN.messageusername, false) || isBRCenabled); let usemembercolor = !BDFDB.containsClass(username.parentElement, BDFDB.disCN.userprofilelistname) && (BDFDB.containsClass(username, BDFDB.disCN.memberusername, BDFDB.disCN.messageusername, false) || isBRCenabled);
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || (usenick ? member.nick : info.username))}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || (usenick ? member.nick : info.username))}</span>`));
} }
@ -774,7 +772,7 @@ class EditUsers {
BDFDB.setInnerText(username, data.name || (usenick ? member.nick : info.username)); BDFDB.setInnerText(username, data.name || (usenick ? member.nick : info.username));
} }
username.style.setProperty("background", BDFDB.isObject(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important"); username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important");
if (data.name || data.color1 || data.color2) { if (data.name || data.color1 || data.color2) {
username.setAttribute("changed-by-editusers", true); username.setAttribute("changed-by-editusers", true);
@ -795,12 +793,12 @@ class EditUsers {
let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(guildid, info.id) || {};
this.changeBotTags(data, username, member); this.changeBotTags(data, username, member);
if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) { if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`));
} }
else { else {
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : null), "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCONVERT(data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : null), "RGBA"), "important");
BDFDB.setInnerText(username, data.name || member.nick || info.username); BDFDB.setInnerText(username, data.name || member.nick || info.username);
} }
if (data.name || data.color1) { if (data.name || data.color1) {
@ -821,10 +819,10 @@ class EditUsers {
let data = this.getUserData(info.id, username); let data = this.getUserData(info.id, username);
if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) { if (data.name || data.color1 || username.getAttribute("changed-by-editusers")) {
if (adddisc) { if (adddisc) {
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span ${data.color1 ? (BDFDB.isObject(data.color1) ? 'style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image:' + BDFDB.colorGRADIENT(data.color1) + ' !important;"' : 'style="color:' + data.color1 + ' !important;"'): ''}>${BDFDB.encodeToHTML(data.name || info.username)}</span><span${typeof adddisc == "string" ? ' class="' + adddisc + '"' : ''}>#${info.discriminator}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span ${data.color1 ? (BDFDB.ObjectUtils.is(data.color1) ? 'style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image:' + BDFDB.colorGRADIENT(data.color1) + ' !important;"' : 'style="color:' + data.color1 + ' !important;"'): ''}>${BDFDB.encodeToHTML(data.name || info.username)}</span><span${typeof adddisc == "string" ? ' class="' + adddisc + '"' : ''}>#${info.discriminator}</span>`));
} }
else { else {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCONVERT(data.color1[Object.keys(data.color1)[0]], "RGBA"), "important");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`));
} }
@ -847,7 +845,7 @@ class EditUsers {
changeBotTags (data, username, member) { changeBotTags (data, username, member) {
for (let tag of username.parentElement.parentElement.querySelectorAll(BDFDB.dotCN.bottag)) if (!BDFDB.containsClass(tag, "TRE-tag")) { for (let tag of username.parentElement.parentElement.querySelectorAll(BDFDB.dotCN.bottag)) if (!BDFDB.containsClass(tag, "TRE-tag")) {
let isBRCbottagsEnabled = BDFDB.getReactValue(BDFDB.getPlugin("BetterRoleColors", true), "settings.modules.botTags"); let isBRCbottagsEnabled = BDFDB.ReactUtils.getValue(BDFDB.BdUtils.getPlugin("BetterRoleColors", true), "settings.modules.botTags");
let tagcolor = BDFDB.colorCONVERT(data.color1 || (isBRCbottagsEnabled || BDFDB.containsClass(tag, "owner-tag-rolecolor") ? member.colorString : null), "RGBA"); let tagcolor = BDFDB.colorCONVERT(data.color1 || (isBRCbottagsEnabled || BDFDB.containsClass(tag, "owner-tag-rolecolor") ? member.colorString : null), "RGBA");
tagcolor = BDFDB.colorISBRIGHT(tagcolor) ? BDFDB.colorCHANGE(tagcolor, -0.3) : tagcolor; tagcolor = BDFDB.colorISBRIGHT(tagcolor) ? BDFDB.colorCHANGE(tagcolor, -0.3) : tagcolor;
tag.style.setProperty(BDFDB.containsClass(tag, BDFDB.disCN.bottaginvert) ? "color" : "background-color", tagcolor, "important"); tag.style.setProperty(BDFDB.containsClass(tag, BDFDB.disCN.bottaginvert) ? "color" : "background-color", tagcolor, "important");
@ -859,9 +857,9 @@ class EditUsers {
if (avatar.EditUsersChangeObserver && typeof avatar.EditUsersChangeObserver.disconnect == "function") avatar.EditUsersChangeObserver.disconnect(); if (avatar.EditUsersChangeObserver && typeof avatar.EditUsersChangeObserver.disconnect == "function") avatar.EditUsersChangeObserver.disconnect();
let data = this.getUserData(info.id, avatar); let data = this.getUserData(info.id, avatar);
if (data.url || data.removeIcon || avatar.getAttribute("changed-by-editusers")) { if (data.url || data.removeIcon || avatar.getAttribute("changed-by-editusers")) {
if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.getUserAvatar(info.id))); if (avatar.tagName == "IMG") avatar.setAttribute("src", data.removeIcon ? null : (data.url || BDFDB.UserUtils.getAvatar(info.id)));
else { else {
let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.getUserAvatar(info.id)) + ")"); let url = data.removeIcon ? null : ("url(" + (data.url || BDFDB.UserUtils.getAvatar(info.id)) + ")");
if (url && BDFDB.getParentEle(BDFDB.dotCN.userprofile, avatar) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)"); if (url && BDFDB.getParentEle(BDFDB.dotCN.userprofile, avatar) && url.search(/discordapp\.com\/avatars\/[0-9]*\/a_/) > -1) url = url.replace(".webp)", ".gif)");
avatar.style.setProperty("background-image", url); avatar.style.setProperty("background-image", url);
if (data.url && !data.removeIcon) { if (data.url && !data.removeIcon) {
@ -888,7 +886,7 @@ class EditUsers {
wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditUsers); wrapper.removeEventListener("mouseenter", wrapper.tooltipListenerEditUsers);
if (data.name) { if (data.name) {
wrapper.tooltipListenerEditUsers = () => { wrapper.tooltipListenerEditUsers = () => {
BDFDB.createTooltip(data.name, wrapper, {type, selector:"EditUsers-tooltip", hide:true}); BDFDB.TooltipUtils.create(wrapper, data.name, {type, selector:"EditUsers-tooltip", hide:true});
}; };
wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditUsers); wrapper.addEventListener("mouseenter", wrapper.tooltipListenerEditUsers);
} }
@ -900,15 +898,15 @@ class EditUsers {
let data = this.getUserData(info.id, wrapper); let data = this.getUserData(info.id, wrapper);
if (data.tag) { if (data.tag) {
let member = data.ignoreTagColor ? (BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}) : {}; let member = data.ignoreTagColor ? (BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}) : {};
let color3 = BDFDB.isObject(data.color3) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color3) : BDFDB.colorCONVERT(!data.ignoreTagColor ? data.color3 : member.colorString, "RGBA"); let color3 = BDFDB.ObjectUtils.is(data.color3) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color3) : BDFDB.colorCONVERT(!data.ignoreTagColor ? data.color3 : member.colorString, "RGBA");
let color4 = BDFDB.isObject(data.color4) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color4) : (!data.ignoreTagColor && data.color4 ? BDFDB.colorCONVERT(data.color4, "RGBA") : (color3 ? (BDFDB.colorISBRIGHT(color3) ? "black" : "white") : null)); let color4 = BDFDB.ObjectUtils.is(data.color4) && !data.ignoreTagColor ? BDFDB.colorGRADIENT(data.color4) : (!data.ignoreTagColor && data.color4 ? BDFDB.colorCONVERT(data.color4, "RGBA") : (color3 ? (BDFDB.colorISBRIGHT(color3) ? "black" : "white") : null));
let tag = document.createElement("span"); let tag = document.createElement("span");
let invert = container && !color3 && !color4 && container.firstElementChild && !(BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal) || BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userprofiletopsectionnormal)); let invert = container && !color3 && !color4 && container.firstElementChild && !(BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal) || BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userprofiletopsectionnormal));
tag.className = "EditUsers-tag " + (!invert ? BDFDB.disCN.bottagregular : BDFDB.disCN.bottaginvert) + (selector ? (" " + selector) : ""); tag.className = "EditUsers-tag " + (!invert ? BDFDB.disCN.bottagregular : BDFDB.disCN.bottaginvert) + (selector ? (" " + selector) : "");
tag.style.setProperty("background", !invert ? color3 : color4, "important"); tag.style.setProperty("background", !invert ? color3 : color4, "important");
let fontcolor = invert ? color3 : color4; let fontcolor = invert ? color3 : color4;
let fontobj = invert ? data.color3 : data.color4; let fontobj = invert ? data.color3 : data.color4;
if (BDFDB.isObject(fontobj)) tag.appendChild(BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontcolor} !important;">${BDFDB.encodeToHTML(data.tag)}</span>`)); if (BDFDB.ObjectUtils.is(fontobj)) tag.appendChild(BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontcolor} !important;">${BDFDB.encodeToHTML(data.tag)}</span>`));
else { else {
tag.innerText = data.tag; tag.innerText = data.tag;
tag.style.setProperty("color", fontcolor, "important"); tag.style.setProperty("color", fontcolor, "important");
@ -949,7 +947,7 @@ class EditUsers {
} }
else username.removeAttribute("changed-by-editusers"); else username.removeAttribute("changed-by-editusers");
function colorDefault() { function colorDefault() {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.removeProperty("color"); username.style.removeProperty("color");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(BDFDB.colorCHANGE(data.color1, -0.5))} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(BDFDB.colorCHANGE(data.color1, -0.5))} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`));
} }
@ -957,10 +955,10 @@ class EditUsers {
username.style.setProperty("color", BDFDB.colorCHANGE(data.color1, -0.5, "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCHANGE(data.color1, -0.5, "RGBA"), "important");
BDFDB.setInnerText(username, data.name || info.username); BDFDB.setInnerText(username, data.name || info.username);
} }
username.style.setProperty("background", BDFDB.isObject(data.color2) ? BDFDB.colorGRADIENT(BDFDB.colorCHANGE(data.color2, -0.5)) : BDFDB.colorCHANGE(data.color2, -0.5, "RGBA"), "important"); username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(BDFDB.colorCHANGE(data.color2, -0.5)) : BDFDB.colorCHANGE(data.color2, -0.5, "RGBA"), "important");
} }
function colorHover() { function colorHover() {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.removeProperty("color"); username.style.removeProperty("color");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || info.username)}</span>`));
} }
@ -968,7 +966,7 @@ class EditUsers {
username.style.setProperty("color", BDFDB.colorCONVERT(data.color1, "RGBA"), "important"); username.style.setProperty("color", BDFDB.colorCONVERT(data.color1, "RGBA"), "important");
BDFDB.setInnerText(username, data.name || info.username); BDFDB.setInnerText(username, data.name || info.username);
} }
username.style.setProperty("background", BDFDB.isObject(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important"); username.style.setProperty("background", BDFDB.ObjectUtils.is(data.color2) ? BDFDB.colorGRADIENT(data.color2) : BDFDB.colorCONVERT(data.color2, "RGBA"), "important");
} }
} }
} }
@ -980,10 +978,10 @@ class EditUsers {
mention.removeEventListener("mouseout", mention.mouseoutListenerEditUsers); mention.removeEventListener("mouseout", mention.mouseoutListenerEditUsers);
let data = this.getUserData(info.id, mention); let data = this.getUserData(info.id, mention);
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {};
let name = "@" + (data.name ? data.name : (BDFDB.isPluginEnabled("RemoveNicknames") ? BDFDB.getPlugin("RemoveNicknames").getNewName(info, mention) : member.nick || info.username)); let name = "@" + (data.name ? data.name : (BDFDB.BdUtils.isPluginEnabled("RemoveNicknames") ? BDFDB.BdUtils.getPlugin("RemoveNicknames").getNewName(info, mention) : member.nick || info.username));
let isgradient = data.color1 && BDFDB.isObject(data.color1); let isgradient = data.color1 && BDFDB.ObjectUtils.is(data.color1);
let datacolor = data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : null); let datacolor = data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : null);
let color = isgradient ? BDFDB.colorGRADIENT(data.color1) : BDFDB.colorCONVERT(datacolor, "RGBA"); let color = isgradient ? BDFDB.colorGRADIENT(data.color1) : BDFDB.colorCONVERT(datacolor, "RGBA");
let color0_1 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.1, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.1, "RGBA"); let color0_1 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.1, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.1, "RGBA");
let color0_7 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.7, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.7, "RGBA"); let color0_7 = isgradient ? BDFDB.colorGRADIENT(BDFDB.colorSETALPHA(data.color1, 0.7, "RGBA")) : BDFDB.colorSETALPHA(datacolor, 0.7, "RGBA");
@ -1052,18 +1050,18 @@ class EditUsers {
} }
else username.removeAttribute("changed-by-editusers"); else username.removeAttribute("changed-by-editusers");
function colorDefault() { function colorDefault() {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.removeProperty("color"); username.style.removeProperty("color");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(!speaking ? BDFDB.colorCHANGE(data.color1, -50) : data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(!speaking ? BDFDB.colorCHANGE(data.color1, -50) : data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`));
} }
else { else {
var color1 = data.color1 || (BDFDB.isPluginEnabled("BetterRoleColors") ? member.colorString : ""); var color1 = data.color1 || (BDFDB.BdUtils.isPluginEnabled("BetterRoleColors") ? member.colorString : "");
username.style.setProperty("color", !speaking ? BDFDB.colorCHANGE(color1, -50, "RGBA") : BDFDB.colorCONVERT(color1, "RGBA"), "important"); username.style.setProperty("color", !speaking ? BDFDB.colorCHANGE(color1, -50, "RGBA") : BDFDB.colorCONVERT(color1, "RGBA"), "important");
BDFDB.setInnerText(username, data.name || member.nick || info.username); BDFDB.setInnerText(username, data.name || member.nick || info.username);
} }
} }
function colorHover() { function colorHover() {
if (BDFDB.isObject(data.color1)) { if (BDFDB.ObjectUtils.is(data.color1)) {
username.style.removeProperty("color"); username.style.removeProperty("color");
BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`)); BDFDB.setInnerText(username, BDFDB.htmlToElement(`<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || member.nick || info.username)}</span>`));
} }
@ -1128,9 +1126,7 @@ class EditUsers {
wrapper.EditUsersCachedDataState = true; wrapper.EditUsersCachedDataState = true;
return data; return data;
} }
else { else return {};
return {};
}
} }
addAutoCompleteMenu (textarea, channel) { addAutoCompleteMenu (textarea, channel) {
@ -1146,7 +1142,7 @@ class EditUsers {
let member = user ? BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, id) : null; let member = user ? BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, id) : null;
if (user && member) userarray.push(Object.assign({lowercasename:users[id].name.toLowerCase(),user,member},users[id])); if (user && member) userarray.push(Object.assign({lowercasename:users[id].name.toLowerCase(),user,member},users[id]));
} }
userarray = BDFDB.sortArrayByKey(userarray.filter(n => n.lowercasename.indexOf(lastword.toLowerCase().slice(1)) != -1), "lowercasename"); userarray = BDFDB.ArrayUtils.keySort(userarray.filter(n => n.lowercasename.indexOf(lastword.toLowerCase().slice(1)) != -1), "lowercasename");
if (userarray.length) { if (userarray.length) {
let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15; let autocompletemenu = textarea.parentElement.querySelector(BDFDB.dotCNS.autocomplete + BDFDB.dotCN.autocompleteinner), amount = 15;
if (!autocompletemenu) { if (!autocompletemenu) {
@ -1158,7 +1154,7 @@ class EditUsers {
amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length; amount -= autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselectable).length;
} }
BDFDB.addEventListener(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => { BDFDB.ListenerUtils.add(this, autocompletemenu, "mouseenter", BDFDB.dotCN.autocompleteselectable, e => {
var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected); var selected = autocompletemenu.querySelectorAll(BDFDB.dotCN.autocompleteselected);
BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected); BDFDB.removeClass(selected, BDFDB.disCN.autocompleteselected);
BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector); BDFDB.addClass(selected, BDFDB.disCN.autocompleteselector);
@ -1167,10 +1163,10 @@ class EditUsers {
for (let data of userarray) { for (let data of userarray) {
if (amount-- < 1) break; if (amount-- < 1) break;
let status = BDFDB.getUserStatus(data.user.id); let status = BDFDB.UserUtils.getStatus(data.user.id);
let isgradient = data.color1 && BDFDB.isObject(data.color1); let isgradient = data.color1 && BDFDB.ObjectUtils.is(data.color1);
let username = isgradient ? `<div class="${BDFDB.disCN.marginleft8}" changed-by-editusers="true" style="flex: 1 1 auto;"><span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || data.member.nick || data.user.username)}</span></div>` : `<div class="${BDFDB.disCN.marginleft8}" changed-by-editusers="true" style="flex: 1 1 auto;${data.color1 ? (' color: ' + BDFDB.colorCONVERT(data.color1, 'RGB') + ' !important;') : ''}">${BDFDB.encodeToHTML(data.name || data.member.nick || data.user.username)}</div>`; let username = isgradient ? `<div class="${BDFDB.disCN.marginleft8}" changed-by-editusers="true" style="flex: 1 1 auto;"><span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${BDFDB.colorGRADIENT(data.color1)} !important;">${BDFDB.encodeToHTML(data.name || data.member.nick || data.user.username)}</span></div>` : `<div class="${BDFDB.disCN.marginleft8}" changed-by-editusers="true" style="flex: 1 1 auto;${data.color1 ? (' color: ' + BDFDB.colorCONVERT(data.color1, 'RGB') + ' !important;') : ''}">${BDFDB.encodeToHTML(data.name || data.member.nick || data.user.username)}</div>`;
let autocompleterow = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteEditUsersRow"><div userid="${data.user.id}" class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteEditUsersSelector"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletecontent}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${data.user.username}, ${BDFDB.LanguageUtils.LanguageStrings["STATUS_" + status.toUpperCase()]}" aria-hidden="false" style="width: 24px; height: 24px;"><svg width="30" height="24" viewBox="0 0 30 24" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="24" height="24" mask="url(#svg-mask-avatar-status-round-24)"><img src="${data.url || BDFDB.getUserAvatar(data.user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject><rect width="8" height="8" x="16" y="16" fill="${BDFDB.getUserStatusColor(status)}" mask="url(#svg-mask-status-${status})" class="${BDFDB.disCN.avatarpointerevents}"></rect></svg></div>${username}<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletedescription}" style="flex: 0 1 auto;"><div class="${BDFDB.disCN.autocompletedescriptionusername}">${BDFDB.encodeToHTML(data.user.username)}</div><div class="${BDFDB.disCN.autocompletedescriptiondiscriminator}">#${data.user.discriminator}</div></div></div></div></div>`); let autocompleterow = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.autocompleterowvertical + BDFDB.disCN.autocompleterow} autocompleteEditUsersRow"><div userid="${data.user.id}" class="${BDFDB.disCNS.autocompleteselector + BDFDB.disCN.autocompleteselectable} autocompleteEditUsersSelector"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletecontent}" style="flex: 1 1 auto;"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${data.user.username}, ${BDFDB.LanguageUtils.LanguageStrings["STATUS_" + status.toUpperCase()]}" aria-hidden="false" style="width: 24px; height: 24px;"><svg width="30" height="24" viewBox="0 0 30 24" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="24" height="24" mask="url(#svg-mask-avatar-status-round-24)"><img src="${data.url || BDFDB.UserUtils.getAvatar(data.user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject><rect width="8" height="8" x="16" y="16" fill="${BDFDB.UserUtils.getStatusColor(status)}" mask="url(#svg-mask-status-${status})" class="${BDFDB.disCN.avatarpointerevents}"></rect></svg></div>${username}<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignbaseline + BDFDB.disCNS.nowrap + BDFDB.disCN.autocompletedescription}" style="flex: 0 1 auto;"><div class="${BDFDB.disCN.autocompletedescriptionusername}">${BDFDB.encodeToHTML(data.user.username)}</div><div class="${BDFDB.disCN.autocompletedescriptiondiscriminator}">#${data.user.discriminator}</div></div></div></div></div>`);
autocompleterow.querySelector(BDFDB.dotCN.autocompleteselectable).addEventListener("click", () => {this.swapWordWithMention(textarea);}); autocompleterow.querySelector(BDFDB.dotCN.autocompleteselectable).addEventListener("click", () => {this.swapWordWithMention(textarea);});
autocompletemenu.appendChild(autocompleterow); autocompletemenu.appendChild(autocompleterow);
} }
@ -1213,7 +1209,7 @@ class EditUsers {
} }
setLabelsByLanguage () { setLabelsByLanguage () {
switch (BDFDB.getDiscordLanguage().id) { switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian case "hr": //croatian
return { return {
context_localusersettings_text: "Lokalne korisničke postavke", context_localusersettings_text: "Lokalne korisničke postavke",

View File

@ -180,13 +180,11 @@ class EmojiStatistics {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -194,7 +192,7 @@ class EmojiStatistics {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".emoji-tooltip",".emojistatistics-button"); BDFDB.removeEles(".emoji-tooltip",".emojistatistics-button");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -222,18 +220,18 @@ class EmojiStatistics {
let emojiStatisticsButton = BDFDB.htmlToElement(`<div class="emojistatistics-button"></div>`); let emojiStatisticsButton = BDFDB.htmlToElement(`<div class="emojistatistics-button"></div>`);
emojipickerdiversityselector.parentElement.insertBefore(emojiStatisticsButton, emojipickerdiversityselector); emojipickerdiversityselector.parentElement.insertBefore(emojiStatisticsButton, emojipickerdiversityselector);
emojiStatisticsButton.addEventListener("click", () => { emojiStatisticsButton.addEventListener("click", () => {
let close = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.return.return.stateNode.close"); let close = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.return.return.stateNode.close");
if (close) close(); if (close) close();
this.showEmojiInformationModal(); this.showEmojiInformationModal();
}); });
emojiStatisticsButton.addEventListener("mouseenter", e => { emojiStatisticsButton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Emoji Statistics", emojiStatisticsButton, {type:"top",selector:"emojistatistics-tooltip"}); BDFDB.TooltipUtils.create(emojiStatisticsButton, "Emoji Statistics", {type:"top",selector:"emojistatistics-tooltip"});
}); });
} }
if (settings.enableEmojiHovering) { if (settings.enableEmojiHovering) {
BDFDB.addEventListener(this, wrapper, "mouseenter", BDFDB.dotCN.emojipickeremojiitem, e => { BDFDB.ListenerUtils.add(this, wrapper, "mouseenter", BDFDB.dotCN.emojipickeremojiitem, e => {
let data = this.emojiToServerList[e.target.style.getPropertyValue("background-image").replace('url("',"").replace('")',"")]; let data = this.emojiToServerList[e.target.style.getPropertyValue("background-image").replace('url("',"").replace('")',"")];
if (data) BDFDB.createTooltip(`${BDFDB.encodeToHTML(data.emoji)}\n${BDFDB.encodeToHTML(data.server)}`, e.target, {type:"right",selector:"emoji-tooltip",delay:BDFDB.getData("hoverDelay", this, "amounts")}); if (data) BDFDB.TooltipUtils.create(e.target, `${BDFDB.encodeToHTML(data.emoji)}\n${BDFDB.encodeToHTML(data.server)}`, {type:"right",selector:"emoji-tooltip",delay:BDFDB.getData("hoverDelay", this, "amounts")});
}); });
} }
} }
@ -242,7 +240,7 @@ class EmojiStatistics {
loadEmojiList () { loadEmojiList () {
this.emojiReplicaList = {}; this.emojiReplicaList = {};
this.emojiToServerList = {}; this.emojiToServerList = {};
for (let serverObj of BDFDB.readServerList()) { for (let serverObj of BDFDB.GuildUtils.getAll()) {
for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(serverObj.id)) { for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(serverObj.id)) {
this.emojiToServerList[emoji.url] = {emoji:emoji.allNamesString, server:serverObj.name}; this.emojiToServerList[emoji.url] = {emoji:emoji.allNamesString, server:serverObj.name};
if (emoji.managed) this.emojiReplicaList[emoji.name] = this.emojiReplicaList[emoji.name] != undefined; if (emoji.managed) this.emojiReplicaList[emoji.name] = this.emojiReplicaList[emoji.name] != undefined;
@ -261,7 +259,7 @@ class EmojiStatistics {
var titleEntry = BDFDB.htmlToElement(this.emojiserverTitlesMarkup); var titleEntry = BDFDB.htmlToElement(this.emojiserverTitlesMarkup);
titlescontainer.appendChild(titleEntry); titlescontainer.appendChild(titleEntry);
var entries = [], index = 0, totalGlobal = 0, totalLocal = 0, totalCopies = 0; var entries = [], index = 0, totalGlobal = 0, totalLocal = 0, totalCopies = 0;
BDFDB.addChildEventListener(titleEntry, "click", ".sorttitle-label ", e => { BDFDB.ListenerUtils.addToChildren(titleEntry, "click", ".sorttitle-label ", e => {
var oldTitle = e.currentTarget.innerText; var oldTitle = e.currentTarget.innerText;
this.resetTitles(titleEntry, totalGlobal, totalLocal, totalCopies); this.resetTitles(titleEntry, totalGlobal, totalLocal, totalCopies);
@ -272,13 +270,13 @@ class EmojiStatistics {
e.currentTarget.innerText = oldTitle.indexOf("▼") < 0 ? e.currentTarget.innerText + "▼" : e.currentTarget.innerText + "▲"; e.currentTarget.innerText = oldTitle.indexOf("▼") < 0 ? e.currentTarget.innerText + "▼" : e.currentTarget.innerText + "▲";
} }
BDFDB.sortArrayByKey(entries, sortKey); BDFDB.ArrayUtils.keySort(entries, sortKey);
if (reverse) entries.reverse(); if (reverse) entries.reverse();
this.updateAllEntries(entriescontainer, entries); this.updateAllEntries(entriescontainer, entries);
}); });
for (let info of BDFDB.readServerList()) { for (let info of BDFDB.GuildUtils.getAll()) {
let amountGlobal = 0, amountLocal = 0, amountCopies = 0; let amountGlobal = 0, amountLocal = 0, amountCopies = 0;
for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(info.id)) { for (let emoji of BDFDB.LibraryModules.GuildEmojiStore.getGuildEmoji(info.id)) {
if (emoji.managed) { if (emoji.managed) {
@ -290,7 +288,7 @@ class EmojiStatistics {
} }
} }
var emojiEntry = BDFDB.htmlToElement(this.emojiserverEntryMarkup); var emojiEntry = BDFDB.htmlToElement(this.emojiserverEntryMarkup);
emojiEntry.querySelector(".emojiserver-icon").appendChild(BDFDB.createServerDivCopy(info, {click: () => {BDFDB.removeEles(emojiInformationModal);}, menu: true, size: 48})); emojiEntry.querySelector(".emojiserver-icon").appendChild(BDFDB.GuildUtils.createCopy(info, {click: () => {BDFDB.removeEles(emojiInformationModal);}, menu: true, size: 48}));
emojiEntry.querySelector(".emojiname-label").innerText = info.name || ""; emojiEntry.querySelector(".emojiname-label").innerText = info.name || "";
emojiEntry.querySelector(".emojitotal-label").innerText = amountGlobal + amountLocal; emojiEntry.querySelector(".emojitotal-label").innerText = amountGlobal + amountLocal;
emojiEntry.querySelector(".emojiglobal-label").innerText = amountGlobal; emojiEntry.querySelector(".emojiglobal-label").innerText = amountGlobal;

View File

@ -43,13 +43,11 @@ class ForceImagePreviews {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -57,7 +55,7 @@ class ForceImagePreviews {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".FIP-embed"); BDFDB.removeEles(".FIP-embed");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -114,7 +112,7 @@ class ForceImagePreviews {
let width = 400; let width = 400;
let height = Math.round(width*(result.split('<meta itemprop="height" content="')[1].split('"')[0]/result.split('<meta itemprop="width" content="')[1].split('"')[0])); let height = Math.round(width*(result.split('<meta itemprop="height" content="')[1].split('"')[0]/result.split('<meta itemprop="width" content="')[1].split('"')[0]));
let embed = BDFDB.htmlToElement(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCN.embedwrapper}" style="max-width: 426px;"><div class="${BDFDB.disCN.embedpill}" style="background-color: rgb(255, 0, 0);"></div><div class="${BDFDB.disCN.embedinner}"><div class="${BDFDB.disCNS.embedcontent + BDFDB.disCN.flex}"><div class="${BDFDB.disCN.embedcontentinner}"><div class=""><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedproviderlink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedprovider + BDFDB.disCNS.titlesize12 + BDFDB.disCN.weightnormal}" href="https://www.youtube.com/" rel="noreferrer noopener" target="_blank">YouTube</a></div><div class="${BDFDB.disCNS.embedauthor + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter + BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedauthornamelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedauthorname + BDFDB.disCNS.weightmedium + BDFDB.disCN.titlesize14}" href="https://www.youtube.com${result.split('<div class="yt-user-info"><a href="')[1].split('"')[0]}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<div class="yt-user-info"><a href="')[1].split('>')[1].split('<')[0])}</a></div><div class="${BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedtitlelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedtitle + BDFDB.disCNS.titlesize14 + BDFDB.disCN.weightmedium}" href="${itemsrc}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<meta property="og:title" content="')[1].split('"')[0])}</a></div></div></div><div class="${BDFDB.disCNS.embedvideo + BDFDB.disCNS.embedimage + BDFDB.disCNS.embedmarginlarge + BDFDB.disCN.margintop8}" style="width: ${width}px; height: ${height}px;"><div class="${BDFDB.disCNS.imagewrapper + BDFDB.disCNS.imageclickable + BDFDB.disCN.embedvideoimagecomponent}" style="width: ${width}px; height: ${height}px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: ${width}px; height: ${height}px;"></div><div class="${BDFDB.disCN.embedvideoactions}"><div class="${BDFDB.disCN.embedcentercontent}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.anchorunderlineonhover + BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" href="${itemsrc}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div></div></div></div>`); let embed = BDFDB.htmlToElement(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCN.embedwrapper}" style="max-width: 426px;"><div class="${BDFDB.disCN.embedpill}" style="background-color: rgb(255, 0, 0);"></div><div class="${BDFDB.disCN.embedinner}"><div class="${BDFDB.disCNS.embedcontent + BDFDB.disCN.flex}"><div class="${BDFDB.disCN.embedcontentinner}"><div class=""><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedproviderlink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedprovider + BDFDB.disCNS.titlesize12 + BDFDB.disCN.weightnormal}" href="https://www.youtube.com/" rel="noreferrer noopener" target="_blank">YouTube</a></div><div class="${BDFDB.disCNS.embedauthor + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter + BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedauthornamelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedauthorname + BDFDB.disCNS.weightmedium + BDFDB.disCN.titlesize14}" href="https://www.youtube.com${result.split('<div class="yt-user-info"><a href="')[1].split('"')[0]}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<div class="yt-user-info"><a href="')[1].split('>')[1].split('<')[0])}</a></div><div class="${BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedtitlelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedtitle + BDFDB.disCNS.titlesize14 + BDFDB.disCN.weightmedium}" href="${itemsrc}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<meta property="og:title" content="')[1].split('"')[0])}</a></div></div></div><div class="${BDFDB.disCNS.embedvideo + BDFDB.disCNS.embedimage + BDFDB.disCNS.embedmarginlarge + BDFDB.disCN.margintop8}" style="width: ${width}px; height: ${height}px;"><div class="${BDFDB.disCNS.imagewrapper + BDFDB.disCNS.imageclickable + BDFDB.disCN.embedvideoimagecomponent}" style="width: ${width}px; height: ${height}px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: ${width}px; height: ${height}px;"></div><div class="${BDFDB.disCN.embedvideoactions}"><div class="${BDFDB.disCN.embedcentercontent}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.anchorunderlineonhover + BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" href="${itemsrc}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div></div></div></div>`);
BDFDB.addChildEventListener(embed, "click", BDFDB.dotCN.iconplay, () => { BDFDB.ListenerUtils.addToChildren(embed, "click", BDFDB.dotCN.iconplay, () => {
let videowrapper = embed.querySelector(BDFDB.dotCN.embedvideo); let videowrapper = embed.querySelector(BDFDB.dotCN.embedvideo);
BDFDB.removeEles(videowrapper.childNodes); BDFDB.removeEles(videowrapper.childNodes);
videowrapper.appendChild(BDFDB.htmlToElement(`<iframe src="${result.split('<link itemprop="embedURL" href="')[1].split('"')[0]}?start=0&amp;autoplay=1&amp;auto_play=1" width="${width}" height="${height}" frameborder="0" allowfullscreen=""></iframe>`)); videowrapper.appendChild(BDFDB.htmlToElement(`<iframe src="${result.split('<link itemprop="embedURL" href="')[1].split('"')[0]}?start=0&amp;autoplay=1&amp;auto_play=1" width="${width}" height="${height}" frameborder="0" allowfullscreen=""></iframe>`));

View File

@ -225,9 +225,9 @@ class FriendNotifications {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "keyup", ".input-notificationstring", e => {this.saveNotificationString(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", ".input-notificationstring", e => {this.saveNotificationString(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", ".btn-savesong", e => {this.saveNotificationSound(e.currentTarget.parentElement.querySelector(BDFDB.dotCN.input));}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-savesong", e => {this.saveNotificationSound(e.currentTarget.parentElement.querySelector(BDFDB.dotCN.input));});
BDFDB.addEventListener(this, settingspanel, "click", ".mute-checkbox", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".mute-checkbox", e => {
let config = e.currentTarget.getAttribute("config"); let config = e.currentTarget.getAttribute("config");
if (config) { if (config) {
let notificationsound = BDFDB.getData(config, this, "notificationsounds"); let notificationsound = BDFDB.getData(config, this, "notificationsounds");
@ -235,30 +235,30 @@ class FriendNotifications {
BDFDB.saveData(config, notificationsound, this, "notificationsounds"); BDFDB.saveData(config, notificationsound, this, "notificationsounds");
} }
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".settings-avatar", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-avatar", e => {
this.changeNotificationType(e.currentTarget, false, !BDFDB.containsClass(e.currentTarget, "disabled", "desktop", false)); this.changeNotificationType(e.currentTarget, false, !BDFDB.containsClass(e.currentTarget, "disabled", "desktop", false));
}); });
BDFDB.addEventListener(this, settingspanel, "contextmenu", ".settings-avatar", e => { BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".settings-avatar", e => {
if (!("Notification" in window)) return; if (!("Notification" in window)) return;
this.changeNotificationType(e.currentTarget, true, !(BDFDB.containsClass(e.currentTarget, "disabled") || !BDFDB.containsClass(e.currentTarget, "desktop"))); this.changeNotificationType(e.currentTarget, true, !(BDFDB.containsClass(e.currentTarget, "disabled") || !BDFDB.containsClass(e.currentTarget, "desktop")));
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".btn-batch", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-batch", e => {
this.changeAllNotificationTypes(settingspanel, e.currentTarget, true); this.changeAllNotificationTypes(settingspanel, e.currentTarget, true);
}); });
BDFDB.addEventListener(this, settingspanel, "contextmenu", ".btn-batch", e => { BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".btn-batch", e => {
this.changeAllNotificationTypes(settingspanel, e.currentTarget, false); this.changeAllNotificationTypes(settingspanel, e.currentTarget, false);
}); });
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.checkboxinput, e => {
if (BDFDB.containsClass(e.target, "remove-user")) return; if (BDFDB.containsClass(e.target, "remove-user")) return;
this.changeNotificationConfig(e.currentTarget); this.changeNotificationConfig(e.currentTarget);
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".BDFDB-tableheadercolumn", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".BDFDB-tableheadercolumn", e => {
this.changeAllNotificationConfigs(settingspanel, e.currentTarget, true); this.changeAllNotificationConfigs(settingspanel, e.currentTarget, true);
}); });
BDFDB.addEventListener(this, settingspanel, "contextmenu", ".BDFDB-tableheadercolumn", e => { BDFDB.ListenerUtils.add(this, settingspanel, "contextmenu", ".BDFDB-tableheadercolumn", e => {
this.changeAllNotificationConfigs(settingspanel, e.currentTarget, false); this.changeAllNotificationConfigs(settingspanel, e.currentTarget, false);
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".remove-user", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-user", e => {
let id = e.currentTarget.getAttribute("user-id"); let id = e.currentTarget.getAttribute("user-id");
let group = e.currentTarget.getAttribute("group"); let group = e.currentTarget.getAttribute("group");
if (id && group) { if (id && group) {
@ -267,12 +267,12 @@ class FriendNotifications {
this.SettingsUpdated = true; this.SettingsUpdated = true;
} }
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".btn-adduser", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-adduser", e => {
let idinput = settingspanel.querySelector("#input-userid"); let idinput = settingspanel.querySelector("#input-userid");
let id = idinput.value; let id = idinput.value;
idinput.value = ""; idinput.value = "";
if (friendIDs.includes(id)) BDFDB.showToast("User is already a friend of yours. Please use the 'Friends' area to configure him/her.", {type:"error"}); if (friendIDs.includes(id)) BDFDB.NotificationUtils.toast("User is already a friend of yours. Please use the 'Friends' area to configure him/her.", {type:"error"});
else if (BDFDB.loadData(id, this, "nonfriends")) BDFDB.showToast("User is already being observed as a 'Non-Friend'.", {type:"error"}); else if (BDFDB.loadData(id, this, "nonfriends")) BDFDB.NotificationUtils.toast("User is already being observed as a 'Non-Friend'.", {type:"error"});
else { else {
let user = BDFDB.LibraryModules.UserStore.getUser(id); let user = BDFDB.LibraryModules.UserStore.getUser(id);
if (user) { if (user) {
@ -283,11 +283,11 @@ class FriendNotifications {
BDFDB.initElements(hovercard); BDFDB.initElements(hovercard);
this.SettingsUpdated = true; this.SettingsUpdated = true;
} }
else if (/.+#[0-9]{4}/.test(id)) BDFDB.showToast("A UserID does not consist of the username and discriminator.", {type:"error"}); else if (/.+#[0-9]{4}/.test(id)) BDFDB.NotificationUtils.toast("A UserID does not consist of the username and discriminator.", {type:"error"});
else BDFDB.showToast("Please enter a valid UserID of a user that has been loaded in your client.", {type:"error"}); else BDFDB.NotificationUtils.toast("Please enter a valid UserID of a user that has been loaded in your client.", {type:"error"});
} }
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".btn-timelog", () => {this.showTimeLog();}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-timelog", () => {this.showTimeLog();});
return settingspanel; return settingspanel;
} }
@ -316,15 +316,13 @@ class FriendNotifications {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.startInterval(); this.startInterval();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -332,7 +330,7 @@ class FriendNotifications {
this.stopping = true; this.stopping = true;
clearInterval(this.checkInterval); clearInterval(this.checkInterval);
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -341,7 +339,7 @@ class FriendNotifications {
createHoverCard (user, data, group) { createHoverCard (user, data, group) {
let EUdata = BDFDB.loadData(user.id, "EditUsers", "users") || {}; let EUdata = BDFDB.loadData(user.id, "EditUsers", "users") || {};
var hovercardhtml = `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="settings-avatar${data.desktop ? " desktop" : ""}${data.disabled ? " disabled" : ""}" group="${group}" user-id="${user.id}" style="flex: 0 0 auto; background-image: url(${EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.getUserAvatar(user.id))});"></div><div class="BDFDB-textscrollwrapper" style="flex: 1 1 auto;"><div class="BDFDB-textscroll">${BDFDB.encodeToHTML(EUdata.name || user.username)}</div></div>`; var hovercardhtml = `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="settings-avatar${data.desktop ? " desktop" : ""}${data.disabled ? " disabled" : ""}" group="${group}" user-id="${user.id}" style="flex: 0 0 auto; background-image: url(${EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.UserUtils.getAvatar(user.id))});"></div><div class="BDFDB-textscrollwrapper" style="flex: 1 1 auto;"><div class="BDFDB-textscroll">${BDFDB.encodeToHTML(EUdata.name || user.username)}</div></div>`;
for (let config in this.defaults.notificationstrings) { for (let config in this.defaults.notificationstrings) {
hovercardhtml += `<div class="${BDFDB.disCNS.checkboxcontainer + BDFDB.disCN.marginreset} BDFDB-tablecheckbox" table-id="${group}" style="flex: 0 0 auto;"><label class="${BDFDB.disCN.checkboxwrapper}"><input user-id="${user.id}" group="${group}" config="${config}" type="checkbox" class="${BDFDB.disCN.checkboxinputdefault}"${data[config] ? " checked" : ""}><div class="${BDFDB.disCNS.checkbox + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex2 + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.checkboxround}"><svg name="Checkmark" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><polyline stroke="transparent" stroke-width="2" points="3.5 9.5 7 13 15 5"></polyline></g></svg></div></label></div>`; hovercardhtml += `<div class="${BDFDB.disCNS.checkboxcontainer + BDFDB.disCN.marginreset} BDFDB-tablecheckbox" table-id="${group}" style="flex: 0 0 auto;"><label class="${BDFDB.disCN.checkboxwrapper}"><input user-id="${user.id}" group="${group}" config="${config}" type="checkbox" class="${BDFDB.disCN.checkboxinputdefault}"${data[config] ? " checked" : ""}><div class="${BDFDB.disCNS.checkbox + BDFDB.disCNS.flexcenter + BDFDB.disCNS.flex2 + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCN.checkboxround}"><svg name="Checkmark" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><polyline stroke="transparent" stroke-width="2" points="3.5 9.5 7 13 15 5"></polyline></g></svg></div></label></div>`;
} }
@ -407,7 +405,7 @@ class FriendNotifications {
} }
createDefaultConfig () { createDefaultConfig () {
return Object.assign({desktop: false, disabled: BDFDB.getData("disableForNew", this, "settings")}, BDFDB.mapObject(this.defaults.notificationstrings, "init")); return Object.assign({desktop: false, disabled: BDFDB.getData("disableForNew", this, "settings")}, BDFDB.ObjectUtils.map(this.defaults.notificationstrings, "init"));
} }
saveNotificationString (input) { saveNotificationString (input) {
@ -422,7 +420,7 @@ class FriendNotifications {
let config = input.getAttribute("config"); let config = input.getAttribute("config");
if (config) { if (config) {
let successSavedAudio = (parsedurl, parseddata) => { let successSavedAudio = (parsedurl, parseddata) => {
if (parsedurl && parseddata) BDFDB.showToast(`Sound was saved successfully.`, {type:"success"}); if (parsedurl && parseddata) BDFDB.NotificationUtils.toast(`Sound was saved successfully.`, {type:"success"});
let notificationsound = BDFDB.getData(config, this, "notificationsounds"); let notificationsound = BDFDB.getData(config, this, "notificationsounds");
notificationsound.url = parsedurl; notificationsound.url = parsedurl;
notificationsound.song = parseddata; notificationsound.song = parseddata;
@ -432,7 +430,7 @@ class FriendNotifications {
let url = input.value; let url = input.value;
if (url.length == 0) { if (url.length == 0) {
BDFDB.showToast(`Sound file was removed.`, {type:"warn"}); BDFDB.NotificationUtils.toast(`Sound file was removed.`, {type:"warn"});
successSavedAudio(url, url); successSavedAudio(url, url);
} }
else if (url.indexOf("http") == 0) { else if (url.indexOf("http") == 0) {
@ -444,12 +442,12 @@ class FriendNotifications {
return; return;
} }
} }
BDFDB.showToast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"}); BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
}); });
} }
else { else {
BDFDB.LibraryRequires.fs.readFile(url, (error, response) => { BDFDB.LibraryRequires.fs.readFile(url, (error, response) => {
if (error) BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"}); if (error) BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
else successSavedAudio(url, `data:audio/mpeg;base64,${response.toString("base64")}`); else successSavedAudio(url, `data:audio/mpeg;base64,${response.toString("base64")}`);
}); });
} }
@ -464,7 +462,7 @@ class FriendNotifications {
} }
getStatusWithMobileAndActivity (id, config) { getStatusWithMobileAndActivity (id, config) {
let statusname = BDFDB.getUserStatus(id); let statusname = BDFDB.UserUtils.getStatus(id);
let status = {statusname, isactivity:false}; let status = {statusname, isactivity:false};
let activity = BDFDB.LibraryModules.StatusMetaUtils.getPrimaryActivity(id); let activity = BDFDB.LibraryModules.StatusMetaUtils.getPrimaryActivity(id);
if (activity && this.activityTypes[activity.type]) { if (activity && this.activityTypes[activity.type]) {
@ -498,20 +496,20 @@ class FriendNotifications {
let string = notificationstrings[status.statusname] || "$user changed status to $status"; let string = notificationstrings[status.statusname] || "$user changed status to $status";
let toaststring = BDFDB.encodeToHTML(string).replace(/'{0,1}\$user'{0,1}/g, `<strong>${BDFDB.encodeToHTML(EUdata.name || user.username)}</strong>`).replace(/'{0,1}\$status'{0,1}/g, `<strong>${libstring}</strong>`); let toaststring = BDFDB.encodeToHTML(string).replace(/'{0,1}\$user'{0,1}/g, `<strong>${BDFDB.encodeToHTML(EUdata.name || user.username)}</strong>`).replace(/'{0,1}\$status'{0,1}/g, `<strong>${libstring}</strong>`);
if (status.isactivity) toaststring = toaststring.replace(/'{0,1}\$song'{0,1}|'{0,1}\$game'{0,1}/g, `<strong>${status.name || status.details}</strong>`).replace(/'{0,1}\$artist'{0,1}/g, `<strong>${status.state}</strong>`); if (status.isactivity) toaststring = toaststring.replace(/'{0,1}\$song'{0,1}|'{0,1}\$game'{0,1}/g, `<strong>${status.name || status.details}</strong>`).replace(/'{0,1}\$artist'{0,1}/g, `<strong>${status.state}</strong>`);
let avatar = EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.getUserAvatar(user.id)); let avatar = EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.UserUtils.getAvatar(user.id));
this.timeLog.push({string:toaststring, avatar, time: new Date()}); this.timeLog.push({string:toaststring, avatar, time: new Date()});
if (!(settings.muteOnDND && BDFDB.getUserStatus() == "dnd")) { if (!(settings.muteOnDND && BDFDB.UserUtils.getStatus() == "dnd")) {
let openChannel = () => { let openChannel = () => {
if (settings.openOnClick) { if (settings.openOnClick) {
let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id) let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id)
if (DMid) BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid); if (DMid) BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid);
else BDFDB.LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.myData.id, user.id); else BDFDB.LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.UserUtils.me.id, user.id);
BDFDB.LibraryRequires.electron.remote.getCurrentWindow().maximize(); BDFDB.LibraryRequires.electron.remote.getCurrentWindow().maximize();
} }
}; };
if (!users[id].desktop) { if (!users[id].desktop) {
if (!document.querySelector(`.friendnotifications-${id}-toast`)) { if (!document.querySelector(`.friendnotifications-${id}-toast`)) {
let toast = BDFDB.showToast(`<div class="toast-inner"><div class="toast-avatar" style="background-image:url(${avatar});"></div><div>${toaststring}</div></div>`, {html:true, timeout:toasttime, color:BDFDB.getUserStatusColor(status.statusname), icon:false, selector:`friendnotifications-${status.statusname}-toast friendnotifications-${id}-toast`}); let toast = BDFDB.NotificationUtils.toast(`<div class="toast-inner"><div class="toast-avatar" style="background-image:url(${avatar});"></div><div>${toaststring}</div></div>`, {html:true, timeout:toasttime, color:BDFDB.UserUtils.getStatusColor(status.statusname), icon:false, selector:`friendnotifications-${status.statusname}-toast friendnotifications-${id}-toast`});
toast.addEventListener("click", openChannel); toast.addEventListener("click", openChannel);
let notificationsound = notificationsounds["toast" + status.statusname] || {}; let notificationsound = notificationsounds["toast" + status.statusname] || {};
if (!notificationsound.mute && notificationsound.song) { if (!notificationsound.mute && notificationsound.song) {
@ -525,7 +523,7 @@ class FriendNotifications {
let desktopstring = string.replace(/\$user/g, EUdata.name || user.username).replace(/\$status/g, libstring); let desktopstring = string.replace(/\$user/g, EUdata.name || user.username).replace(/\$status/g, libstring);
if (status.isactivity) desktopstring = desktopstring.replace(/\$song|\$game/g, status.name || status.details).replace(/\$artist/g, status.state); if (status.isactivity) desktopstring = desktopstring.replace(/\$song|\$game/g, status.name || status.details).replace(/\$artist/g, status.state);
let notificationsound = notificationsounds["desktop" + status.statusname] || {}; let notificationsound = notificationsounds["desktop" + status.statusname] || {};
BDFDB.showDesktopNotification(desktopstring, {icon:avatar, timeout:desktoptime, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song}); BDFDB.NotificationUtils.desktop(desktopstring, {icon:avatar, timeout:desktoptime, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song});
} }
} }
} }

View File

@ -83,18 +83,16 @@ class GoogleSearchReplace {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -117,7 +115,7 @@ class GoogleSearchReplace {
appendItem (menu, returnvalue, text) { appendItem (menu, returnvalue, text) {
let engines = BDFDB.getAllData(this, "engines"); let engines = BDFDB.getAllData(this, "engines");
let items = []; let items = [];
for (let key in engines) if (engines[key]) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { for (let key in engines) if (engines[key]) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.defaults.engines[key].name, label: this.defaults.engines[key].name,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
action: e => { action: e => {
@ -128,13 +126,13 @@ class GoogleSearchReplace {
else window.open(this.defaults.engines[key].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank"); else window.open(this.defaults.engines[key].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
} }
})); }));
if (!items.length) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_disabled_text, label: this.labels.submenu_disabled_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
disabled: true disabled: true
})); }));
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "SearchWithGoogle"); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "SearchWithGoogle");
const item = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { const item = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_googlesearchreplace_text, label: this.labels.context_googlesearchreplace_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`,
render: items render: items

View File

@ -154,9 +154,9 @@ class GoogleTranslateOption {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type"); let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type");
let menulanguages = this.defaults.choices[type].direction == "Output" ? BDFDB.filterObject(this.languages, lang => {return lang.id != "auto";}) : this.languages; let menulanguages = this.defaults.choices[type].direction == "Output" ? BDFDB.ObjectUtils.filter(this.languages, lang => {return lang.id != "auto";}) : this.languages;
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), menulanguages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), menulanguages);
}); });
@ -187,15 +187,13 @@ class GoogleTranslateOption {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.setLanguages(); this.setLanguages();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -208,7 +206,7 @@ class GoogleTranslateOption {
BDFDB.removeEles(".translate-button", ".popout-googletranslate"); BDFDB.removeEles(".translate-button", ".popout-googletranslate");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -221,9 +219,9 @@ class GoogleTranslateOption {
if (!messagediv || pos == -1) return; if (!messagediv || pos == -1) return;
let translated = BDFDB.containsClass(messagediv, "GTO-translated-message"); let translated = BDFDB.containsClass(messagediv, "GTO-translated-message");
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "MessagePinItem"); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "MessagePinItem");
const translateUntranslateItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const translateUntranslateItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: translated ? this.labels.context_messageuntranslateoption_text : this.labels.context_messagetranslateoption_text, label: translated ? this.labels.context_messageuntranslateoption_text : this.labels.context_messagetranslateoption_text,
hint: BDFDB.isPluginEnabled("MessageUtilities") ? BDFDB.getPlugin("MessageUtilities").getActiveShortcutString("__Translate_Message") : null, hint: BDFDB.BdUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BdUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Translate_Message") : null,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${translated ? "untranslate" : "translate"}-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${translated ? "untranslate" : "translate"}-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(menu); BDFDB.closeContextMenu(menu);
@ -234,17 +232,17 @@ class GoogleTranslateOption {
else children.push(translateUntranslateItem); else children.push(translateUntranslateItem);
let text = document.getSelection().toString(); let text = document.getSelection().toString();
if (text) { if (text) {
let GSRstring = BDFDB.getReactValue(BDFDB.getPlugin("GoogleSearchReplace", true), "labels.context_googlesearchreplace_text"); let GSRstring = BDFDB.ReactUtils.getValue(BDFDB.BdUtils.getPlugin("GoogleSearchReplace", true), "labels.context_googlesearchreplace_text");
let [children2, index2] = BDFDB.getContextMenuGroupAndIndex(returnvalue, GSRstring ? ["SearchWithGoogle", GSRstring] : "SearchWithGoogle"); let [children2, index2] = BDFDB.getContextMenuGroupAndIndex(returnvalue, GSRstring ? ["SearchWithGoogle", GSRstring] : "SearchWithGoogle");
var foundtranslation, foundinput, foundoutput; var foundtranslation, foundinput, foundoutput;
const searchTranslationItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const searchTranslationItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_googletranslateoption_text, label: this.labels.context_googletranslateoption_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-searchtranslation-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-searchtranslation-contextMenuItem`,
action: e => { action: e => {
var item = BDFDB.getParentEle(BDFDB.dotCN.contextmenuitem, e.target); var item = BDFDB.getParentEle(BDFDB.dotCN.contextmenuitem, e.target);
if (item) { if (item) {
var createTooltip = () => { var createTooltip = () => {
BDFDB.createTooltip(`From ${foundinput.name}:\n${text}\n\nTo ${foundoutput.name}:\n${foundtranslation}`, item, {type:"right", selector:"googletranslate-tooltip"}); BDFDB.TooltipUtils.create(item, `From ${foundinput.name}:\n${text}\n\nTo ${foundoutput.name}:\n${foundtranslation}`, {type:"right", selector:"googletranslate-tooltip"});
}; };
if (foundtranslation && foundinput && foundoutput) { if (foundtranslation && foundinput && foundoutput) {
if (document.querySelector(".googletranslate-tooltip")) { if (document.querySelector(".googletranslate-tooltip")) {
@ -274,7 +272,7 @@ class GoogleTranslateOption {
if (!messagediv || pos == -1) return; if (!messagediv || pos == -1) return;
let translated = BDFDB.containsClass(messagediv, "GTO-translated-message"); let translated = BDFDB.containsClass(messagediv, "GTO-translated-message");
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, [BDFDB.LanguageUtils.LanguageStrings.PIN, BDFDB.LanguageUtils.LanguageStrings.UNPIN]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, [BDFDB.LanguageUtils.LanguageStrings.PIN, BDFDB.LanguageUtils.LanguageStrings.UNPIN]);
const translateUntranslateItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const translateUntranslateItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels[translated ? "popout_untranslateoption_text" : "popout_translateoption_text"], label: this.labels[translated ? "popout_untranslateoption_text" : "popout_translateoption_text"],
className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-${translated ? "untranslate" : "translate"}-popoutMenuItem`, className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-${translated ? "untranslate" : "translate"}-popoutMenuItem`,
action: e => { action: e => {
@ -289,14 +287,14 @@ class GoogleTranslateOption {
setLanguages () { setLanguages () {
this.languages = Object.assign({}, this.languages = Object.assign({},
{"auto": {name:"Auto", id:"auto", integrated:false, dic:false}}, {"auto": {name:"Auto", id:"auto", integrated:false, dic:false}},
BDFDB.languages, BDFDB.LanguageUtils.languages,
{"binary": {name:"Binary", id:"binary", integrated:false, dic:false}}, {"binary": {name:"Binary", id:"binary", integrated:false, dic:false}},
{"braille": {name:"Braille 6-dot", id:"braille", integrated:false, dic:false}}, {"braille": {name:"Braille 6-dot", id:"braille", integrated:false, dic:false}},
{"morse": {name:"Morse", id:"morse", integrated:false, dic:false}} {"morse": {name:"Morse", id:"morse", integrated:false, dic:false}}
); );
let favorites = BDFDB.loadAllData(this, "favorites") let favorites = BDFDB.loadAllData(this, "favorites")
for (let id in this.languages) this.languages[id].fav = favorites[id] != undefined ? 0 : 1; for (let id in this.languages) this.languages[id].fav = favorites[id] != undefined ? 0 : 1;
this.languages = BDFDB.sortObject(this.languages, "fav"); this.languages = BDFDB.ObjectUtils.sort(this.languages, "fav");
} }
getLanguageChoice (direction, place) { getLanguageChoice (direction, place) {
@ -313,7 +311,7 @@ class GoogleTranslateOption {
delete this.SettingsUpdated; delete this.SettingsUpdated;
this.setLanguages(); this.setLanguages();
BDFDB.removeEles(".translate-button"); BDFDB.removeEles(".translate-button");
BDFDB.WebModules.forceAllUpdates(this, "ChannelTextArea"); BDFDB.ModuleUtils.forceAllUpdates(this, "ChannelTextArea");
} }
} }
@ -334,7 +332,7 @@ class GoogleTranslateOption {
buttoncontainer.insertBefore(translateButton, buttoncontainer.firstElementChild); buttoncontainer.insertBefore(translateButton, buttoncontainer.firstElementChild);
BDFDB.addClass(translateButton, instance.props.type); BDFDB.addClass(translateButton, instance.props.type);
BDFDB.toggleClass(translateButton, "translating-active", this.translating); BDFDB.toggleClass(translateButton, "translating-active", this.translating);
BDFDB.addEventListener(this, textarea, "input", () => { BDFDB.ListenerUtils.add(this, textarea, "input", () => {
if (this.doTranslate) { if (this.doTranslate) {
this.doTranslate = false; this.doTranslate = false;
if (document.activeElement == textarea) { if (document.activeElement == textarea) {
@ -352,7 +350,7 @@ class GoogleTranslateOption {
} }
} }
}); });
BDFDB.addEventListener(this, textarea, "keydown", e => { BDFDB.ListenerUtils.add(this, textarea, "keydown", e => {
if (textarea.value && this.translating && !e.shiftKey && e.which == 13 && !wrapper.querySelector(BDFDB.dotCN.autocomplete)) { if (textarea.value && this.translating && !e.shiftKey && e.which == 13 && !wrapper.querySelector(BDFDB.dotCN.autocomplete)) {
this.doTranslate = true; this.doTranslate = true;
textarea.dispatchEvent(new Event("input")); textarea.dispatchEvent(new Event("input"));
@ -363,7 +361,7 @@ class GoogleTranslateOption {
} }
processMessage (instance, wrapper, returnvalue) { processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.getReactValue(instance, "props.message.author.id") != 1) { if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer); let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) { if (buttonwrap) {
let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`); let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
@ -411,8 +409,8 @@ class GoogleTranslateOption {
if (embeddescriptions.length) for (let embeddescription of embeddescriptions) { if (embeddescriptions.length) for (let embeddescription of embeddescriptions) {
embeddescription.insertBefore(BDFDB.htmlToElement(`<label class="GTO-translation">${translations.shift().trim()}<time class="${BDFDB.disCN.messageedited} GTO-translated">(${this.labels.translated_watermark_text})</time></label>`), embeddescription.firstChild); embeddescription.insertBefore(BDFDB.htmlToElement(`<label class="GTO-translation">${translations.shift().trim()}<time class="${BDFDB.disCN.messageedited} GTO-translated">(${this.labels.translated_watermark_text})</time></label>`), embeddescription.firstChild);
} }
BDFDB.addChildEventListener(messagediv, "mouseenter", BDFDB.dotCN.messageedited + ".GTO-translated", e => { BDFDB.ListenerUtils.addToChildren(messagediv, "mouseenter", BDFDB.dotCN.messageedited + ".GTO-translated", e => {
BDFDB.createTooltip(`<div>From: ${input.name}</div><div>To: ${output.name}</div>`, e.currentTarget, {html:true, type:"top", selector:"translation-tooltip"}); BDFDB.TooltipUtils.create(e.currentTarget, `<div>From: ${input.name}</div><div>To: ${output.name}</div>`, {html:true, type:"top", selector:"translation-tooltip"});
}); });
} }
}); });
@ -436,7 +434,7 @@ class GoogleTranslateOption {
callback(translation, input, output); callback(translation, input, output);
}; };
var translationError = (exceptions, input, output, toast, test) => { var translationError = (exceptions, input, output, toast, test) => {
BDFDB.showToast("Could not translate message, you most likely got rate limited by Google for today due to too frequent usage of their Translate-API.", {type:"error",timeout:15000}); BDFDB.NotificationUtils.toast("Could not translate message, you most likely got rate limited by Google for today due to too frequent usage of their Translate-API.", {type:"error",timeout:15000});
finishTranslation(null, exceptions, input, output, toast); finishTranslation(null, exceptions, input, output, toast);
}; };
var [newtext, exceptions, translate] = this.removeExceptions(text.trim(), type); var [newtext, exceptions, translate] = this.removeExceptions(text.trim(), type);
@ -444,7 +442,7 @@ class GoogleTranslateOption {
var output = Object.assign({}, this.languages[this.getLanguageChoice("output", type)]); var output = Object.assign({}, this.languages[this.getLanguageChoice("output", type)]);
var translation = ""; var translation = "";
if (translate) { if (translate) {
toast = BDFDB.showToast("Translating. Please wait", {timeout:0}); toast = BDFDB.NotificationUtils.toast("Translating. Please wait", {timeout:0});
toast.interval = setInterval(() => { toast.interval = setInterval(() => {
toast.textContent = toast.textContent.indexOf(".....") > -1 ? "Translating. Please wait" : toast.textContent + "."; toast.textContent = toast.textContent.indexOf(".....") > -1 ? "Translating. Please wait" : toast.textContent + ".";
},500); },500);
@ -544,7 +542,7 @@ class GoogleTranslateOption {
} }
} }
} }
else BDFDB.showToast("Invalid binary format. Only use 0s and 1s.", {type:"error"}); else BDFDB.NotificationUtils.toast("Invalid binary format. Only use 0s and 1s.", {type:"error"});
return string; return string;
} }
@ -609,11 +607,11 @@ class GoogleTranslateOption {
translatepopout.style.setProperty("left", buttonrects.left + buttonrects.width + "px"); translatepopout.style.setProperty("left", buttonrects.left + buttonrects.width + "px");
translatepopout.style.setProperty("top", buttonrects.top - buttonrects.height/2 + "px") translatepopout.style.setProperty("top", buttonrects.top - buttonrects.height/2 + "px")
BDFDB.addChildEventListener(translatepopout, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.addToChildren(translatepopout, "click", BDFDB.dotCN.selectcontrol, e => {
let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type"); let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type");
let menulanguages = this.defaults.choices[type].direction == "Output" ? BDFDB.filterObject(this.languages, lang => {return lang.id != "auto";}) : this.languages; let menulanguages = this.defaults.choices[type].direction == "Output" ? BDFDB.ObjectUtils.filter(this.languages, lang => {return lang.id != "auto";}) : this.languages;
let menu = BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), menulanguages, true); let menu = BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), menulanguages, true);
BDFDB.addChildEventListener(menu, "click", BDFDB.dotCN.giffavoritebutton, e => { BDFDB.ListenerUtils.addToChildren(menu, "click", BDFDB.dotCN.giffavoritebutton, e => {
let choice = e.currentTarget.parentElement.getAttribute("value"); let choice = e.currentTarget.parentElement.getAttribute("value");
if (choice) { if (choice) {
let favorize = !BDFDB.loadData(choice, this, "favorites") let favorize = !BDFDB.loadData(choice, this, "favorites")
@ -623,7 +621,7 @@ class GoogleTranslateOption {
} }
}); });
}); });
BDFDB.addChildEventListener(translatepopout, "click", ".reverse-button", e => { BDFDB.ListenerUtils.addToChildren(translatepopout, "click", ".reverse-button", e => {
let place = e.currentTarget.getAttribute("type").replace("output",""); let place = e.currentTarget.getAttribute("type").replace("output","");
let input = this.getLanguageChoice("output", place); let input = this.getLanguageChoice("output", place);
let output = this.getLanguageChoice("input", place); let output = this.getLanguageChoice("input", place);
@ -675,12 +673,12 @@ class GoogleTranslateOption {
} }
getGoogleTranslateApiURL (input, output, text) { getGoogleTranslateApiURL (input, output, text) {
input = BDFDB.languages[input] ? input : "auto"; input = BDFDB.LanguageUtils.languages[input] ? input : "auto";
return "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + input + "&tl=" + output + "&dt=t&ie=UTF-8&oe=UTF-8&q=" + encodeURIComponent(text); return "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + input + "&tl=" + output + "&dt=t&ie=UTF-8&oe=UTF-8&q=" + encodeURIComponent(text);
} }
getGoogleTranslatePageURL (input, output, text) { getGoogleTranslatePageURL (input, output, text) {
input = BDFDB.languages[input] ? input : "auto"; input = BDFDB.LanguageUtils.languages[input] ? input : "auto";
return "https://translate.google.com/#" + input + "/" + output + "/" + encodeURIComponent(text); return "https://translate.google.com/#" + input + "/" + output + "/" + encodeURIComponent(text);
} }

View File

@ -63,13 +63,11 @@ class ImageGallery {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -78,14 +76,14 @@ class ImageGallery {
this.closemodal = true; this.closemodal = true;
BDFDB.WebModules.forceAllUpdates(this, "ImageModal"); BDFDB.ModuleUtils.forceAllUpdates(this, "ImageModal");
delete this.closemodal; delete this.closemodal;
document.removeEventListener("keydown", document.keydownImageGalleryListener); document.removeEventListener("keydown", document.keydownImageGalleryListener);
document.removeEventListener("keyup", document.keyupImageGalleryListener); document.removeEventListener("keyup", document.keyupImageGalleryListener);
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }

View File

@ -66,13 +66,11 @@ class ImageZoom {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -87,7 +85,7 @@ class ImageZoom {
BDFDB.removeEles(".imagezoom-contextmenu", ".imagezoom-separator", ".imagezoom-settings", ".imagezoom-lense", ".imagezoom-backdrop"); BDFDB.removeEles(".imagezoom-contextmenu", ".imagezoom-separator", ".imagezoom-settings", ".imagezoom-lense", ".imagezoom-backdrop");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -112,7 +110,7 @@ class ImageZoom {
let openContext = e => { let openContext = e => {
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
let items = []; let items = [];
for (let type in settings) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSliderItem, { for (let type in settings) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSliderItem, {
label: this.defaults.settings[type].name + ": " + settings[type] + this.defaults.settings[type].unit, label: this.defaults.settings[type].name + ": " + settings[type] + this.defaults.settings[type].unit,
className: `BDFDB-contextMenuSliderItem ${this.name}-contextMenuSliderItem ${this.name}-${type}-contextMenuSliderItem`, className: `BDFDB-contextMenuSliderItem ${this.name}-contextMenuSliderItem ${this.name}-${type}-contextMenuSliderItem`,
type, type,
@ -121,7 +119,7 @@ class ImageZoom {
BDFDB.saveData(type, Math.round(BDFDB.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value)), this, "settings"); BDFDB.saveData(type, Math.round(BDFDB.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value)), this, "settings");
}, },
onValueRender: value => { onValueRender: value => {
setImmediate(() => {for (let slider of document.querySelectorAll(BDFDB.dotCN.contextmenuitemslider)) if (BDFDB.getReactValue(slider, "return.memoizedProps.type") == type) { setImmediate(() => {for (let slider of document.querySelectorAll(BDFDB.dotCN.contextmenuitemslider)) if (BDFDB.ReactUtils.getValue(slider, "return.memoizedProps.type") == type) {
value = Math.round(BDFDB.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value)); value = Math.round(BDFDB.mapRange([0, 100], [this.defaults.settings[type].min, this.defaults.settings[type].max], value));
let label = slider.querySelector(BDFDB.dotCN.contextmenulabel); let label = slider.querySelector(BDFDB.dotCN.contextmenulabel);
if (label) label.innerText = this.defaults.settings[type].name + ": " + value + this.defaults.settings[type].unit; if (label) label.innerText = this.defaults.settings[type].name + ": " + value + this.defaults.settings[type].unit;
@ -131,7 +129,7 @@ class ImageZoom {
}}); }});
} }
})); }));
const itemGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: items children: items
}); });
@ -140,7 +138,7 @@ class ImageZoom {
settingslink.addEventListener("click", openContext); settingslink.addEventListener("click", openContext);
settingslink.addEventListener("contextmenu", openContext); settingslink.addEventListener("contextmenu", openContext);
img.ImageZoomMouseDownListener = e => { img.ImageZoomMouseDownListener = e => {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
BDFDB.appendLocalStyle("ImageZoomCrossHair", "* {cursor: crosshair !important;}"); BDFDB.appendLocalStyle("ImageZoomCrossHair", "* {cursor: crosshair !important;}");
let imgrects = BDFDB.getRects(img); let imgrects = BDFDB.getRects(img);

View File

@ -91,10 +91,10 @@ class JoinedAtDate {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
}); });
return settingspanel; return settingspanel;
@ -124,15 +124,13 @@ class JoinedAtDate {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}},BDFDB.languages); this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}},BDFDB.LanguageUtils.languages);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -141,7 +139,7 @@ class JoinedAtDate {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".joinedAtDate"); BDFDB.removeEles(".joinedAtDate");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -202,7 +200,7 @@ class JoinedAtDate {
let addTimestamp = (timestamp) => { let addTimestamp = (timestamp) => {
if (document.contains(container)) { if (document.contains(container)) {
BDFDB.removeEles(container.querySelectorAll(".joinedAtDate")); BDFDB.removeEles(container.querySelectorAll(".joinedAtDate"));
if (BDFDB.isObject(container.JoinedAtDateObserver)) container.JoinedAtDateObserver.disconnect(); if (BDFDB.ObjectUtils.is(container.JoinedAtDateObserver)) container.JoinedAtDateObserver.disconnect();
let choice = BDFDB.getData("joinedAtDateLang", this, "choices"); let choice = BDFDB.getData("joinedAtDateLang", this, "choices");
let nametag = container.querySelector(BDFDB.dotCN.nametag); let nametag = container.querySelector(BDFDB.dotCN.nametag);
container.insertBefore(BDFDB.htmlToElement(`<div class="joinedAtDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 7 !important;"><div class="BDFDB-textscroll">${this.labels.joinedat_text.replace("{{time}}", this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null); container.insertBefore(BDFDB.htmlToElement(`<div class="joinedAtDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 7 !important;"><div class="BDFDB-textscroll">${this.labels.joinedat_text.replace("{{time}}", this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null);

View File

@ -92,10 +92,10 @@ class LastMessageDate {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".settings-switch", () => {setImmediate(() => {this.updateSettingsPanel(settingspanel);})});
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".toggle-info", e => {this.toggleInfo(e.currentTarget);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
}); });
return settingspanel; return settingspanel;
@ -125,21 +125,19 @@ class LastMessageDate {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.languages); this.languages = Object.assign({"own":{name:"Own",id:"own",integrated:false,dic:false}}, BDFDB.LanguageUtils.languages);
BDFDB.WebModules.patch(BDFDB.LibraryModules.MessageUtils, "receiveMessage", this, {after: e => { BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.MessageUtils, "receiveMessage", {after: e => {
let message = e.methodArguments[1]; let message = e.methodArguments[1];
let guildid = message.guild_id || message.channel_id; let guildid = message.guild_id || message.channel_id;
if (guildid && this.loadedusers[guildid] && this.loadedusers[guildid][message.author.id]) this.loadedusers[guildid][message.author.id] = new Date(message.timestamp); if (guildid && this.loadedusers[guildid] && this.loadedusers[guildid][message.author.id]) this.loadedusers[guildid][message.author.id] = new Date(message.timestamp);
}}); }});
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -148,7 +146,7 @@ class LastMessageDate {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".lastMessageDate"); BDFDB.removeEles(".lastMessageDate");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -211,7 +209,7 @@ class LastMessageDate {
let addTimestamp = (timestamp) => { let addTimestamp = (timestamp) => {
if (document.contains(container)) { if (document.contains(container)) {
BDFDB.removeEles(container.querySelectorAll(".lastMessageDate")); BDFDB.removeEles(container.querySelectorAll(".lastMessageDate"));
if (BDFDB.isObject(container.LastMessageDateObserver)) container.LastMessageDateObserver.disconnect(); if (BDFDB.ObjectUtils.is(container.LastMessageDateObserver)) container.LastMessageDateObserver.disconnect();
let choice = BDFDB.getData("lastMessageDateLang", this, "choices"); let choice = BDFDB.getData("lastMessageDateLang", this, "choices");
let nametag = container.querySelector(BDFDB.dotCN.nametag); let nametag = container.querySelector(BDFDB.dotCN.nametag);
container.insertBefore(BDFDB.htmlToElement(`<div class="lastMessageDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 6 !important;"><div class="BDFDB-textscroll">${this.labels.lastmessage_text.replace("{{time}}", timestamp == "never" ? "---" : this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null); container.insertBefore(BDFDB.htmlToElement(`<div class="lastMessageDate BDFDB-textscrollwrapper ${BDFDB.disCN.textrow}" style="max-width: ${BDFDB.getRects(BDFDB.getParentEle(popout ? BDFDB.dotCN.userpopoutheader : BDFDB.dotCN.userprofileheaderinfo, container)).width - 20}px !important; order: 6 !important;"><div class="BDFDB-textscroll">${this.labels.lastmessage_text.replace("{{time}}", timestamp == "never" ? "---" : this.getTimestamp(this.languages[choice].id, timestamp))}</div></div>`), nametag ? nametag.nextSibling : null);

View File

@ -64,7 +64,7 @@ class MessageUtilities {
if (this.defaults.settings[key].description) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`; if (this.defaults.settings[key].description) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
} }
for (let action in bindings) { for (let action in bindings) {
if (!this.defaults.bindings[action].plugin || BDFDB.isPluginEnabled(this.defaults.bindings[action].plugin)) { if (!this.defaults.bindings[action].plugin || BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings[action].plugin)) {
settingshtml += `<div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`; settingshtml += `<div class="${BDFDB.disCNS.divider + BDFDB.disCN.marginbottom4}"></div>`;
settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3>${toasts[action] != undefined ? `<h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Toast:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="toasts ${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${toasts[action] ? " checked" : ""}></div>` : ''}<h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Enabled:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`; settingshtml += `<div class="${action}-key-settings"><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.bindings[action].name}:</h3>${toasts[action] != undefined ? `<h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Toast:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="toasts ${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${toasts[action] ? " checked" : ""}></div>` : ''}<h5 class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin}" style="flex: 0 0 auto;">Enabled:</h5><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${action}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[action] ? " checked" : ""}></div></div><div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;">`;
settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 20%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">Click:</h5>${BDFDB.createSelectMenu(this.createSelectChoice(bindings[action].click), bindings[action].click, action + " click")}</div>`; settingshtml += `<div class="${BDFDB.disCN.flexchild}" style="flex: 1 1 20%;"><h5 class="${BDFDB.disCNS.h5 + BDFDB.disCNS.title + BDFDB.disCNS.titlesize12 + BDFDB.disCNS.height16 + BDFDB.disCNS.weightsemibold + BDFDB.disCNS.h5defaultmargin + BDFDB.disCN.marginbottom4}">Click:</h5>${BDFDB.createSelectMenu(this.createSelectChoice(bindings[action].click), bindings[action].click, action + " click")}</div>`;
@ -81,10 +81,10 @@ class MessageUtilities {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.hotkeycontainer, e => {this.startRecording(settingspanel, e);}) BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.hotkeycontainer, e => {this.startRecording(settingspanel, e);})
BDFDB.addEventListener(this, settingspanel, "click", ".reset-recorder", e => {this.resetRecorder(settingspanel, e);}) BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-recorder", e => {this.resetRecorder(settingspanel, e);})
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => {this.resetAll(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {this.resetAll(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.clickMap); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.clickMap);
}); });
@ -115,28 +115,26 @@ class MessageUtilities {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.addEventListener(this, document, "click", BDFDB.dotCN.messagegroup + "> [aria-disabled]," + BDFDB.dotCN.messagegroup + "> * > [aria-disabled]," + BDFDB.dotCN.messagesystem, e => { BDFDB.ListenerUtils.add(this, document, "click", BDFDB.dotCN.messagegroup + "> [aria-disabled]," + BDFDB.dotCN.messagegroup + "> * > [aria-disabled]," + BDFDB.dotCN.messagesystem, e => {
this.onClick(e, 0, "onSglClick"); this.onClick(e, 0, "onSglClick");
}) })
BDFDB.addEventListener(this, document, "dblclick", BDFDB.dotCN.messagegroup + "> [aria-disabled]," + BDFDB.dotCN.messagegroup + "> * > [aria-disabled]," + BDFDB.dotCN.messagesystem, e => { BDFDB.ListenerUtils.add(this, document, "dblclick", BDFDB.dotCN.messagegroup + "> [aria-disabled]," + BDFDB.dotCN.messagegroup + "> * > [aria-disabled]," + BDFDB.dotCN.messagesystem, e => {
this.onClick(e, 1, "onDblClick"); this.onClick(e, 1, "onDblClick");
}); });
BDFDB.addEventListener(this, document, "keydown", BDFDB.dotCN.textareawrapchat, e => { BDFDB.ListenerUtils.add(this, document, "keydown", BDFDB.dotCN.textareawrapchat, e => {
this.onKeyDown(e, e.which, "onKeyDown"); this.onKeyDown(e, e.which, "onKeyDown");
}); });
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -265,7 +263,7 @@ class MessageUtilities {
if (!this.isEventFired(name)) { if (!this.isEventFired(name)) {
this.fireEvent(name); this.fireEvent(name);
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
let bindings = BDFDB.filterObject(BDFDB.getAllData(this, "bindings"), action => {return settings[action]}, true); let bindings = BDFDB.ObjectUtils.filter(BDFDB.getAllData(this, "bindings"), action => {return settings[action]}, true);
let priorityaction = null; let priorityaction = null;
for (let action in bindings) { for (let action in bindings) {
let binding = bindings[action]; let binding = bindings[action];
@ -275,7 +273,7 @@ class MessageUtilities {
if (priorityaction) { if (priorityaction) {
let {messagediv, pos, message} = this.getMessageData(e.currentTarget); let {messagediv, pos, message} = this.getMessageData(e.currentTarget);
if (messagediv && pos > -1 && message) { if (messagediv && pos > -1 && message) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
clearTimeout(this.clickTimeout); clearTimeout(this.clickTimeout);
if (!this.hasDoubleClickOverwrite(bindings, bindings[priorityaction])) { if (!this.hasDoubleClickOverwrite(bindings, bindings[priorityaction])) {
this.defaults.bindings[priorityaction].func.bind(this)({messagediv, pos, message}, priorityaction); this.defaults.bindings[priorityaction].func.bind(this)({messagediv, pos, message}, priorityaction);
@ -298,7 +296,7 @@ class MessageUtilities {
hasDoubleClickOverwrite (bindings, binding) { hasDoubleClickOverwrite (bindings, binding) {
if (binding.click == 1) return false; if (binding.click == 1) return false;
let dblbindings = BDFDB.filterObject(bindings, bndg => {return bndg.click == 1}); let dblbindings = BDFDB.ObjectUtils.filter(bindings, bndg => {return bndg.click == 1});
for (let dblaction in dblbindings) { for (let dblaction in dblbindings) {
let dblbndg = dblbindings[dblaction]; let dblbndg = dblbindings[dblaction];
let overwrite = true; let overwrite = true;
@ -313,17 +311,17 @@ class MessageUtilities {
if (deletelink) deletelink.click(); if (deletelink) deletelink.click();
else { else {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if ((channel && BDFDB.isUserAllowedTo("MANAGE_MESSAGES")) || message.author.id == BDFDB.myData.id && message.type != 1 && message.type != 2 && message.type != 3) { 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"); BDFDB.LibraryModules.MessageUtils.deleteMessage(message.channel_id, message.id, message.state != "SENT");
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Message has been deleted.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Message has been deleted.", {type:"success"});
} }
} }
} }
doEdit ({messagediv, pos, message}, action) { doEdit ({messagediv, pos, message}, action) {
if (message.author.id == BDFDB.myData.id && !messagediv.querySelector("textarea")) { if (message.author.id == BDFDB.UserUtils.me.id && !messagediv.querySelector("textarea")) {
BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content); BDFDB.LibraryModules.MessageUtils.startEditMessage(message.channel_id, message.id, message.content);
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Started editing.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Started editing.", {type:"success"});
} }
} }
@ -331,21 +329,21 @@ class MessageUtilities {
let reactButton = messagediv.querySelector(BDFDB.dotCN.emojipickerbutton); let reactButton = messagediv.querySelector(BDFDB.dotCN.emojipickerbutton);
if (reactButton) { if (reactButton) {
reactButton.click(); reactButton.click();
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Reaction popout has been opened.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Reaction popout has been opened.", {type:"success"});
} }
} }
doPinUnPin ({messagediv, pos, message}, action) { doPinUnPin ({messagediv, pos, message}, action) {
if (message.state == "SENT") { if (message.state == "SENT") {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel && (channel.type == 1 || channel.type == 3 || BDFDB.isUserAllowedTo("MANAGE_MESSAGES")) && message.type == 0) { if (channel && (channel.type == 1 || channel.type == 3 || BDFDB.UserUtils.can("MANAGE_MESSAGES")) && message.type == 0) {
if (message.pinned) { if (message.pinned) {
BDFDB.LibraryModules.MessagePinUtils.unpinMessage(channel, message.id); BDFDB.LibraryModules.MessagePinUtils.unpinMessage(channel, message.id);
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Message has been unpinned.", {type:"error"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Message has been unpinned.", {type:"error"});
} }
else { else {
BDFDB.LibraryModules.MessagePinUtils.pinMessage(channel, message.id); BDFDB.LibraryModules.MessagePinUtils.pinMessage(channel, message.id);
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Message has been pinned.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Message has been pinned.", {type:"success"});
} }
} }
} }
@ -354,7 +352,7 @@ class MessageUtilities {
doCopyRaw ({messagediv, pos, message}, action) { doCopyRaw ({messagediv, pos, message}, action) {
if (message.content) { if (message.content) {
BDFDB.LibraryRequires.electron.clipboard.write({text:message.content}); BDFDB.LibraryRequires.electron.clipboard.write({text:message.content});
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Raw message content has been copied.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Raw message content has been copied.", {type:"success"});
} }
} }
@ -362,41 +360,41 @@ class MessageUtilities {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) { if (channel) {
BDFDB.LibraryRequires.electron.clipboard.write({text:`https://discordapp.com/channels/${channel.guild_id}/${channel.id}/${message.id}`}); BDFDB.LibraryRequires.electron.clipboard.write({text:`https://discordapp.com/channels/${channel.guild_id}/${channel.id}/${message.id}`});
if (BDFDB.getData(action, this, "toasts")) BDFDB.showToast("Messagelink has been copied.", {type:"success"}); if (BDFDB.getData(action, this, "toasts")) BDFDB.NotificationUtils.toast("Messagelink has been copied.", {type:"success"});
} }
} }
doNote ({messagediv, pos, message}, action) { doNote ({messagediv, pos, message}, action) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) { if (BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings.__Note_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, messagediv, channel); if (channel) BDFDB.BdUtils.getPlugin(this.defaults.bindings.__Note_Message.plugin).addMessageToNotes(message, messagediv, channel);
} }
} }
doTranslate ({messagediv, pos, message}, action) { doTranslate ({messagediv, pos, message}, action) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) { if (BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings.__Translate_Message.plugin)) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(message.channel_id);
if (channel) BDFDB.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, messagediv, channel); if (channel) BDFDB.BdUtils.getPlugin(this.defaults.bindings.__Translate_Message.plugin).translateMessage(message, messagediv, channel);
} }
} }
doQuote ({messagediv, pos, message}, action) { doQuote ({messagediv, pos, message}, action) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) { if (BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings.__Quote_Message.plugin)) {
let quoteButton = messagediv.querySelector(".btn-quote"); let quoteButton = messagediv.querySelector(".btn-quote");
if (quoteButton) quoteButton.click(); if (quoteButton) quoteButton.click();
} }
} }
doCitate ({messagediv, pos, message}, action) { doCitate ({messagediv, pos, message}, action) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Citate_Message.plugin)) { if (BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings.__Citate_Message.plugin)) {
let citarButton = messagediv.parentElement.querySelector(".citar-btn"); let citarButton = messagediv.parentElement.querySelector(".citar-btn");
if (citarButton) citarButton.click(); if (citarButton) citarButton.click();
} }
} }
doReveal ({messagediv, pos, message}, action) { doReveal ({messagediv, pos, message}, action) {
if (BDFDB.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) { if (BDFDB.BdUtils.isPluginEnabled(this.defaults.bindings.__Reveal_Spoilers.plugin)) {
BDFDB.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messagediv); BDFDB.BdUtils.getPlugin(this.defaults.bindings.__Reveal_Spoilers.plugin).revealAllSpoilers(messagediv);
} }
} }
@ -427,7 +425,7 @@ class MessageUtilities {
getMessageData (target) { getMessageData (target) {
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> [aria-disabled]", target) || BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> * > [aria-disabled]", target) || BDFDB.getParentEle(BDFDB.dotCN.messagesystem, target); let messagediv = BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> [aria-disabled]", target) || BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> * > [aria-disabled]", target) || BDFDB.getParentEle(BDFDB.dotCN.messagesystem, target);
let pos = messagediv ? Array.from(messagediv.parentElement.childNodes).filter(n => n.nodeType != Node.TEXT_NODE).indexOf(messagediv) : -1; let pos = messagediv ? Array.from(messagediv.parentElement.childNodes).filter(n => n.nodeType != Node.TEXT_NODE).indexOf(messagediv) : -1;
let instance = BDFDB.getReactInstance(messagediv); let instance = BDFDB.ReactUtils.getInstance(messagediv);
let message = instance ? BDFDB.getKeyInformation({instance, key:"message", up:true}) : null; let message = instance ? BDFDB.getKeyInformation({instance, key:"message", up:true}) : null;
return {messagediv, pos, message}; return {messagediv, pos, message};
} }
@ -441,6 +439,6 @@ class MessageUtilities {
} }
cancelEvent (name) { cancelEvent (name) {
setImmediate(() => {BDFDB.removeFromArray(this.firedEvents, name)}); setImmediate(() => {BDFDB.ArrayUtils.remove(this.firedEvents, name)});
} }
} }

View File

@ -47,7 +47,7 @@ class MoveablePopups {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
var observer = null; var observer = null;
@ -64,7 +64,7 @@ class MoveablePopups {
} }
); );
}); });
BDFDB.addObserver(this, BDFDB.dotCN.popouts, {name:"popoutObserver",instance:observer}, {childList: true}); BDFDB.ObserverUtils.connect(this, BDFDB.dotCN.popouts, {name:"popoutObserver",instance:observer}, {childList: true});
observer = new MutationObserver((changes, _) => { observer = new MutationObserver((changes, _) => {
changes.forEach( changes.forEach(
@ -82,11 +82,9 @@ class MoveablePopups {
} }
); );
}); });
BDFDB.addObserver(this, BDFDB.React.findDOMNode(BDFDB.getOwnerInstance({node:document.querySelector(BDFDB.dotCN.app), name:"Modals"})), {name:"modalObserver",instance:observer}, {childList: true}); BDFDB.ObserverUtils.connect(this, BDFDB.ReactUtils.findDOMNode(BDFDB.getOwnerInstance({node:document.querySelector(BDFDB.dotCN.app), name:"Modals"})), {name:"modalObserver",instance:observer}, {childList: true});
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -94,7 +92,7 @@ class MoveablePopups {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -104,7 +102,7 @@ class MoveablePopups {
makeMoveable (div) { makeMoveable (div) {
div.removeEventListener("click", div.clickMovablePopups); div.removeEventListener("click", div.clickMovablePopups);
div.removeEventListener("mousedown", div.mousedownMovablePopups); div.removeEventListener("mousedown", div.mousedownMovablePopups);
div.clickMovablePopups = e => {if (this.dragging) BDFDB.stopEvent(e);}; div.clickMovablePopups = e => {if (this.dragging) BDFDB.ListenerUtils.stopEvent(e);};
div.mousedownMovablePopups = e => { div.mousedownMovablePopups = e => {
if (!e.ctrlKey) return; if (!e.ctrlKey) return;
div.style.setProperty("position", "fixed", "important"); div.style.setProperty("position", "fixed", "important");

View File

@ -144,9 +144,9 @@ class NotificationSounds {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addsong", e => {this.saveAudio(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-addsong", e => {this.saveAudio(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "keyup", ".songInput", e => {if (e.which == 13) this.saveAudio(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", ".songInput", e => {if (e.which == 13) this.saveAudio(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to delete all added songs?", () => { BDFDB.openConfirmModal(this, "Are you sure you want to delete all added songs?", () => {
BDFDB.removeAllData(this, "choices"); BDFDB.removeAllData(this, "choices");
BDFDB.removeAllData(this, "audios"); BDFDB.removeAllData(this, "audios");
@ -167,21 +167,21 @@ class NotificationSounds {
}); });
}); });
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".mutednd-checkbox", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".mutednd-checkbox", e => {
var type = e.currentTarget.parentElement.getAttribute("type"); var type = e.currentTarget.parentElement.getAttribute("type");
this.choices[type].mute = e.currentTarget.checked; this.choices[type].mute = e.currentTarget.checked;
this.saveChoice(type, false); this.saveChoice(type, false);
}); });
BDFDB.addEventListener(this, settingspanel, "click", ".mutefocus-checkbox", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".mutefocus-checkbox", e => {
var type = e.currentTarget.parentElement.getAttribute("type"); var type = e.currentTarget.parentElement.getAttribute("type");
this.choices[type].focus = e.currentTarget.checked; this.choices[type].focus = e.currentTarget.checked;
this.saveChoice(type, false); this.saveChoice(type, false);
}); });
BDFDB.addEventListener(this, settingspanel, "click", "#input-unimplemented", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", "#input-unimplemented", e => {
BDFDB.toggleEles(settingspanel.querySelectorAll(".unimplemented"), e.currentTarget.checked); BDFDB.toggleEles(settingspanel.querySelectorAll(".unimplemented"), e.currentTarget.checked);
}); });
BDFDB.addEventListener(this, settingspanel, "mousedown", BDFDB.dotCN.slidergrabber, e => {this.dragSlider(settingspanel,e);}); BDFDB.ListenerUtils.add(this, settingspanel, "mousedown", BDFDB.dotCN.slidergrabber, e => {this.dragSlider(settingspanel,e);});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type").split(" "); let type = BDFDB.getParentEle(BDFDB.dotCN.select, e.currentTarget).getAttribute("type").split(" ");
let songSelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type[0]} song"]`); let songSelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type[0]} song"]`);
let categorySelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type[0]} category"]`); let categorySelect = settingspanel.querySelector(`${BDFDB.dotCN.select}[type="${type[0]} category"]`);
@ -216,18 +216,18 @@ class NotificationSounds {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.patch(BDFDB.LibraryModules.MessageUtils, "receiveMessage", this, {before: e => { BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.MessageUtils, "receiveMessage", {before: e => {
let message = e.methodArguments[1]; let message = e.methodArguments[1];
let guildid = message.guild_id ? message.guild_id : null; let guildid = message.guild_id ? message.guild_id : null;
if (!BDFDB.LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(guildid, message.channel_id) && message.author.id != BDFDB.myData.id) { if (!BDFDB.LibraryModules.MutedUtils.isGuildOrCategoryOrChannelMuted(guildid, message.channel_id) && message.author.id != BDFDB.UserUtils.me.id) {
if (!guildid && !(this.choices.dm.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) { if (!guildid && !(this.choices.dm.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) {
this.fireEvent("dm"); this.fireEvent("dm");
this.playAudio("dm"); this.playAudio("dm");
} }
else if (message.mentions && !(this.choices.mentioned.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) { else if (message.mentions && !(this.choices.mentioned.focus && document.hasFocus() && BDFDB.LibraryModules.LastChannelStore.getChannelId() == message.channel_id)) {
for (let mention of message.mentions) if (mention.id == BDFDB.myData.id) { for (let mention of message.mentions) if (mention.id == BDFDB.UserUtils.me.id) {
this.fireEvent("mentioned"); this.fireEvent("mentioned");
this.playAudio("mentioned"); this.playAudio("mentioned");
break; break;
@ -236,7 +236,7 @@ class NotificationSounds {
} }
}}); }});
BDFDB.WebModules.patch(BDFDB.LibraryModules.SoundUtils, "playSound", this, {instead: e => { BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {instead: e => {
let type = e.methodArguments[0]; let type = e.methodArguments[0];
if (this.choices[type]) setImmediate(() => { if (this.choices[type]) setImmediate(() => {
if (type == "message1") { if (type == "message1") {
@ -248,7 +248,7 @@ class NotificationSounds {
}); });
else e.callOriginalMethod(); else e.callOriginalMethod();
}}); }});
BDFDB.WebModules.patch(BDFDB.LibraryModules.SoundUtils, "createSound", this, {after: e => { BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "createSound", {after: e => {
let type = e.methodArguments[0]; let type = e.methodArguments[0];
let audio = new Audio(); let audio = new Audio();
audio.src = this.choices[type].src; audio.src = this.choices[type].src;
@ -269,11 +269,9 @@ class NotificationSounds {
this.loadAudios(); this.loadAudios();
this.loadChoices(); this.loadChoices();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -281,7 +279,7 @@ class NotificationSounds {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
this.settingsaudio.pause(); this.settingsaudio.pause();
} }
} }
@ -309,7 +307,7 @@ class NotificationSounds {
var selectMenu = this.createDropdownMenu(type, option, category, song); var selectMenu = this.createDropdownMenu(type, option, category, song);
selectWrap.appendChild(selectMenu); selectWrap.appendChild(selectMenu);
BDFDB.addChildEventListener(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => { BDFDB.ListenerUtils.addToChildren(selectMenu, "mousedown", BDFDB.dotCN.selectoption, e2 => {
var selection = e2.currentTarget.textContent; var selection = e2.currentTarget.textContent;
selectWrap.setAttribute("value", selection); selectWrap.setAttribute("value", selection);
selectWrap.querySelector(BDFDB.dotCN.title).innerText = selection; selectWrap.querySelector(BDFDB.dotCN.title).innerText = selection;
@ -404,7 +402,7 @@ class NotificationSounds {
loadAudios () { loadAudios () {
this.audios = BDFDB.loadAllData(this, "audios"); this.audios = BDFDB.loadAllData(this, "audios");
if (BDFDB.isObjectEmpty(this.audios)) this.audios = this.defaults; if (BDFDB.ObjectUtils.isEmpty(this.audios)) this.audios = this.defaults;
BDFDB.saveAllData(this.audios, this, "audios"); BDFDB.saveAllData(this.audios, this, "audios");
} }
@ -428,13 +426,13 @@ class NotificationSounds {
return; return;
} }
} }
BDFDB.showToast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"}); BDFDB.NotificationUtils.toast("Use a valid direct link to a video or audio source. They usually end on something like .mp3, .mp4 or .wav.", {type:"danger"});
}); });
} }
else { else {
BDFDB.LibraryRequires.fs.readFile(url, (error, response) => { BDFDB.LibraryRequires.fs.readFile(url, (error, response) => {
if (error) { if (error) {
BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"}); BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
} }
else { else {
url = `data:audio/mpeg;base64,${response.toString("base64")}`; url = `data:audio/mpeg;base64,${response.toString("base64")}`;
@ -444,7 +442,7 @@ class NotificationSounds {
} }
successSavedAudio = () => { successSavedAudio = () => {
BDFDB.showToast(`Song ${song} was added to category ${category}.`, {type:"success"}); BDFDB.NotificationUtils.toast(`Song ${song} was added to category ${category}.`, {type:"success"});
if (!this.audios[category]) this.audios[category] = {}; if (!this.audios[category]) this.audios[category] = {};
this.audios[category][song] = url; this.audios[category][song] = url;
BDFDB.saveAllData(this.audios, this, "audios"); BDFDB.saveAllData(this.audios, this, "audios");
@ -453,9 +451,7 @@ class NotificationSounds {
}); });
}; };
} }
else { else BDFDB.NotificationUtils.toast("Fill out all fields to add a new song.", {type:"danger"});
BDFDB.showToast("Fill out all fields to add a new song.", {type:"danger"});
}
} }
loadChoices () { loadChoices () {
@ -493,7 +489,7 @@ class NotificationSounds {
} }
dontPlayAudio (type) { dontPlayAudio (type) {
let status = BDFDB.getUserStatus(); let status = BDFDB.UserUtils.getStatus();
return this.choices[type].mute && (status == "dnd" || status == "streaming"); return this.choices[type].mute && (status == "dnd" || status == "streaming");
} }
@ -512,10 +508,10 @@ class NotificationSounds {
audio.play(); audio.play();
}; };
let stop = () => {audio.pause();} let stop = () => {audio.pause();}
BDFDB.WebModules.patch(instance, "startRinging", this, {instead: play}); BDFDB.ModuleUtils.patch(this, instance, "startRinging", {instead: play});
BDFDB.WebModules.patch(instance, "stopRinging", this, {instead: stop}); BDFDB.ModuleUtils.patch(this, instance, "stopRinging", {instead: stop});
BDFDB.WebModules.patch(instance._reactInternalFiber.type.prototype, "startRinging", this, {instead: play}); BDFDB.ModuleUtils.patch(this, instance._reactInternalFiber.type.prototype, "startRinging", {instead: play});
BDFDB.WebModules.patch(instance._reactInternalFiber.type.prototype, "stopRinging", this, {instead: stop}); BDFDB.ModuleUtils.patch(this, instance._reactInternalFiber.type.prototype, "stopRinging", {instead: stop});
} }
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {

View File

@ -108,13 +108,13 @@ class OldTitleBar {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".nativetitlebar-switch", e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".nativetitlebar-switch", e => {
if (this.patchMainScreen(e.currentTarget.checked)) { if (this.patchMainScreen(e.currentTarget.checked)) {
this.patched = !this.patched; this.patched = !this.patched;
let notifybar = document.querySelector("#OldTitleBarNotifyBar"); let notifybar = document.querySelector("#OldTitleBarNotifyBar");
if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click(); if (notifybar) notifybar.querySelector(BDFDB.dotCN.noticedismiss).click();
if (this.patched) { if (this.patched) {
notifybar = BDFDB.createNotificationsBar("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"}); notifybar = BDFDB.NotificationUtils.notice("Changed nativebar settings, relaunch to see changes:", {type:"danger",btn:"Relaunch",id:"OldTitleBarNotifyBar"});
notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", () => { notifybar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", () => {
BDFDB.LibraryRequires.electron.remote.app.relaunch(); BDFDB.LibraryRequires.electron.remote.app.relaunch();
BDFDB.LibraryRequires.electron.remote.app.quit(); BDFDB.LibraryRequires.electron.remote.app.quit();
@ -150,9 +150,9 @@ class OldTitleBar {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.addEventListener(this, window, "resize", e => { BDFDB.ListenerUtils.add(this, window, "resize", e => {
this.changeMaximizeButtons(); this.changeMaximizeButtons();
}); });
@ -162,11 +162,9 @@ class OldTitleBar {
BDFDB.addClass([document.body,document.querySelector(BDFDB.dotCN.titlebar)], "hidden-by-OTB"); BDFDB.addClass([document.body,document.querySelector(BDFDB.dotCN.titlebar)], "hidden-by-OTB");
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -178,7 +176,7 @@ class OldTitleBar {
BDFDB.removeClasses("hidden-by-OTB", "settingsTitlebarOTB-added"); BDFDB.removeClasses("hidden-by-OTB", "settingsTitlebarOTB-added");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -239,7 +237,7 @@ class OldTitleBar {
var reloadbuttonicon = reloadbutton.querySelector(BDFDB.dotCN.channelheadericon); var reloadbuttonicon = reloadbutton.querySelector(BDFDB.dotCN.channelheadericon);
reloadbuttonicon.addEventListener("click", () => {this.window.reload();}); reloadbuttonicon.addEventListener("click", () => {this.window.reload();});
reloadbuttonicon.addEventListener("mouseenter", e => { reloadbuttonicon.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Reload", reloadbuttonicon, {type:"bottom",selector:"reload-button-tooltip"}); BDFDB.TooltipUtils.create(reloadbuttonicon, "Reload", {type:"bottom",selector:"reload-button-tooltip"});
}); });
} }
bar.appendChild(BDFDB.htmlToElement(this.dividerMarkup)); bar.appendChild(BDFDB.htmlToElement(this.dividerMarkup));

View File

@ -65,7 +65,7 @@ class OwnerTag {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "keyup", BDFDB.dotCN.input, () => {this.saveInputs(settingspanel);});
return settingspanel; return settingspanel;
} }
@ -94,15 +94,13 @@ class OwnerTag {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
this.addHideCSS(); this.addHideCSS();
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
@ -113,7 +111,7 @@ class OwnerTag {
BDFDB.removeLocalStyle(this.name + "HideCrown"); BDFDB.removeLocalStyle(this.name + "HideCrown");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -142,7 +140,7 @@ class OwnerTag {
} }
processMessageUsername (instance, wrapper, returnvalue, methodnames) { processMessageUsername (instance, wrapper, returnvalue, methodnames) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message && BDFDB.getData("addInChatWindow", this, "settings")) { if (message && BDFDB.getData("addInChatWindow", this, "settings")) {
let username = wrapper.querySelector(BDFDB.dotCN.messageusername); let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
if (username) { if (username) {
@ -156,7 +154,7 @@ class OwnerTag {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.removeEles(".owner-tag, .owner-tag-crown"); BDFDB.removeEles(".owner-tag, .owner-tag-crown");
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
this.addHideCSS(); this.addHideCSS();
} }
} }
@ -169,13 +167,13 @@ class OwnerTag {
let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id); let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id);
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
let isowner = channel.ownerId == info.id || guild && guild.ownerId == info.id; let isowner = channel.ownerId == info.id || guild && guild.ownerId == info.id;
if (!(isowner || (settings.addForAdmins && BDFDB.isUserAllowedTo("ADMINISTRATOR", info.id)))) return; if (!(isowner || (settings.addForAdmins && BDFDB.UserUtils.can("ADMINISTRATOR", info.id)))) return;
let member = settings.useRoleColor ? (BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, info.id) || {}) : {}; let member = settings.useRoleColor ? (BDFDB.LibraryModules.MemberStore.getMember(channel.guild_id, info.id) || {}) : {};
if (!settings.useCrown) { if (!settings.useCrown) {
let tag = BDFDB.htmlToElement(`<span class="owner-tag ${isowner ? "owner-tag-owner" : "owner-tag-admin"} owner-${type}-tag ${(settings.useRoleColor ? "owner-tag-rolecolor " : "") + BDFDB.disCN.bottag + (selector ? (" " + selector) : "")}" style="order: 10 !important;">${BDFDB.getData(isowner ? "ownTagName" : "ownAdminTagName", this, "inputs")}</span>`); let tag = BDFDB.htmlToElement(`<span class="owner-tag ${isowner ? "owner-tag-owner" : "owner-tag-admin"} owner-${type}-tag ${(settings.useRoleColor ? "owner-tag-rolecolor " : "") + BDFDB.disCN.bottag + (selector ? (" " + selector) : "")}" style="order: 10 !important;">${BDFDB.getData(isowner ? "ownTagName" : "ownAdminTagName", this, "inputs")}</span>`);
let invert = container && container.firstElementChild && !(BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal) || BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userprofiletopsectionnormal)); let invert = container && container.firstElementChild && !(BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userpopoutheadernormal) || BDFDB.containsClass(container.firstElementChild, BDFDB.disCN.userprofiletopsectionnormal));
BDFDB.addClass(tag, invert ? BDFDB.disCN.bottaginvert : BDFDB.disCN.bottagregular); BDFDB.addClass(tag, invert ? BDFDB.disCN.bottaginvert : BDFDB.disCN.bottagregular);
let EditUsersData = BDFDB.isPluginEnabled("EditUsers") ? BDFDB.getPlugin("EditUsers").getUserData(info.id, wrapper) : {}; let EditUsersData = BDFDB.BdUtils.isPluginEnabled("EditUsers") ? BDFDB.BdUtils.getPlugin("EditUsers").getUserData(info.id, wrapper) : {};
let tagcolor = BDFDB.colorCONVERT(EditUsersData.color1 || member.colorString, "RGBA"); let tagcolor = BDFDB.colorCONVERT(EditUsersData.color1 || member.colorString, "RGBA");
let isbright = BDFDB.colorISBRIGHT(tagcolor); let isbright = BDFDB.colorISBRIGHT(tagcolor);
tagcolor = isbright ? (settings.useBlackFont ? tagcolor : BDFDB.colorCHANGE(tagcolor, -0.3)) : tagcolor; tagcolor = isbright ? (settings.useBlackFont ? tagcolor : BDFDB.colorCHANGE(tagcolor, -0.3)) : tagcolor;
@ -186,7 +184,7 @@ class OwnerTag {
else { else {
let crown = BDFDB.htmlToElement(`<svg name="Crown" class="owner-tag-crown ${isowner ? "owner-tag-owner" : "owner-tag-admin"} ${BDFDB.disCN.memberownericon}" aria-hidden="false" width="24" height="24" viewBox="0 0 16 16"><g fill="none" fill-rule="evenodd"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.6572 5.42868C13.8879 5.29002 14.1806 5.30402 14.3973 5.46468C14.6133 5.62602 14.7119 5.90068 14.6473 6.16202L13.3139 11.4954C13.2393 11.7927 12.9726 12.0007 12.6666 12.0007H3.33325C3.02725 12.0007 2.76058 11.792 2.68592 11.4954L1.35258 6.16202C1.28792 5.90068 1.38658 5.62602 1.60258 5.46468C1.81992 5.30468 2.11192 5.29068 2.34325 5.42868L5.13192 7.10202L7.44592 3.63068C7.46173 3.60697 7.48377 3.5913 7.50588 3.57559C7.5192 3.56612 7.53255 3.55663 7.54458 3.54535L6.90258 2.90268C6.77325 2.77335 6.77325 2.56068 6.90258 2.43135L7.76458 1.56935C7.89392 1.44002 8.10658 1.44002 8.23592 1.56935L9.09792 2.43135C9.22725 2.56068 9.22725 2.77335 9.09792 2.90268L8.45592 3.54535C8.46794 3.55686 8.48154 3.56651 8.49516 3.57618C8.51703 3.5917 8.53897 3.60727 8.55458 3.63068L10.8686 7.10202L13.6572 5.42868ZM2.66667 12.6673H13.3333V14.0007H2.66667V12.6673Z" fill="${isowner ? "currentColor" : "#b3b3b3"}"></path></svg>`); let crown = BDFDB.htmlToElement(`<svg name="Crown" class="owner-tag-crown ${isowner ? "owner-tag-owner" : "owner-tag-admin"} ${BDFDB.disCN.memberownericon}" aria-hidden="false" width="24" height="24" viewBox="0 0 16 16"><g fill="none" fill-rule="evenodd"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.6572 5.42868C13.8879 5.29002 14.1806 5.30402 14.3973 5.46468C14.6133 5.62602 14.7119 5.90068 14.6473 6.16202L13.3139 11.4954C13.2393 11.7927 12.9726 12.0007 12.6666 12.0007H3.33325C3.02725 12.0007 2.76058 11.792 2.68592 11.4954L1.35258 6.16202C1.28792 5.90068 1.38658 5.62602 1.60258 5.46468C1.81992 5.30468 2.11192 5.29068 2.34325 5.42868L5.13192 7.10202L7.44592 3.63068C7.46173 3.60697 7.48377 3.5913 7.50588 3.57559C7.5192 3.56612 7.53255 3.55663 7.54458 3.54535L6.90258 2.90268C6.77325 2.77335 6.77325 2.56068 6.90258 2.43135L7.76458 1.56935C7.89392 1.44002 8.10658 1.44002 8.23592 1.56935L9.09792 2.43135C9.22725 2.56068 9.22725 2.77335 9.09792 2.90268L8.45592 3.54535C8.46794 3.55686 8.48154 3.56651 8.49516 3.57618C8.51703 3.5917 8.53897 3.60727 8.55458 3.63068L10.8686 7.10202L13.6572 5.42868ZM2.66667 12.6673H13.3333V14.0007H2.66667V12.6673Z" fill="${isowner ? "currentColor" : "#b3b3b3"}"></path></svg>`);
crown.addEventListener("mouseenter", () => { crown.addEventListener("mouseenter", () => {
BDFDB.createTooltip(isowner ? (channel.type == 3 ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER) : BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR, crown, {type: "top"}); BDFDB.TooltipUtils.create(crown, isowner ? (channel.type == 3 ? BDFDB.LanguageUtils.LanguageStrings.GROUP_OWNER : BDFDB.LanguageUtils.LanguageStrings.GUILD_OWNER) : BDFDB.LanguageUtils.LanguageStrings.ADMINISTRATOR, {type: "top"});
}); });
wrapper.insertBefore(crown, wrapper.querySelector(".TRE-tag,svg[name=MobileDevice]")); wrapper.insertBefore(crown, wrapper.querySelector(".TRE-tag,svg[name=MobileDevice]"));
} }

View File

@ -174,13 +174,11 @@ class PersonalPins {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -189,7 +187,7 @@ class PersonalPins {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".popout-personalpins-notes", ".personalpins-sort-popout", ".notes-button"); BDFDB.removeEles(".popout-personalpins-notes", ".personalpins-sort-popout", ".notes-button");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -217,9 +215,9 @@ class PersonalPins {
if (!messagediv || pos == -1) return; if (!messagediv || pos == -1) return;
let note = this.getNoteData(instance.props.message, instance.props.target, instance.props.channel); let note = this.getNoteData(instance.props.message, instance.props.target, instance.props.channel);
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "MessagePinItem"); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "MessagePinItem");
const pinUnpinItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const pinUnpinItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels[note ? "context_unpinoption_text" : "context_pinoption_text"], label: this.labels[note ? "context_unpinoption_text" : "context_pinoption_text"],
hint: BDFDB.isPluginEnabled("MessageUtilities") ? BDFDB.getPlugin("MessageUtilities").getActiveShortcutString("__Note_Message") : null, hint: BDFDB.BdUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BdUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Note_Message") : null,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${note ? "unpin" : "pin"}-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${note ? "unpin" : "pin"}-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(menu); BDFDB.closeContextMenu(menu);
@ -232,7 +230,7 @@ class PersonalPins {
let newmarkup = this.getMarkup(messagediv).innerHTML; let newmarkup = this.getMarkup(messagediv).innerHTML;
let newaccessory = messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML; let newaccessory = messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML;
if (note.markup != newmarkup || note.accessory != newaccessory) { if (note.markup != newmarkup || note.accessory != newaccessory) {
const updateItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const updateItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_updateoption_text, label: this.labels.context_updateoption_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-update-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-update-contextMenuItem`,
action: e => { action: e => {
@ -253,7 +251,7 @@ class PersonalPins {
if (!messagediv || pos == -1) return; if (!messagediv || pos == -1) return;
let note = this.getNoteData(instance.props.message, instance.props.target, instance.props.channel); let note = this.getNoteData(instance.props.message, instance.props.target, instance.props.channel);
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, [BDFDB.LanguageUtils.LanguageStrings.PIN, BDFDB.LanguageUtils.LanguageStrings.UNPIN]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, [BDFDB.LanguageUtils.LanguageStrings.PIN, BDFDB.LanguageUtils.LanguageStrings.UNPIN]);
const pinUnpinItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const pinUnpinItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels[note ? "context_unpinoption_text" : "popout_pinoption_text"], label: this.labels[note ? "context_unpinoption_text" : "popout_pinoption_text"],
className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-${note ? "unpin" : "pin"}-popoutMenuItem`, className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-${note ? "unpin" : "pin"}-popoutMenuItem`,
action: e => { action: e => {
@ -266,7 +264,7 @@ class PersonalPins {
let newmarkup = this.getMarkup(messagediv).innerHTML; let newmarkup = this.getMarkup(messagediv).innerHTML;
let newaccessory = messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML; let newaccessory = messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML;
if (note.markup != newmarkup || note.accessory != newaccessory) { if (note.markup != newmarkup || note.accessory != newaccessory) {
const updateItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const updateItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_updateoption_text, label: this.labels.context_updateoption_text,
className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-update-popoutMenuItem`, className: `${BDFDB.disCN.optionpopoutitem} BDFDB-popoutMenuItem ${this.name}-popoutMenuItem ${this.name}-update-popoutMenuItem`,
action: e => { action: e => {
@ -295,12 +293,12 @@ class PersonalPins {
this.openNotesPopout(icon.parentElement); this.openNotesPopout(icon.parentElement);
}); });
icon.addEventListener("mouseenter", () => { icon.addEventListener("mouseenter", () => {
BDFDB.createTooltip(this.labels.popout_note_text, icon, {type:"bottom",selector:"note-button-tooltip"}); BDFDB.TooltipUtils.create(icon, this.labels.popout_note_text, {type:"bottom",selector:"note-button-tooltip"});
}); });
} }
processMessage (instance, wrapper, returnvalue) { processMessage (instance, wrapper, returnvalue) {
if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.getReactValue(instance, "props.message.author.id") != 1) { if (instance.props && typeof instance.props.renderButtons == "function" && !wrapper.querySelector(BDFDB.dotCN.optionpopoutbutton) && BDFDB.ReactUtils.getValue(instance, "props.message.author.id") != 1) {
let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer); let buttonwrap = wrapper.querySelector(BDFDB.dotCN.messagebuttoncontainer);
if (buttonwrap) { if (buttonwrap) {
let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`); let optionPopoutButton = BDFDB.htmlToElement(`<div tabindex="0" class="${BDFDB.disCN.optionpopoutbutton}" aria-label="More Options" role="button"><svg name="OverflowMenu" class="${BDFDB.disCN.optionpopoutbuttonicon}" aria-hidden="false" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0z"></path><path fill="currentColor" d="M12 16c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2zm0-6c1.1045695 0 2 .8954305 2 2s-.8954305 2-2 2-2-.8954305-2-2 .8954305-2 2-2z"></path></g></svg></div>`);
@ -350,15 +348,15 @@ class PersonalPins {
addNotes (notespopout) { addNotes (notespopout) {
BDFDB.removeEles(notespopout.querySelectorAll(BDFDB.dotCNC.messagegroupwrapper + BDFDB.dotCN.messagespopoutchannelseparator)); BDFDB.removeEles(notespopout.querySelectorAll(BDFDB.dotCNC.messagegroupwrapper + BDFDB.dotCN.messagespopoutchannelseparator));
let channel = BDFDB.getSelectedChannel(); let channel = BDFDB.ChannelUtils.getSelected();
if (channel) { if (channel) {
let guild_id = channel.guild_id ? channel.guild_id : "@me"; let guild_id = channel.guild_id ? channel.guild_id : "@me";
let pins = BDFDB.loadAllData(this, "pins"); let pins = BDFDB.loadAllData(this, "pins");
if (!BDFDB.isObjectEmpty(pins)) { if (!BDFDB.ObjectUtils.isEmpty(pins)) {
let container = notespopout.querySelector(BDFDB.dotCN.messagespopout); let container = notespopout.querySelector(BDFDB.dotCN.messagespopout);
let placeholder = notespopout.querySelector(BDFDB.dotCN.messagespopoutemptyplaceholder); let placeholder = notespopout.querySelector(BDFDB.dotCN.messagespopoutemptyplaceholder);
if (!container || !placeholder) return; if (!container || !placeholder) return;
placeholder.querySelector(BDFDB.dotCN.messagespopoutimage).style.setProperty("background-image", `url(${BDFDB.getDiscordTheme() == BDFDB.disCN.themelight ? "/assets/03c7541028afafafd1a9f6a81cb7f149.svg" : "/assets/6793e022dc1b065b21f12d6df02f91bd.svg"})`); placeholder.querySelector(BDFDB.dotCN.messagespopoutimage).style.setProperty("background-image", `url(${BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight ? "/assets/03c7541028afafafd1a9f6a81cb7f149.svg" : "/assets/6793e022dc1b065b21f12d6df02f91bd.svg"})`);
let notes = {}; let notes = {};
switch (notespopout.querySelector(BDFDB.dotCN.tabbarheaderitem + BDFDB.dotCN.settingsitemselected).getAttribute("tab")) { switch (notespopout.querySelector(BDFDB.dotCN.tabbarheaderitem + BDFDB.dotCN.settingsitemselected).getAttribute("tab")) {
case "channel": case "channel":
@ -373,7 +371,7 @@ class PersonalPins {
} }
let noteArray = []; let noteArray = [];
for (let id in notes) {noteArray.push(notes[id]);} for (let id in notes) {noteArray.push(notes[id]);}
BDFDB.sortArrayByKey(noteArray, notespopout.querySelector(BDFDB.dotCN.recentmentionsmentionfiltervalue).getAttribute("option")); BDFDB.ArrayUtils.keySort(noteArray, notespopout.querySelector(BDFDB.dotCN.recentmentionsmentionfiltervalue).getAttribute("option"));
for (let noteData of noteArray) this.appendNote(notespopout, container, noteData, placeholder); for (let noteData of noteArray) this.appendNote(notespopout, container, noteData, placeholder);
let searchstring = notespopout.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, ""); let searchstring = notespopout.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "");
if (searchstring) for (let note of notespopout.querySelectorAll(BDFDB.dotCN.messagegroupwrapper)) { if (searchstring) for (let note of notespopout.querySelectorAll(BDFDB.dotCN.messagegroupwrapper)) {
@ -401,25 +399,25 @@ class PersonalPins {
container.insertBefore(messagedivider, container.firstChild); container.insertBefore(messagedivider, container.firstChild);
let channelname = messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname); let channelname = messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname);
channelname.innerText = (noteData.guild_id == "@me" ? " @" : " #") + (channel.name || noteData.channel_name); channelname.innerText = (noteData.guild_id == "@me" ? " @" : " #") + (channel.name || noteData.channel_name);
if (noteData.guild_id != "@me" && BDFDB.isPluginEnabled("EditChannels")) { if (noteData.guild_id != "@me" && BDFDB.BdUtils.isPluginEnabled("EditChannels")) {
BDFDB.getPlugin("EditChannels").changeChannel2({id:noteData.channel_id,name:noteData.channel_name}, channelname); BDFDB.BdUtils.getPlugin("EditChannels").changeChannel2({id:noteData.channel_id,name:noteData.channel_name}, channelname);
} }
else if (noteData.guild_id == "@me" && BDFDB.isPluginEnabled("EditUsers")) { else if (noteData.guild_id == "@me" && BDFDB.BdUtils.isPluginEnabled("EditUsers")) {
let dmuser_id = channel && channel.type == 1 ? channel.recipients[0] : noteData.dmuser_id; let dmuser_id = channel && channel.type == 1 ? channel.recipients[0] : noteData.dmuser_id;
if (dmuser_id) { if (dmuser_id) {
BDFDB.getPlugin("EditUsers").changeName2({id:dmuser_id,username:noteData.channel_name}, channelname); BDFDB.BdUtils.getPlugin("EditUsers").changeName2({id:dmuser_id,username:noteData.channel_name}, channelname);
if (channelname.innerText.indexOf("@") != 0) channelname.innerText = "@" + channelname.innerText; if (channelname.innerText.indexOf("@") != 0) channelname.innerText = "@" + channelname.innerText;
} }
} }
let guildname = messagedivider.querySelector(BDFDB.dotCN.messagespopoutguildname); let guildname = messagedivider.querySelector(BDFDB.dotCN.messagespopoutguildname);
guildname.innerText = server.name || noteData.guild_name; guildname.innerText = server.name || noteData.guild_name;
let avatar = message.querySelector(BDFDB.dotCN.avatar); let avatar = message.querySelector(BDFDB.dotCN.avatar);
avatar.setAttribute("src", `${user.id ? BDFDB.getUserAvatar(user.id) : noteData.avatar}`); avatar.setAttribute("src", `${user.id ? BDFDB.UserUtils.getAvatar(user.id) : noteData.avatar}`);
let username = message.querySelector(BDFDB.dotCN.messageusername); let username = message.querySelector(BDFDB.dotCN.messageusername);
username.innerText = user.username || noteData.author_name; username.innerText = user.username || noteData.author_name;
username.style.setProperty("color", member.colorString || noteData.color); username.style.setProperty("color", member.colorString || noteData.color);
if (BDFDB.isPluginEnabled("EditUsers")) { if (BDFDB.BdUtils.isPluginEnabled("EditUsers")) {
let EditUsers = BDFDB.getPlugin("EditUsers"); let EditUsers = BDFDB.BdUtils.getPlugin("EditUsers");
EditUsers.changeName({id:noteData.author_id,username:noteData.author_name}, username, noteData.guild_id); EditUsers.changeName({id:noteData.author_id,username:noteData.author_name}, username, noteData.guild_id);
if (user.id) EditUsers.changeAvatar({id:noteData.author_id,username:noteData.author_name}, avatar); if (user.id) EditUsers.changeAvatar({id:noteData.author_id,username:noteData.author_name}, avatar);
EditUsers.addTag({id:noteData.author_id,username:noteData.author_name}, username.parentElement, " " + BDFDB.disCN.bottagnametag); EditUsers.addTag({id:noteData.author_id,username:noteData.author_name}, username.parentElement, " " + BDFDB.disCN.bottagnametag);
@ -427,13 +425,13 @@ class PersonalPins {
let timestamp = message.querySelector(BDFDB.dotCN.messagetimestampcozy); let timestamp = message.querySelector(BDFDB.dotCN.messagetimestampcozy);
timestamp.innerText = date.toLocaleString(BDFDB.getDiscordLanguage().id); timestamp.innerText = date.toLocaleString(BDFDB.getDiscordLanguage().id);
timestamp.setAttribute("datetime", date); timestamp.setAttribute("datetime", date);
if (BDFDB.isPluginEnabled("CompleteTimestamps") && BDFDB.loadData("showInChat", "CompleteTimestamps", "settings")) { if (BDFDB.BdUtils.isPluginEnabled("CompleteTimestamps") && BDFDB.loadData("showInChat", "CompleteTimestamps", "settings")) {
BDFDB.getPlugin("CompleteTimestamps").changeTimestamp(timestamp); BDFDB.BdUtils.getPlugin("CompleteTimestamps").changeTimestamp(timestamp);
} }
message.querySelector(BDFDB.dotCN.messagemarkup).innerHTML = noteData.markup.replace(`<span class="edited">`,`<span class="${BDFDB.disCN.messageedited}">`); message.querySelector(BDFDB.dotCN.messagemarkup).innerHTML = noteData.markup.replace(`<span class="edited">`,`<span class="${BDFDB.disCN.messageedited}">`);
message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory; message.querySelector(BDFDB.dotCN.messageaccessory).innerHTML = noteData.accessory;
if (noteData.accessory) { if (noteData.accessory) {
BDFDB.addChildEventListener(message, "click", BDFDB.dotCN.iconplay, e => {this.startYoutubeVideo(e.currentTarget);}); BDFDB.ListenerUtils.addToChildren(message, "click", BDFDB.dotCN.iconplay, e => {this.startYoutubeVideo(e.currentTarget);});
let ytvideo = message.querySelector(BDFDB.dotCN.embed + " iframe[src*='https://www.youtube.com']"); let ytvideo = message.querySelector(BDFDB.dotCN.embed + " iframe[src*='https://www.youtube.com']");
if (ytvideo) { if (ytvideo) {
let ytlink = ytvideo.parentElement.parentElement.querySelector(BDFDB.dotCN.embedtitle).href; let ytlink = ytvideo.parentElement.parentElement.querySelector(BDFDB.dotCN.embedtitle).href;
@ -448,7 +446,7 @@ class PersonalPins {
} }
} }
messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname).addEventListener("click", e => { messagedivider.querySelector(BDFDB.dotCN.messagespopoutchannelname).addEventListener("click", e => {
if (!BDFDB.isObjectEmpty(channel)) { if (!BDFDB.ObjectUtils.isEmpty(channel)) {
notespopout.remove(); notespopout.remove();
BDFDB.LibraryModules.SelectChannelUtils.selectChannel(server.id, channel.id); BDFDB.LibraryModules.SelectChannelUtils.selectChannel(server.id, channel.id);
} }
@ -519,7 +517,7 @@ class PersonalPins {
channelname = channelname + BDFDB.LibraryModules.UserStore.getUser(dmuser_id).username; channelname = channelname + BDFDB.LibraryModules.UserStore.getUser(dmuser_id).username;
} }
} }
pins[guild_id][channel.id][message.id + "_" + pos] = BDFDB.sortObject({ pins[guild_id][channel.id][message.id + "_" + pos] = BDFDB.ObjectUtils.sort({
"guild_id": guild_id, "guild_id": guild_id,
"guild_name": guild.name ? guild.name : "Direct Messages", "guild_name": guild.name ? guild.name : "Direct Messages",
"channel_id": channel.id, "channel_id": channel.id,
@ -532,13 +530,13 @@ class PersonalPins {
"color": message.colorString, "color": message.colorString,
"author_id": message.author.id, "author_id": message.author.id,
"author_name": message.author.username, "author_name": message.author.username,
"avatar": BDFDB.getUserAvatar(message.author.id), "avatar": BDFDB.UserUtils.getAvatar(message.author.id),
"content": message.content, "content": message.content,
"markup": this.getMarkup(messagediv).innerHTML, "markup": this.getMarkup(messagediv).innerHTML,
"accessory": messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML "accessory": messagediv.querySelector(BDFDB.dotCN.messageaccessory).innerHTML
}); });
BDFDB.saveAllData(pins, this, "pins"); BDFDB.saveAllData(pins, this, "pins");
BDFDB.showToast(this.labels.toast_noteadd_text, {type:"success"}); BDFDB.NotificationUtils.toast(this.labels.toast_noteadd_text, {type:"success"});
} }
else this.removeNoteData(pins[guild_id][channel.id][message.id + "_" + pos]); else this.removeNoteData(pins[guild_id][channel.id][message.id + "_" + pos]);
} }
@ -547,9 +545,9 @@ class PersonalPins {
let pins = BDFDB.loadAllData(this, "pins"); let pins = BDFDB.loadAllData(this, "pins");
pins[note.guild_id][note.channel_id][note.id + "_" + note.pos].markup = markup; pins[note.guild_id][note.channel_id][note.id + "_" + note.pos].markup = markup;
pins[note.guild_id][note.channel_id][note.id + "_" + note.pos].accessory = accessory; pins[note.guild_id][note.channel_id][note.id + "_" + note.pos].accessory = accessory;
pins[note.guild_id][note.channel_id][note.id + "_" + note.pos] = BDFDB.sortObject(pins[note.guild_id][note.channel_id][note.id + "_" + note.pos]); pins[note.guild_id][note.channel_id][note.id + "_" + note.pos] = BDFDB.ObjectUtils.sort(pins[note.guild_id][note.channel_id][note.id + "_" + note.pos]);
BDFDB.saveAllData(pins, this, "pins"); BDFDB.saveAllData(pins, this, "pins");
BDFDB.showToast(this.labels.toast_noteupdate_text, {type:"info"}); BDFDB.NotificationUtils.toast(this.labels.toast_noteupdate_text, {type:"info"});
} }
getMarkup (messagediv) { getMarkup (messagediv) {
@ -571,12 +569,12 @@ class PersonalPins {
removeNoteData (noteData) { removeNoteData (noteData) {
let pins = BDFDB.loadAllData(this, "pins"); let pins = BDFDB.loadAllData(this, "pins");
delete pins[noteData.guild_id][noteData.channel_id][noteData.id + "_" + noteData.pos]; delete pins[noteData.guild_id][noteData.channel_id][noteData.id + "_" + noteData.pos];
if (BDFDB.isObjectEmpty(pins[noteData.guild_id][noteData.channel_id])) { if (BDFDB.ObjectUtils.isEmpty(pins[noteData.guild_id][noteData.channel_id])) {
delete pins[noteData.guild_id][noteData.channel_id]; delete pins[noteData.guild_id][noteData.channel_id];
if (BDFDB.isObjectEmpty(pins[noteData.guild_id])) delete pins[noteData.guild_id]; if (BDFDB.ObjectUtils.isEmpty(pins[noteData.guild_id])) delete pins[noteData.guild_id];
} }
BDFDB.saveAllData(pins, this, "pins"); BDFDB.saveAllData(pins, this, "pins");
BDFDB.showToast(this.labels.toast_noteremove_text, {type:"danger"}); BDFDB.NotificationUtils.toast(this.labels.toast_noteremove_text, {type:"danger"});
} }
getMessageAndPos (target) { getMessageAndPos (target) {

View File

@ -122,7 +122,7 @@ class PinDMs {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to unpin all pinned DMs?", () => { BDFDB.openConfirmModal(this, "Are you sure you want to unpin all pinned DMs?", () => {
BDFDB.removeAllData(this, "pinnedDMs"); BDFDB.removeAllData(this, "pinnedDMs");
BDFDB.removeAllData(this, "pinnedRecents"); BDFDB.removeAllData(this, "pinnedRecents");
@ -155,22 +155,20 @@ class PinDMs {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.forceAdding = true; this.forceAdding = true;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
delete this.forceAdding; delete this.forceAdding;
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller)); let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
if (dmsscrollerinstance) { if (dmsscrollerinstance) {
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children; let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
let amount = 0; let amount = 0;
@ -180,7 +178,7 @@ class PinDMs {
if (ele && ele.pinned) { if (ele && ele.pinned) {
delete ele.pinned; delete ele.pinned;
if (ele.props.ispin) { if (ele.props.ispin) {
if (ele && ele.type == "header" || BDFDB.getReactValue(ele, "type.displayName") == "ListSectionItem") insertpoint = i; if (ele && ele.type == "header" || BDFDB.ReactUtils.getValue(ele, "type.displayName") == "ListSectionItem") insertpoint = i;
amount++; amount++;
} }
} }
@ -189,13 +187,13 @@ class PinDMs {
this.forceUpdateScroller(dmsscrollerinstance.stateNode); this.forceUpdateScroller(dmsscrollerinstance.stateNode);
} }
for (let info of BDFDB.readDmList()) { for (let info of BDFDB.DmUtils.getAll()) {
this.unhideNativeDM(info.id); this.unhideNativeDM(info.id);
if (info.div) info.div.removeEventListener("contextmenu", info.div.PinDMsContextMenuListener); if (info.div) info.div.removeEventListener("contextmenu", info.div.PinDMsContextMenuListener);
} }
BDFDB.removeEles(".pinned-dm", ".dmplaceholder", ".pindms-dragpreview"); BDFDB.removeEles(".pinned-dm", ".dmplaceholder", ".pindms-dragpreview");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -212,7 +210,7 @@ class PinDMs {
if (index > -1) { if (index > -1) {
let id = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(instance.props.user.id); let id = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(instance.props.user.id);
if (id) this.appendItem(menu, id, children, index); if (id) this.appendItem(menu, id, children, index);
else BDFDB.LibraryModules.DirectMessageUtils.ensurePrivateChannel(BDFDB.myData.id, instance.props.user.id).then(id => {this.appendItem(menu, id, children, index);}); else BDFDB.LibraryModules.DirectMessageUtils.ensurePrivateChannel(BDFDB.UserUtils.me.id, instance.props.user.id).then(id => {this.appendItem(menu, id, children, index);});
} }
} }
} }
@ -228,14 +226,14 @@ class PinDMs {
let pinnedInChannel = BDFDB.loadAllData(this, "pinnedDMs")[id] != undefined; let pinnedInChannel = BDFDB.loadAllData(this, "pinnedDMs")[id] != undefined;
let pinnedInGuild = BDFDB.loadAllData(this, "pinnedRecents")[id] != undefined; let pinnedInGuild = BDFDB.loadAllData(this, "pinnedRecents")[id] != undefined;
let items = []; let items = [];
items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels[pinnedInChannel ? "context_unpinchannel_text" : "context_pinchannel_text"], label: this.labels[pinnedInChannel ? "context_unpinchannel_text" : "context_pinchannel_text"],
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInChannel ? "unpin" : "pin"}channel-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInChannel ? "unpin" : "pin"}channel-contextMenuItem`,
danger: pinnedInChannel, danger: pinnedInChannel,
action: e => { action: e => {
BDFDB.closeContextMenu(menu); BDFDB.closeContextMenu(menu);
if (!pinnedInChannel) { if (!pinnedInChannel) {
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller)); let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
if (dmsscrollerinstance) { if (dmsscrollerinstance) {
let dms = dmsscrollerinstance.return.return.return.stateNode.props.children; let dms = dmsscrollerinstance.return.return.return.stateNode.props.children;
let insertpoint = this.getInsertPoint(dms); let insertpoint = this.getInsertPoint(dms);
@ -249,7 +247,7 @@ class PinDMs {
} }
} }
})); }));
items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels[pinnedInGuild ? "context_unpinguild_text" : "context_pinguild_text"], label: this.labels[pinnedInGuild ? "context_unpinguild_text" : "context_pinguild_text"],
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInGuild ? "unpin" : "pin"}guild-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInGuild ? "unpin" : "pin"}guild-contextMenuItem`,
danger: pinnedInGuild, danger: pinnedInGuild,
@ -267,7 +265,7 @@ class PinDMs {
} }
} }
})); }));
const subitem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { const subitem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_pindm_text, label: this.labels.context_pindm_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-pindm-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-pindm-contextMenuSubItem`,
render: items render: items
@ -281,10 +279,10 @@ class PinDMs {
processPrivateChannel (instance, wrapper, returnvalue) { processPrivateChannel (instance, wrapper, returnvalue) {
if (instance && instance.props && instance.props.ispin) { if (instance && instance.props && instance.props.ispin) {
let id = BDFDB.getReactValue(instance, "props.channel.id"); let id = BDFDB.ReactUtils.getValue(instance, "props.channel.id");
wrapper.setAttribute("channelid", id); wrapper.setAttribute("channelid", id);
BDFDB.addClass(wrapper, "pinned"); BDFDB.addClass(wrapper, "pinned");
BDFDB.removeClass(BDFDB.getChannelDiv(id), BDFDB.disCN.namecontainerselected); BDFDB.removeClass(BDFDB.ChannelUtils.getDiv(id), BDFDB.disCN.namecontainerselected);
(wrapper.querySelector("a") || wrapper).setAttribute("draggable", false); (wrapper.querySelector("a") || wrapper).setAttribute("draggable", false);
wrapper.addEventListener("click", e => { wrapper.addEventListener("click", e => {
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller); let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
@ -294,7 +292,7 @@ class PinDMs {
} }
}); });
wrapper.querySelector(BDFDB.dotCN.dmchannelclose).addEventListener("click", e => { wrapper.querySelector(BDFDB.dotCN.dmchannelclose).addEventListener("click", e => {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
this.removePinnedDM(id); this.removePinnedDM(id);
}); });
wrapper.addEventListener("mousedown", e => { wrapper.addEventListener("mousedown", e => {
@ -345,10 +343,10 @@ class PinDMs {
wrapper.removeEventListener("contextmenu", wrapper.PinDMsContextMenuListener); wrapper.removeEventListener("contextmenu", wrapper.PinDMsContextMenuListener);
wrapper.PinDMsContextMenuListener = e => { wrapper.PinDMsContextMenuListener = e => {
if (BDFDB.loadAllData(this, "pinnedRecents")[instance.props.channel.id] == undefined) { if (BDFDB.loadAllData(this, "pinnedRecents")[instance.props.channel.id] == undefined) {
const itemGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_pinguild_text, label: this.labels.context_pinguild_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pinguild-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pinguild-contextMenuItem`,
action: e => { action: e => {
@ -376,7 +374,7 @@ class PinDMs {
} }
processLazyScroller (instance, wrapper, returnvalue) { processLazyScroller (instance, wrapper, returnvalue) {
let privateChannelIds = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.privateChannelIds"); let privateChannelIds = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.privateChannelIds");
if (privateChannelIds) { if (privateChannelIds) {
if (this.forceAdding || !instance.props.PinDMsPatched) { if (this.forceAdding || !instance.props.PinDMsPatched) {
instance.props.PinDMsPatched = true; instance.props.PinDMsPatched = true;
@ -403,7 +401,7 @@ class PinDMs {
let insertpoint = null; let insertpoint = null;
for (let i in dms) { for (let i in dms) {
let ele = dms[i]; let ele = dms[i];
if (ele && ele.type == "header" || BDFDB.getReactValue(ele, "type.displayName") == "ListSectionItem") { if (ele && ele.type == "header" || BDFDB.ReactUtils.getValue(ele, "type.displayName") == "ListSectionItem") {
insertpoint = parseInt(i); insertpoint = parseInt(i);
if (!ele.pinned && !ele.props.ispin) { if (!ele.pinned && !ele.props.ispin) {
ele.pinned = true; ele.pinned = true;
@ -438,7 +436,7 @@ class PinDMs {
} }
BDFDB.removeData(id, this, "pinnedDMs"); BDFDB.removeData(id, this, "pinnedDMs");
this.updatePinnedPositions("pinnedDMs"); this.updatePinnedPositions("pinnedDMs");
let dmsscrollerinstance = BDFDB.getReactInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller)); let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
if (dmsscrollerinstance) { if (dmsscrollerinstance) {
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children; let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
let existingDMs = this.sortAndUpdate("pinnedDMs"); let existingDMs = this.sortAndUpdate("pinnedDMs");
@ -476,11 +474,11 @@ class PinDMs {
forceUpdateScroller (scroller) { forceUpdateScroller (scroller) {
if (this.updatingScroller) return; if (this.updatingScroller) return;
var stateNode = BDFDB.getReactValue(scroller, "return.return.return.stateNode"); var stateNode = BDFDB.ReactUtils.getValue(scroller, "return.return.return.stateNode");
if (stateNode) { if (stateNode) {
this.updatingScroller = true; this.updatingScroller = true;
BDFDB.React.forceUpdate(stateNode); BDFDB.ReactUtils.forceUpdate(stateNode);
setTimeout(() => {BDFDB.React.forceUpdate(stateNode);},500); setTimeout(() => {BDFDB.ReactUtils.forceUpdate(stateNode);},500);
setTimeout(() => {delete this.updatingScroller;},1000); setTimeout(() => {delete this.updatingScroller;},1000);
} }
} }
@ -508,28 +506,28 @@ class PinDMs {
dmname = dmname + BDFDB.LibraryModules.UserStore.getUser(dmuser_id).username; dmname = dmname + BDFDB.LibraryModules.UserStore.getUser(dmuser_id).username;
} }
} }
let EditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? BDFDB.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {}; let EditUsersData = user && BDFDB.BdUtils.isPluginEnabled("EditUsers") ? BDFDB.BdUtils.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {};
if (!EditUsersData.removeIcon) avatar.setAttribute("src", `${EditUsersData.url || BDFDB.getChannelIcon(id)}`); if (!EditUsersData.removeIcon) avatar.setAttribute("src", `${EditUsersData.url || BDFDB.DmUtils.getIcon(id)}`);
avatar.setAttribute("channel", dmname); avatar.setAttribute("channel", dmname);
if (user) avatar.setAttribute("user", user.username); if (user) avatar.setAttribute("user", user.username);
dmdivinner.addEventListener("mouseenter", () => { dmdivinner.addEventListener("mouseenter", () => {
let FreshEditUsersData = user && BDFDB.isPluginEnabled("EditUsers") ? BDFDB.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {}; let FreshEditUsersData = user && BDFDB.BdUtils.isPluginEnabled("EditUsers") ? BDFDB.BdUtils.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {};
BDFDB.createTooltip(FreshEditUsersData.name || dmname, dmdivinner, {selector:(BDFDB.isObjectEmpty(FreshEditUsersData) ? "" : "EditUsers-tooltip"),type:"right"}); BDFDB.TooltipUtils.create(dmdivinner, FreshEditUsersData.name || dmname, {selector:(BDFDB.ObjectUtils.isEmpty(FreshEditUsersData) ? "" : "EditUsers-tooltip"),type:"right"});
}); });
avatar.parentElement.addEventListener("click", e => { avatar.parentElement.addEventListener("click", e => {
if (user) { if (user) {
let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id) let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id)
if (DMid) BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid); if (DMid) BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid);
else BDFDB.LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.myData.id, user.id); else BDFDB.LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.UserUtils.me.id, user.id);
} }
else BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(id); else BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(id);
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
}); });
avatar.parentElement.addEventListener("contextmenu", e => { avatar.parentElement.addEventListener("contextmenu", e => {
const itemGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_unpinguild_text, label: this.labels.context_unpinguild_text,
danger: true, danger: true,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-unpinguild-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-unpinguild-contextMenuItem`,
@ -626,7 +624,7 @@ class PinDMs {
let count = BDFDB.LibraryModules.UnreadChannelUtils.getUnreadCount(id); let count = BDFDB.LibraryModules.UnreadChannelUtils.getUnreadCount(id);
let showpin = BDFDB.getData("showPinIcon", this, "settings"); let showpin = BDFDB.getData("showPinIcon", this, "settings");
let dmdiv = BDFDB.getDmDiv(id); let dmdiv = BDFDB.DmUtils.getDiv(id);
let pinneddmiconwrapper = pinneddmdiv.querySelector(BDFDB.dotCN.guildiconwrapper); let pinneddmiconwrapper = pinneddmdiv.querySelector(BDFDB.dotCN.guildiconwrapper);
let pinneddmdivpill = pinneddmdiv.querySelector(BDFDB.dotCN.guildpillitem); let pinneddmdivpill = pinneddmdiv.querySelector(BDFDB.dotCN.guildpillitem);
let iconbadge = pinneddmdiv.querySelector(BDFDB.dotCN.guildupperbadge); let iconbadge = pinneddmdiv.querySelector(BDFDB.dotCN.guildupperbadge);
@ -656,7 +654,7 @@ class PinDMs {
} }
hideNativeDM (id) { hideNativeDM (id) {
let dmdiv = BDFDB.getDmDiv(id); let dmdiv = BDFDB.DmUtils.getDiv(id);
if (Node.prototype.isPrototypeOf(dmdiv)) { if (Node.prototype.isPrototypeOf(dmdiv)) {
BDFDB.toggleEles(dmdiv, false); BDFDB.toggleEles(dmdiv, false);
BDFDB.addClass(dmdiv, "hidden-by-pin"); BDFDB.addClass(dmdiv, "hidden-by-pin");
@ -664,7 +662,7 @@ class PinDMs {
} }
unhideNativeDM (id) { unhideNativeDM (id) {
let dmdiv = BDFDB.getDmDiv(id); let dmdiv = BDFDB.DmUtils.getDiv(id);
if (Node.prototype.isPrototypeOf(dmdiv) && BDFDB.containsClass(dmdiv, "hidden-by-pin")) { if (Node.prototype.isPrototypeOf(dmdiv) && BDFDB.containsClass(dmdiv, "hidden-by-pin")) {
BDFDB.toggleEles(dmdiv, true); BDFDB.toggleEles(dmdiv, true);
BDFDB.removeClass(dmdiv, "hidden-by-pin"); BDFDB.removeClass(dmdiv, "hidden-by-pin");

View File

@ -263,11 +263,11 @@ class PluginRepo {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-addplugin", () => {this.addPluginToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", "#input-pluginurl", e => {if (e.which == 13) this.addPluginToOwnList(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", "#input-pluginurl", e => {if (e.which == 13) this.addPluginToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);}) BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);})
BDFDB.addEventListener(this, settingspanel, "click", ".refresh-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".refresh-button", () => {
this.loading = {is:false, timeout:null, amount:0}; this.loading = {is:false, timeout:null, amount:0};
this.loadPlugins(); this.loadPlugins();
}); });
@ -299,17 +299,15 @@ class PluginRepo {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.loadPlugins(); this.loadPlugins();
this.updateInterval = setInterval(() => {this.checkForNewPlugins();},1000*60*30); this.updateInterval = setInterval(() => {this.checkForNewPlugins();},1000*60*30);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -328,7 +326,7 @@ class PluginRepo {
frame.remove(); frame.remove();
} }
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -337,7 +335,7 @@ class PluginRepo {
onUserSettingsCogContextMenu (instance, menu, returnvalue) { onUserSettingsCogContextMenu (instance, menu, returnvalue) {
setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) { setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
const repoItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: "Plugin Repo", label: "Plugin Repo",
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`,
action: e => { action: e => {
@ -359,7 +357,7 @@ class PluginRepo {
this.openPluginRepoModal() this.openPluginRepoModal()
}); });
repoButton.addEventListener("mouseenter", () => { repoButton.addEventListener("mouseenter", () => {
BDFDB.createTooltip("Open Plugin Repo", repoButton, {type:"top",selector:"pluginrepo-button-tooltip"}); BDFDB.TooltipUtils.create(repoButton, "Open Plugin Repo", {type:"top",selector:"pluginrepo-button-tooltip"});
}); });
folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling); folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling);
} }
@ -377,7 +375,7 @@ class PluginRepo {
ownlist.push(url); ownlist.push(url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-plugin"></div></div>`); let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-plugin"></div></div>`);
BDFDB.addChildEventListener(entry, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);}); BDFDB.ListenerUtils.addToChildren(entry, "click", ".remove-plugin", e => {this.removePluginFromOwnList(e);});
pluginList.appendChild(entry); pluginList.appendChild(entry);
} }
} }
@ -388,7 +386,7 @@ class PluginRepo {
var url = entry.querySelector(".entryurl").textContent; var url = entry.querySelector(".entryurl").textContent;
entry.remove(); entry.remove();
var ownlist = BDFDB.loadData("ownlist", this, "ownlist") || []; var ownlist = BDFDB.loadData("ownlist", this, "ownlist") || [];
BDFDB.removeFromArray(ownlist, url); BDFDB.ArrayUtils.remove(ownlist, url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
} }
@ -401,7 +399,7 @@ class PluginRepo {
openPluginRepoModal (options = {}) { openPluginRepoModal (options = {}) {
if (this.loading.is) { if (this.loading.is) {
BDFDB.showToast(`Plugins are still being fetched. Try again in some seconds.`, {type:"danger"}); BDFDB.NotificationUtils.toast(`Plugins are still being fetched. Try again in some seconds.`, {type:"danger"});
return; return;
} }
@ -412,7 +410,7 @@ class PluginRepo {
pluginRepoModal.querySelector("#input-hideupdated").checked = hiddenSettings.updated || options.showOnlyOutdated; pluginRepoModal.querySelector("#input-hideupdated").checked = hiddenSettings.updated || options.showOnlyOutdated;
pluginRepoModal.querySelector("#input-hideoutdated").checked = hiddenSettings.outdated && !options.showOnlyOutdated; pluginRepoModal.querySelector("#input-hideoutdated").checked = hiddenSettings.outdated && !options.showOnlyOutdated;
pluginRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || options.showOnlyOutdated; pluginRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || options.showOnlyOutdated;
if (!BDFDB.isRestartNoMoreEnabled()) pluginRepoModal.querySelector("#RNMoption").remove(); if (!BDFDB.BdUtils.isAutoLoadEnabled()) pluginRepoModal.querySelector("#RNMoption").remove();
else pluginRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "RNMstart"); else pluginRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "RNMstart");
if (options.forcedSort && this.sortings.sort[options.forcedSort]) { if (options.forcedSort && this.sortings.sort[options.forcedSort]) {
@ -426,28 +424,28 @@ class PluginRepo {
orderinput.setAttribute('option', options.forcedOrder); orderinput.setAttribute('option', options.forcedOrder);
} }
BDFDB.addChildEventListener(pluginRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => {
clearTimeout(pluginRepoModal.searchTimeout); clearTimeout(pluginRepoModal.searchTimeout);
pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000); pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000);
}); });
BDFDB.addChildEventListener(pluginRepoModal, "click", BDFDB.dotCN.searchbarclear, () => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "click", BDFDB.dotCN.searchbarclear, () => {
clearTimeout(pluginRepoModal.searchTimeout); clearTimeout(pluginRepoModal.searchTimeout);
pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000); pluginRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(pluginRepoModal);},1000);
}); });
BDFDB.addChildEventListener(pluginRepoModal, "change", ".hide-checkbox", e => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "change", ".hide-checkbox", e => {
pluginRepoModal.updateHidden = true; pluginRepoModal.updateHidden = true;
BDFDB.saveData(e.currentTarget.value, e.currentTarget.checked, this, "hidden"); BDFDB.saveData(e.currentTarget.value, e.currentTarget.checked, this, "hidden");
}); });
BDFDB.addChildEventListener(pluginRepoModal, "change", "#input-rnmstart", e => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "change", "#input-rnmstart", e => {
BDFDB.saveData("RNMstart", e.currentTarget.checked, this, "RNMstart"); BDFDB.saveData("RNMstart", e.currentTarget.checked, this, "RNMstart");
}); });
BDFDB.addChildEventListener(pluginRepoModal, "click", ".sort-filter", e => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "click", ".sort-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.sortEntries(pluginRepoModal);}); BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.sortEntries(pluginRepoModal);});
}); });
BDFDB.addChildEventListener(pluginRepoModal, "click", ".order-filter", e => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "click", ".order-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(pluginRepoModal);}); BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(pluginRepoModal);});
}); });
BDFDB.addChildEventListener(pluginRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=plugins]", e => { BDFDB.ListenerUtils.addToChildren(pluginRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=plugins]", e => {
if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected) && pluginRepoModal.updateHidden) { if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected) && pluginRepoModal.updateHidden) {
delete pluginRepoModal.updateHidden; delete pluginRepoModal.updateHidden;
this.sortEntries(pluginRepoModal); this.sortEntries(pluginRepoModal);
@ -459,7 +457,7 @@ class PluginRepo {
pluginRepoModal.entries = {}; pluginRepoModal.entries = {};
for (let url in this.loadedPlugins) { for (let url in this.loadedPlugins) {
let plugin = this.loadedPlugins[url]; let plugin = this.loadedPlugins[url];
let instPlugin = BDFDB.getPlugin(plugin.getName); let instPlugin = BDFDB.BdUtils.getPlugin(plugin.getName);
if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase()) plugin.getState = this.getString(instPlugin.getVersion()) != plugin.getVersion ? 1 : 0; if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase()) plugin.getState = this.getString(instPlugin.getVersion()) != plugin.getVersion ? 1 : 0;
else plugin.getState = 2; else plugin.getState = 2;
let data = { let data = {
@ -518,18 +516,18 @@ class PluginRepo {
if (giturl) window.open(giturl, "_blank"); if (giturl) window.open(giturl, "_blank");
}); });
gitbutton.addEventListener("mouseenter", e => { gitbutton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Go to Git", gitbutton, {type:"top",selector:"pluginrepo-giticon-tooltip"}); BDFDB.TooltipUtils.create(gitbutton, "Go to Git", {type:"top",selector:"pluginrepo-giticon-tooltip"});
}); });
let trashbutton = entry.querySelector(".trashIcon"); let trashbutton = entry.querySelector(".trashIcon");
trashbutton.addEventListener("click", e => { trashbutton.addEventListener("click", e => {
if (BDFDB.containsClass(entry, "outdated", "updated", false)) { if (BDFDB.containsClass(entry, "outdated", "updated", false)) {
setEntryState(2); setEntryState(2);
this.deletePluginFile(data); this.deletePluginFile(data);
if (!BDFDB.isRestartNoMoreEnabled()) this.stopPlugin(data); if (!BDFDB.BdUtils.isAutoLoadEnabled()) this.stopPlugin(data);
} }
}); });
trashbutton.addEventListener("mouseenter", e => { trashbutton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Delete Pluginfile", trashbutton, {type:"top",selector:"pluginrepo-trashicon-tooltip"}); BDFDB.TooltipUtils.create(trashbutton, "Delete Pluginfile", {type:"top",selector:"pluginrepo-trashicon-tooltip"});
}); });
entry.querySelector(".btn-download").addEventListener("click", e => { entry.querySelector(".btn-download").addEventListener("click", e => {
setEntryState(0); setEntryState(0);
@ -560,14 +558,14 @@ class PluginRepo {
let searchstring = pluginRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase(); let searchstring = pluginRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
let entries = pluginRepoModal.entries; let entries = pluginRepoModal.entries;
if (pluginRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state < 1 ? null : entry;}); if (pluginRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state < 1 ? null : entry;});
if (pluginRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state == 1 ? null : entry;}); if (pluginRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state == 1 ? null : entry;});
if (pluginRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state > 1 ? null : entry;}); if (pluginRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state > 1 ? null : entry;});
entries = BDFDB.filterObject(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;}); entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
let sortfilter = pluginRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option"); let sortfilter = pluginRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option");
entries = BDFDB.sortObject(entries, sortfilter == "new" && !pluginRepoModal.querySelector(".newentries-tag") ? "name" : sortfilter); entries = BDFDB.ObjectUtils.sort(entries, sortfilter == "new" && !pluginRepoModal.querySelector(".newentries-tag") ? "name" : sortfilter);
if (pluginRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.reverseObject(entries); if (pluginRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.ObjectUtils.reverse(entries);
let entrypositions = Object.keys(entries); let entrypositions = Object.keys(entries);
@ -616,7 +614,9 @@ class PluginRepo {
} }
var loadingicon = BDFDB.htmlToElement(this.pluginRepoIconMarkup); var loadingicon = BDFDB.htmlToElement(this.pluginRepoIconMarkup);
BDFDB.addClass(loadingicon, "pluginrepo-loadingicon"); BDFDB.addClass(loadingicon, "pluginrepo-loadingicon");
loadingicon.addEventListener("mouseenter", () => {BDFDB.createTooltip(this.getLoadingTooltipText(),loadingicon,{type:"left",delay:500,style:"max-width:unset;",selector:"pluginrepo-loading-tooltip"});}) loadingicon.addEventListener("mouseenter", () => {
BDFDB.TooltipUtils.create(loadingicon, this.getLoadingTooltipText(), {type:"left", delay:500, style:"max-width:unset;", selector:"pluginrepo-loading-tooltip"});
});
loadingiconwrapper.appendChild(loadingicon); loadingiconwrapper.appendChild(loadingicon);
createFrame().then(() => { createFrame().then(() => {
@ -636,11 +636,11 @@ class PluginRepo {
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
this.loading = {is:false, timeout:null, amount:this.loading.amount}; this.loading = {is:false, timeout:null, amount:this.loading.amount};
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Plugins."); console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Plugins.");
if (document.querySelector(".bd-pluginrepobutton")) BDFDB.showToast(`Finished fetching Plugins.`, {type:"success"}); if (document.querySelector(".bd-pluginrepobutton")) BDFDB.NotificationUtils.toast(`Finished fetching Plugins.`, {type:"success"});
if ((settings.notifyOutdated || settings.notifyOutdated == undefined) && outdated > 0) { if ((settings.notifyOutdated || settings.notifyOutdated == undefined) && outdated > 0) {
var oldbarbutton = document.querySelector(".pluginrepo-outdate-notice " + BDFDB.dotCN.noticedismiss); var oldbarbutton = document.querySelector(".pluginrepo-outdate-notice " + BDFDB.dotCN.noticedismiss);
if (oldbarbutton) oldbarbutton.click(); if (oldbarbutton) oldbarbutton.click();
var bar = BDFDB.createNotificationsBar(`${outdated} of your Plugins ${outdated == 1 ? "is" : "are"} outdated. Check:`,{type:"danger",btn:"PluginRepo",selector:"pluginrepo-notice pluginrepo-outdate-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`${outdated} of your Plugins ${outdated == 1 ? "is" : "are"} outdated. Check:`,{type:"danger",btn:"PluginRepo",selector:"pluginrepo-notice pluginrepo-outdate-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
this.openPluginRepoModal({showOnlyOutdated:true}); this.openPluginRepoModal({showOnlyOutdated:true});
bar.querySelector(BDFDB.dotCN.noticedismiss).click(); bar.querySelector(BDFDB.dotCN.noticedismiss).click();
@ -649,19 +649,19 @@ class PluginRepo {
if ((settings.notifyNewentries || settings.notifyNewentries == undefined) && newentries > 0) { if ((settings.notifyNewentries || settings.notifyNewentries == undefined) && newentries > 0) {
var oldbarbutton = document.querySelector(".pluginrepo-newentries-notice " + BDFDB.dotCN.noticedismiss); var oldbarbutton = document.querySelector(".pluginrepo-newentries-notice " + BDFDB.dotCN.noticedismiss);
if (oldbarbutton) oldbarbutton.click(); if (oldbarbutton) oldbarbutton.click();
var bar = BDFDB.createNotificationsBar(`There ${newentries == 1 ? "is" : "are"} ${newentries} new Plugin${newentries == 1 ? "" : "s"} in the Repo. Check:`,{type:"success",btn:"PluginRepo",selector:"pluginrepo-notice pluginrepo-newentries-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`There ${newentries == 1 ? "is" : "are"} ${newentries} new Plugin${newentries == 1 ? "" : "s"} in the Repo. Check:`,{type:"success",btn:"PluginRepo",selector:"pluginrepo-notice pluginrepo-newentries-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
this.openPluginRepoModal({forcedSort:"new",forcedOrder:"asc"}); this.openPluginRepoModal({forcedSort:"new",forcedOrder:"asc"});
bar.querySelector(BDFDB.dotCN.noticedismiss).click(); bar.querySelector(BDFDB.dotCN.noticedismiss).click();
}); });
} }
if (BDFDB.myData.id == "278543574059057154") { if (BDFDB.UserUtils.me.id == "278543574059057154") {
let wrongUrls = []; let wrongUrls = [];
for (let url of this.foundPlugins) if (url && !this.loadedPlugins[url] && !wrongUrls.includes(url)) wrongUrls.push(url); for (let url of this.foundPlugins) if (url && !this.loadedPlugins[url] && !wrongUrls.includes(url)) wrongUrls.push(url);
if (wrongUrls.length > 0) { if (wrongUrls.length > 0) {
var bar = BDFDB.createNotificationsBar(`PluginRepo: ${wrongUrls.length} Plugin${wrongUrls.length > 1 ? "s" : ""} could not be loaded.`, {type:"danger",btn:"List",selector:"pluginrepo-notice pluginrepo-fail-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`PluginRepo: ${wrongUrls.length} Plugin${wrongUrls.length > 1 ? "s" : ""} could not be loaded.`, {type:"danger",btn:"List",selector:"pluginrepo-notice pluginrepo-fail-notice", customicon:this.pluginRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
var toast = BDFDB.showToast(wrongUrls.join("\n"),{type:"error"}); var toast = BDFDB.NotificationUtils.toast(wrongUrls.join("\n"),{type:"error"});
toast.style.overflow = "hidden"; toast.style.overflow = "hidden";
console.log(wrongUrls.length == 1 ? wrongUrls[0] : wrongUrls); console.log(wrongUrls.length == 1 ? wrongUrls[0] : wrongUrls);
}); });
@ -683,7 +683,7 @@ class PluginRepo {
let url = this.foundPlugins[i]; let url = this.foundPlugins[i];
BDFDB.LibraryRequires.request(url, (error, response, body) => { BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (!response) { if (!response) {
if (url && BDFDB.getAllIndexes(this.foundPlugins, url).length < 2) this.foundPlugins.push(url); if (url && BDFDB.ArrayUtils.getAllIndexes(this.foundPlugins, url).length < 2) this.foundPlugins.push(url);
} }
else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
let plugin = {}; let plugin = {};
@ -728,7 +728,7 @@ class PluginRepo {
if (valid) { if (valid) {
plugin.url = url; plugin.url = url;
this.loadedPlugins[url] = plugin; this.loadedPlugins[url] = plugin;
let instPlugin = BDFDB.getPlugin(plugin.getName); let instPlugin = BDFDB.BdUtils.getPlugin(plugin.getName);
if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase() && this.getString(instPlugin.getVersion()) != plugin.getVersion && PluginUpdates && PluginUpdates.plugins && !PluginUpdates.plugins[url]) outdated++; if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase() && this.getString(instPlugin.getVersion()) != plugin.getVersion && PluginUpdates && PluginUpdates.plugins && !PluginUpdates.plugins[url]) outdated++;
if (!this.cachedPlugins.includes(url)) newentries++; if (!this.cachedPlugins.includes(url)) newentries++;
} }
@ -741,7 +741,7 @@ class PluginRepo {
var loadingtooltip = document.querySelector(".pluginrepo-loading-tooltip"); var loadingtooltip = document.querySelector(".pluginrepo-loading-tooltip");
if (loadingtooltip) { if (loadingtooltip) {
BDFDB.setInnerText(loadingtooltip, this.getLoadingTooltipText()); BDFDB.setInnerText(loadingtooltip, this.getLoadingTooltipText());
BDFDB.updateTooltipPosition(loadingtooltip); BDFDB.TooltipUtils.update(loadingtooltip);
} }
getPluginInfo(callback); getPluginInfo(callback);
}); });
@ -783,10 +783,10 @@ class PluginRepo {
if (name.length > 1) { if (name.length > 1) {
name = name[1].split('"')[0]; name = name[1].split('"')[0];
var processResult = plugin => { var processResult = plugin => {
if (BDFDB.isObject(plugin)) { if (BDFDB.ObjectUtils.is(plugin)) {
plugin.url = url; plugin.url = url;
this.loadedPlugins[url] = plugin; this.loadedPlugins[url] = plugin;
let instPlugin = BDFDB.getPlugin(plugin.getName); let instPlugin = BDFDB.BdUtils.getPlugin(plugin.getName);
if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase() && this.getString(instPlugin.getVersion()) != plugin.getVersion) outdated++; if (instPlugin && this.getString(instPlugin.getAuthor()).toUpperCase() == plugin.getAuthor.toUpperCase() && this.getString(instPlugin.getVersion()) != plugin.getVersion) outdated++;
if (!this.cachedPlugins.includes(url)) newentries++; if (!this.cachedPlugins.includes(url)) newentries++;
} }
@ -849,20 +849,20 @@ class PluginRepo {
downloadPlugin (data) { downloadPlugin (data) {
BDFDB.LibraryRequires.request(data.url, (error, response, body) => { BDFDB.LibraryRequires.request(data.url, (error, response, body) => {
if (error) BDFDB.showToast(`Unable to download Plugin "${plugin.getName}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to download Plugin "${plugin.getName}".`, {type:"danger"});
else this.createPluginFile(data.url.split("/").pop(), body); else this.createPluginFile(data.url.split("/").pop(), body);
}); });
} }
createPluginFile (filename, content) { createPluginFile (filename, content) {
BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.getPluginsFolder(), filename), content, (error) => { BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BdUtils.getPluginsFolder(), filename), content, (error) => {
if (error) BDFDB.showToast(`Unable to save Plugin "${filename}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to save Plugin "${filename}".`, {type:"danger"});
else BDFDB.showToast(`Successfully saved Plugin "${filename}".`, {type:"success"}); else BDFDB.NotificationUtils.toast(`Successfully saved Plugin "${filename}".`, {type:"success"});
}); });
} }
startPlugin (data) { startPlugin (data) {
if (BDFDB.isPluginEnabled(data.name) == false) { if (BDFDB.BdUtils.isPluginEnabled(data.name) == false) {
window.pluginModule.startPlugin(data.name); window.pluginModule.startPlugin(data.name);
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Started Plugin " + data.name + "."); console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Started Plugin " + data.name + ".");
} }
@ -870,14 +870,14 @@ class PluginRepo {
deletePluginFile (data) { deletePluginFile (data) {
let filename = data.url.split("/").pop(); let filename = data.url.split("/").pop();
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.getPluginsFolder(), filename), (error) => { BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BdUtils.getPluginsFolder(), filename), (error) => {
if (error) BDFDB.showToast(`Unable to delete Plugin "${filename}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to delete Plugin "${filename}".`, {type:"danger"});
else BDFDB.showToast(`Successfully deleted Plugin "${filename}".`); else BDFDB.NotificationUtils.toast(`Successfully deleted Plugin "${filename}".`);
}); });
} }
stopPlugin (data) { stopPlugin (data) {
if (BDFDB.isPluginEnabled(data.name) == true) { if (BDFDB.BdUtils.isPluginEnabled(data.name) == true) {
window.pluginModule.stopPlugin(data.name); window.pluginModule.stopPlugin(data.name);
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Stopped Plugin " + data.name + "."); console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Stopped Plugin " + data.name + ".");
} }

View File

@ -61,7 +61,7 @@ class ReadAllNotificationsButton {
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
var settingsitems = [], inneritems = []; var settingsitems = [], inneritems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, { for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8, className: BDFDB.disCN.marginbottom8,
plugin: this, plugin: this,
keys: ["settings", key], keys: ["settings", key],
@ -77,12 +77,12 @@ class ReadAllNotificationsButton {
} }
} }
})); }));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, { settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "When left clicking the 'read all' button mark following Elements as read:", title: "When left clicking the 'read all' button mark following Elements as read:",
children: inneritems children: inneritems
})); }));
return BDFDB.createSettingsPanel(this, settingsitems); return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
} }
//legacy //legacy
@ -109,13 +109,11 @@ class ReadAllNotificationsButton {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -124,7 +122,7 @@ class ReadAllNotificationsButton {
BDFDB.removeEles(".RANbutton-frame", ".RAMbutton"); BDFDB.removeEles(".RANbutton-frame", ".RAMbutton");
BDFDB.removeClasses("RAN-added", "RAM-added"); BDFDB.removeClasses("RAN-added", "RAM-added");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -140,52 +138,52 @@ class ReadAllNotificationsButton {
insertnode.parentElement.insertBefore(ranbutton, insertnode); insertnode.parentElement.insertBefore(ranbutton, insertnode);
ranbutton.addEventListener("click", () => { ranbutton.addEventListener("click", () => {
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
if (settings.includeGuilds) BDFDB.markGuildAsRead(settings.includeMuted ? BDFDB.readServerList() : BDFDB.readUnreadServerList()); if (settings.includeGuilds) BDFDB.GuildUtils.markAsRead(settings.includeMuted ? BDFDB.GuildUtils.getAll() : BDFDB.GuildUtils.getUnread());
if (settings.includeDMs) BDFDB.markChannelAsRead(BDFDB.readDmList()); if (settings.includeDMs) BDFDB.DmUtils.markAsRead(BDFDB.DmUtils.getAll());
}); });
ranbutton.addEventListener("contextmenu", e => { ranbutton.addEventListener("contextmenu", e => {
const itemGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_unreadguilds_text, label: this.labels.context_unreadguilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-unreadguilds-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-unreadguilds-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target)); BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
BDFDB.markGuildAsRead(BDFDB.readUnreadServerList()); BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getUnread());
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_pingedguilds_text, label: this.labels.context_pingedguilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pingedguilds-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pingedguilds-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target)); BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
BDFDB.markGuildAsRead(BDFDB.readPingedServerList()); BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getPinged());
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_mutedguilds_text, label: this.labels.context_mutedguilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-mutedguilds-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-mutedguilds-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target)); BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
BDFDB.markGuildAsRead(BDFDB.readMutedServerList()); BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getMuted());
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_guilds_text, label: this.labels.context_guilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-guilds-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-guilds-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target)); BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
this.addPinnedRecent(instance.props.channel.id); this.addPinnedRecent(instance.props.channel.id);
BDFDB.markGuildAsRead(BDFDB.readServerList()); BDFDB.GuildUtils.markAsRead(BDFDB.GuildUtils.getAll());
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_dms_text, label: this.labels.context_dms_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-dms-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-dms-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target)); BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
BDFDB.markChannelAsRead(BDFDB.readDmList()); BDFDB.DmUtils.markAsRead(BDFDB.DmUtils.getAll());
} }
}) })
] ]

View File

@ -85,14 +85,12 @@ class RemoveNicknames {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.reseting = false; this.reseting = false;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -102,9 +100,9 @@ class RemoveNicknames {
this.reseting = true; this.reseting = true;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -112,7 +110,7 @@ class RemoveNicknames {
// begin of own functions // begin of own functions
processMemberListItem (instance, wrapper, returnvalue) { processMemberListItem (instance, wrapper, returnvalue) {
let user = BDFDB.getReactValue(instance, "props.user"); let user = BDFDB.ReactUtils.getValue(instance, "props.user");
if (user) { if (user) {
let username = wrapper.querySelector(BDFDB.dotCN.memberusername); let username = wrapper.querySelector(BDFDB.dotCN.memberusername);
if (username) BDFDB.setInnerText(username, this.getNewName(user, wrapper)); if (username) BDFDB.setInnerText(username, this.getNewName(user, wrapper));
@ -120,7 +118,7 @@ class RemoveNicknames {
} }
processMessageUsername (instance, wrapper, returnvalue) { processMessageUsername (instance, wrapper, returnvalue) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message) { if (message) {
let username = wrapper.querySelector(BDFDB.dotCN.messageusername); let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
if (username) BDFDB.setInnerText(username, this.getNewName(message.author, wrapper)); if (username) BDFDB.setInnerText(username, this.getNewName(message.author, wrapper));
@ -128,7 +126,7 @@ class RemoveNicknames {
} }
processTypingUsers (instance, wrapper, returnvalue) { processTypingUsers (instance, wrapper, returnvalue) {
let users = !instance.props.typingUsers ? [] : Object.keys(instance.props.typingUsers).filter(id => id != BDFDB.myData.id).filter(id => !BDFDB.LibraryModules.FriendUtils.isBlocked(id)).map(id => BDFDB.LibraryModules.UserStore.getUser(id)).filter(id => id != null); let users = !instance.props.typingUsers ? [] : Object.keys(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(id => id != null);
wrapper.querySelectorAll("strong").forEach((username, i) => { wrapper.querySelectorAll("strong").forEach((username, i) => {
if (users[i] && username) BDFDB.setInnerText(username, this.getNewName(users[i])); if (users[i] && username) BDFDB.setInnerText(username, this.getNewName(users[i]));
}); });
@ -150,7 +148,7 @@ class RemoveNicknames {
} }
} }
else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) { else if (instance.props.tag == "span" && instance.props.className.indexOf(BDFDB.disCN.mention) > -1) {
let render = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.stateNode.props.render"); let render = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.stateNode.props.render");
if (typeof render == "function") { if (typeof render == "function") {
var props = render().props; var props = render().props;
if (props && props.user) BDFDB.setInnerText(wrapper, "@" + this.getNewName(props.user, wrapper)); if (props && props.user) BDFDB.setInnerText(wrapper, "@" + this.getNewName(props.user, wrapper));
@ -158,14 +156,14 @@ class RemoveNicknames {
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.voiceuser) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.voiceuser) > -1) {
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.user"); let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.user");
if (user) { if (user) {
let username = wrapper.querySelector(BDFDB.dotCN.voicename); let username = wrapper.querySelector(BDFDB.dotCN.voicename);
if (username) BDFDB.setInnerText(username, this.getNewName(user, username)); if (username) BDFDB.setInnerText(username, this.getNewName(user, username));
} }
} }
else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) { else if (instance.props.tag == "div" && instance.props.className.indexOf(BDFDB.disCN.autocompleterow) > -1) {
let user = BDFDB.getReactValue(instance, "_reactInternalFiber.return.memoizedProps.user"); let user = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.user");
if (user) { if (user) {
let username = wrapper.querySelector(BDFDB.dotCN.marginleft8); let username = wrapper.querySelector(BDFDB.dotCN.marginleft8);
if (username) BDFDB.setInnerText(username, this.getNewName(user, username)); if (username) BDFDB.setInnerText(username, this.getNewName(user, username));
@ -176,7 +174,7 @@ class RemoveNicknames {
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
@ -184,14 +182,14 @@ class RemoveNicknames {
if (!info) return null; if (!info) return null;
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {}; let member = BDFDB.LibraryModules.MemberStore.getMember(BDFDB.LibraryModules.LastGuildStore.getGuildId(), info.id) || {};
let EditUsersData = (BDFDB.isPluginEnabled("EditUsers") ? BDFDB.loadData(info.id, "EditUsers", "users") : null) || {}; let EditUsersData = (BDFDB.BdUtils.isPluginEnabled("EditUsers") ? BDFDB.loadData(info.id, "EditUsers", "users") : null) || {};
if (this.reseting || !member.nick || info.id == BDFDB.myData.id && !settings.replaceOwn || info.bot && !settings.replaceBots || this.ignoreElement(wrapper)) return EditUsersData.name || member.nick || info.username; if (this.reseting || !member.nick || info.id == BDFDB.UserUtils.me.id && !settings.replaceOwn || info.bot && !settings.replaceBots || this.ignoreElement(wrapper)) return EditUsersData.name || member.nick || info.username;
var username = EditUsersData.name || info.username; var username = EditUsersData.name || info.username;
return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + username + ")") : (username + " (" + member.nick + ")")) : username; return settings.addNickname ? (settings.swapPositions ? (member.nick + " (" + username + ")") : (username + " (" + member.nick + ")")) : username;
} }
ignoreElement (id, wrapper) { ignoreElement (id, wrapper) {
let allenabled = true, settings = BDFDB.filterObject(BDFDB.getAllData(this, "settings"), key => {return this.defaults.settings[key].inner;}, true); let allenabled = true, settings = BDFDB.ObjectUtils.filter(BDFDB.getAllData(this, "settings"), key => {return this.defaults.settings[key].inner;}, true);
for (let i in settings) if (!settings[i]) { for (let i in settings) if (!settings[i]) {
allenabled = false; allenabled = false;
break; break;

View File

@ -171,15 +171,13 @@ class RepoControls {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.dirs = {theme: BDFDB.getThemesFolder(), plugin: BDFDB.getPluginsFolder()}; this.dirs = {theme: BDFDB.BdUtils.getThemesFolder(), plugin: BDFDB.BdUtils.getPluginsFolder()};
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -201,7 +199,7 @@ class RepoControls {
} }
} }
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -239,10 +237,10 @@ class RepoControls {
if (!path) return; if (!path) return;
let button = BDFDB.htmlToElement(this.editButtonMarkup); let button = BDFDB.htmlToElement(this.editButtonMarkup);
button.addEventListener("click", () => { button.addEventListener("click", () => {
if (!BDFDB.LibraryRequires.electron.shell.openItem(path)) BDFDB.showToast(`Unable to open ${type} "${name}".`, {type:"danger"});; if (!BDFDB.LibraryRequires.electron.shell.openItem(path)) BDFDB.NotificationUtils.toast(`Unable to open ${type} "${name}".`, {type:"danger"});;
}); });
button.addEventListener("mouseenter", e => { button.addEventListener("mouseenter", e => {
BDFDB.createTooltip(`Edit ${type[0].toUpperCase() + type.slice(1)}`, e.currentTarget, {type:"top",selector:"repocontrols-editicon-tooltip"}); BDFDB.TooltipUtils.create(e.currentTarget, `Edit ${type[0].toUpperCase() + type.slice(1)}`, {type:"top",selector:"repocontrols-editicon-tooltip"});
}); });
controls.insertBefore(button, controls.firstElementChild); controls.insertBefore(button, controls.firstElementChild);
} }
@ -258,8 +256,8 @@ class RepoControls {
button.addEventListener("click", () => { button.addEventListener("click", () => {
let deleteFile = () => { let deleteFile = () => {
BDFDB.LibraryRequires.fs.unlink(path, (error) => { BDFDB.LibraryRequires.fs.unlink(path, (error) => {
if (error) BDFDB.showToast(`Unable to delete ${type} "${name}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to delete ${type} "${name}".`, {type:"danger"});
else BDFDB.showToast(`Successfully deleted ${type} "${name}".`, {type:"success"}); else BDFDB.NotificationUtils.toast(`Successfully deleted ${type} "${name}".`, {type:"success"});
}); });
}; };
if (!BDFDB.getData("confirmDelete", this, "settings")) deleteFile(); if (!BDFDB.getData("confirmDelete", this, "settings")) deleteFile();
@ -268,7 +266,7 @@ class RepoControls {
}); });
}); });
button.addEventListener("mouseenter", e => { button.addEventListener("mouseenter", e => {
BDFDB.createTooltip(`Delete ${type[0].toUpperCase() + type.slice(1)}`, e.currentTarget, {type:"top",selector:"repocontrols-trashicon-tooltip"}); BDFDB.TooltipUtils.create(e.currentTarget, `Delete ${type[0].toUpperCase() + type.slice(1)}`, {type:"top",selector:"repocontrols-trashicon-tooltip"});
}); });
controls.insertBefore(button, controls.firstElementChild); controls.insertBefore(button, controls.firstElementChild);
} }
@ -294,26 +292,26 @@ class RepoControls {
orderfilter.setAttribute("option", sortings.order); orderfilter.setAttribute("option", sortings.order);
orderfilter.innerText = this.sortings.order[sortings.order]; orderfilter.innerText = this.sortings.order[sortings.order];
BDFDB.addChildEventListener(repocontrols, "keyup", BDFDB.dotCN.searchbarinput, () => { BDFDB.ListenerUtils.addToChildren(repocontrols, "keyup", BDFDB.dotCN.searchbarinput, () => {
clearTimeout(repocontrols.searchTimeout); clearTimeout(repocontrols.searchTimeout);
repocontrols.searchTimeout = setTimeout(() => {this.sortEntries(container, repocontrols);},1000); repocontrols.searchTimeout = setTimeout(() => {this.sortEntries(container, repocontrols);},1000);
}); });
BDFDB.addChildEventListener(repocontrols, "click", BDFDB.dotCN.searchbarclear + BDFDB.dotCN.searchbarvisible, () => { BDFDB.ListenerUtils.addToChildren(repocontrols, "click", BDFDB.dotCN.searchbarclear + BDFDB.dotCN.searchbarvisible, () => {
this.sortEntries(container, repocontrols); this.sortEntries(container, repocontrols);
}); });
BDFDB.addChildEventListener(repocontrols, "click", ".btn-enableall", e => { BDFDB.ListenerUtils.addToChildren(repocontrols, "click", ".btn-enableall", e => {
this.toggleAll(type, container, true); this.toggleAll(type, container, true);
}); });
BDFDB.addChildEventListener(repocontrols, "click", ".btn-disableall", e => { BDFDB.ListenerUtils.addToChildren(repocontrols, "click", ".btn-disableall", e => {
this.toggleAll(type, container, false); this.toggleAll(type, container, false);
}); });
BDFDB.addChildEventListener(repocontrols, "click", ".sort-filter", e => { BDFDB.ListenerUtils.addToChildren(repocontrols, "click", ".sort-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => { BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {
BDFDB.saveData("sort", sortfilter.getAttribute("option"), this, "sortings"); BDFDB.saveData("sort", sortfilter.getAttribute("option"), this, "sortings");
this.sortEntries(container, repocontrols); this.sortEntries(container, repocontrols);
}); });
}); });
BDFDB.addChildEventListener(repocontrols, "click", ".order-filter", e => { BDFDB.ListenerUtils.addToChildren(repocontrols, "click", ".order-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => { BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {
BDFDB.saveData("order", orderfilter.getAttribute("option"), this, "sortings"); BDFDB.saveData("order", orderfilter.getAttribute("option"), this, "sortings");
this.sortEntries(container, repocontrols); this.sortEntries(container, repocontrols);
@ -355,9 +353,9 @@ class RepoControls {
let searchstring = repocontrols.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase(); let searchstring = repocontrols.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
let sortings = BDFDB.getAllData(this, "sortings"); let sortings = BDFDB.getAllData(this, "sortings");
let entries = BDFDB.filterObject(container.entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;}); let entries = BDFDB.ObjectUtils.filter(container.entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
entries = BDFDB.sortObject(entries, sortings.sort); entries = BDFDB.ObjectUtils.sort(entries, sortings.sort);
if (sortings.order == "desc") entries = BDFDB.reverseObject(entries); if (sortings.order == "desc") entries = BDFDB.ObjectUtils.reverse(entries);
let entrypositions = Object.keys(entries); let entrypositions = Object.keys(entries);
for (let li of container.children) { for (let li of container.children) {
let name = li.getAttribute("data-name"); let name = li.getAttribute("data-name");

View File

@ -44,18 +44,16 @@ class RevealAllSpoilersOption {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -67,12 +65,12 @@ class RevealAllSpoilersOption {
let messagediv = BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> [aria-disabled]", instance.props.target); let messagediv = BDFDB.getParentEle(BDFDB.dotCN.messagegroup + "> [aria-disabled]", instance.props.target);
if (!messagediv || !messagediv.querySelector(BDFDB.dotCN.spoilerhidden)) return; if (!messagediv || !messagediv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: "Reveal all Spoilers", label: "Reveal all Spoilers",
hint: BDFDB.isPluginEnabled("MessageUtilities") ? BDFDB.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null, hint: BDFDB.BdUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BdUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-reveal-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-reveal-contextMenuItem`,
action: e => { action: e => {
BDFDB.closeContextMenu(menu); BDFDB.closeContextMenu(menu);

View File

@ -88,18 +88,16 @@ class ReverseImageSearch {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -149,7 +147,7 @@ class ReverseImageSearch {
} }
let engines = BDFDB.getAllData(this, "engines"); let engines = BDFDB.getAllData(this, "engines");
let items = []; let items = [];
for (let key in engines) if (engines[key]) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { for (let key in engines) if (engines[key]) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.defaults.engines[key].name, label: this.defaults.engines[key].name,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
danger: key == "_all", danger: key == "_all",
@ -161,16 +159,16 @@ class ReverseImageSearch {
else window.open(this.defaults.engines[key].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank"); else window.open(this.defaults.engines[key].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
} }
})); }));
if (!items.length) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_disabled_text, label: this.labels.submenu_disabled_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
disabled: true disabled: true
})); }));
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: "Reverse Image Search", label: "Reverse Image Search",
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`,
render: items render: items

View File

@ -105,13 +105,11 @@ class SendLargeMessages {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -119,7 +117,7 @@ class SendLargeMessages {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -142,14 +140,14 @@ class SendLargeMessages {
this.showSendModal(modaltext); this.showSendModal(modaltext);
} }
}; };
BDFDB.addEventListener(this, textarea, "keyup", e => { BDFDB.ListenerUtils.add(this, textarea, "keyup", e => {
clearTimeout(textarea.sendlargemessagestimeout); clearTimeout(textarea.sendlargemessagestimeout);
textarea.sendlargemessagestimeout = setTimeout(() => { textarea.sendlargemessagestimeout = setTimeout(() => {
modaltext = textarea.value; modaltext = textarea.value;
checkTextarea(); checkTextarea();
},100); },100);
}); });
BDFDB.addEventListener(this, textarea, "paste", e => { BDFDB.ListenerUtils.add(this, textarea, "paste", e => {
modaltext = textarea.value.slice(0, textarea.selectionStart) + BDFDB.LibraryRequires.electron.clipboard.readText() + textarea.value.slice(textarea.selectionEnd); modaltext = textarea.value.slice(0, textarea.selectionStart) + BDFDB.LibraryRequires.electron.clipboard.readText() + textarea.value.slice(textarea.selectionEnd);
setImmediate(() => {checkTextarea(textarea);}); setImmediate(() => {checkTextarea(textarea);});
}); });
@ -171,12 +169,12 @@ class SendLargeMessages {
BDFDB.appendModal(sendMessageModal); BDFDB.appendModal(sendMessageModal);
BDFDB.addChildEventListener(sendMessageModal, "click", ".btn-send", e => { BDFDB.ListenerUtils.addToChildren(sendMessageModal, "click", ".btn-send", e => {
let messages = this.formatText(textinput.value || ""); let messages = this.formatText(textinput.value || "");
messages.forEach((message,i) => { messages.forEach((message,i) => {
setTimeout(() => { setTimeout(() => {
this.sendMessage(message); this.sendMessage(message);
if (i >= messages.length-1) BDFDB.showToast(this.labels.toast_allsent_text, {type:"success"}); if (i >= messages.length-1) BDFDB.NotificationUtils.toast(this.labels.toast_allsent_text, {type:"success"});
},this.messageDelay * i); },this.messageDelay * i);
}); });
}); });

View File

@ -184,7 +184,7 @@ class ServerFolders {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".removecustom-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".removecustom-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all custom icons?", () => { BDFDB.openConfirmModal(this, "Are you sure you want to remove all custom icons?", () => {
BDFDB.removeAllData(this, "customicons"); BDFDB.removeAllData(this, "customicons");
}); });
@ -216,10 +216,10 @@ class ServerFolders {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
// REMOVE 08.10.2019 // REMOVE 08.10.2019
let foldersdata = BDFDB.sortObject(BDFDB.loadAllData(this, "folders"), "position"); let foldersdata = BDFDB.ObjectUtils.sort(BDFDB.loadAllData(this, "folders"), "position");
let folders = Object.keys(foldersdata).filter(n => n.indexOf("folder") == 0); let folders = Object.keys(foldersdata).filter(n => n.indexOf("folder") == 0);
if (folders.length) BDFDB.openConfirmModal(this, `Old ServerFolders data detected!\nFound ${folders.length} old custom folders in the ServerFolders.config.json.\nPress the '${BDFDB.LanguageUtils.LanguageStrings.OKAY}' button to automatically create a native folder for each old folder and to automatically put the servers in them.`, "Convert?", () => { if (folders.length) BDFDB.openConfirmModal(this, `Old ServerFolders data detected!\nFound ${folders.length} old custom folders in the ServerFolders.config.json.\nPress the '${BDFDB.LanguageUtils.LanguageStrings.OKAY}' button to automatically create a native folder for each old folder and to automatically put the servers in them.`, "Convert?", () => {
let oldGuildFolders = Object.assign({}, BDFDB.LibraryModules.FolderStore.guildFolders); let oldGuildFolders = Object.assign({}, BDFDB.LibraryModules.FolderStore.guildFolders);
@ -256,11 +256,9 @@ class ServerFolders {
BDFDB.saveAllData(newfoldersdata, this, "folders"); BDFDB.saveAllData(newfoldersdata, this, "folders");
}); });
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -287,7 +285,7 @@ class ServerFolders {
foldericon.parentElement.parentElement.style.removeProperty("-webkit-mask"); foldericon.parentElement.parentElement.style.removeProperty("-webkit-mask");
} }
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -313,7 +311,7 @@ class ServerFolders {
BDFDB.saveData(folderid, data, this, "folders"); BDFDB.saveData(folderid, data, this, "folders");
} }
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "GuildFolderMarkReadItem"); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, "GuildFolderMarkReadItem");
const autoreaditem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuToggleItem, { const autoreaditem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuToggleItem, {
label: this.labels.foldercontext_autoreadfolder_text, label: this.labels.foldercontext_autoreadfolder_text,
className: `BDFDB-contextMenuToggleItem ${this.name}-contextMenuToggleItem ${this.name}-autoread-contextMenuToggleItem`, className: `BDFDB-contextMenuToggleItem ${this.name}-contextMenuToggleItem ${this.name}-autoread-contextMenuToggleItem`,
active: data.autoRead, active: data.autoRead,
@ -324,9 +322,9 @@ class ServerFolders {
}); });
if (index > -1) children.splice(index + 1, 0, autoreaditem); if (index > -1) children.splice(index + 1, 0, autoreaditem);
else children.push(autoreaditem); else children.push(autoreaditem);
const muteGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const muteGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuToggleItem, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuToggleItem, {
label: this.labels.foldercontext_mutefolder_text, label: this.labels.foldercontext_mutefolder_text,
className: `BDFDB-contextMenuToggleItem ${this.name}-contextMenuToggleItem ${this.name}-mutefolder-contextMenuToggleItem`, className: `BDFDB-contextMenuToggleItem ${this.name}-contextMenuToggleItem ${this.name}-mutefolder-contextMenuToggleItem`,
active: muted, active: muted,
@ -338,9 +336,9 @@ class ServerFolders {
}) })
}); });
returnvalue.props.children.splice(returnvalue.props.children.length - 1, 0, muteGroup); returnvalue.props.children.splice(returnvalue.props.children.length - 1, 0, muteGroup);
const deleteGroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const deleteGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.foldercontext_removefolder_text, label: this.labels.foldercontext_removefolder_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-removefolder-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-removefolder-contextMenuItem`,
danger: true, danger: true,
@ -357,7 +355,7 @@ class ServerFolders {
let folders = this.getFolders(); let folders = this.getFolders();
let folder = this.getFolderOfGuildId(guildid); let folder = this.getFolderOfGuildId(guildid);
let addtofolderitems = [], openguilds = BDFDB.LibraryModules.FolderStore.getSortedGuilds().filter(n => !n.folderId).map(n => n.guilds[0]); let addtofolderitems = [], openguilds = BDFDB.LibraryModules.FolderStore.getSortedGuilds().filter(n => !n.folderId).map(n => n.guilds[0]);
for (let i = 0; i < folders.length; i++) addtofolderitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { for (let i = 0; i < folders.length; i++) addtofolderitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: folders[i].folderName || (this.labels.modal_tabheader1_text + " #" + parseInt(i+1)), label: folders[i].folderName || (this.labels.modal_tabheader1_text + " #" + parseInt(i+1)),
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addtofolder-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addtofolder-contextMenuItem`,
action: e => { action: e => {
@ -367,14 +365,14 @@ class ServerFolders {
})); }));
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const addType = !addtofolderitems.length ? "contextMenuItem" : "contextMenuSubItem"; const addType = !addtofolderitems.length ? "contextMenuItem" : "contextMenuSubItem";
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.servercontext_serverfolders_text, label: this.labels.servercontext_serverfolders_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-guild-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-guild-contextMenuSubItem`,
render: folder ? [ render: folder ? [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.serversubmenu_removefromfolder_text, label: this.labels.serversubmenu_removefromfolder_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-removefromfolder-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-removefromfolder-contextMenuItem`,
danger: true, danger: true,
@ -384,7 +382,7 @@ class ServerFolders {
} }
}) })
] : [ ] : [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.serversubmenu_createfolder_text, label: this.labels.serversubmenu_createfolder_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-createfolder-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-createfolder-contextMenuItem`,
disabled: !openguilds.length, disabled: !openguilds.length,
@ -393,7 +391,7 @@ class ServerFolders {
this.openFolderCreationMenu(openguilds, guildid); this.openFolderCreationMenu(openguilds, guildid);
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents[addType.charAt(0).toUpperCase() + addType.slice(1)], { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents[addType.charAt(0).toUpperCase() + addType.slice(1)], {
label: this.labels.serversubmenu_addtofolder_text, label: this.labels.serversubmenu_addtofolder_text,
className: `BDFDB-${addType} ${this.name}-${addType} ${this.name}-addtofolder-${addType}`, className: `BDFDB-${addType} ${this.name}-${addType} ${this.name}-addtofolder-${addType}`,
disabled: !addtofolderitems.length, disabled: !addtofolderitems.length,
@ -439,7 +437,7 @@ class ServerFolders {
if (data.autoRead && (state.unread || state.badge > 0)) { if (data.autoRead && (state.unread || state.badge > 0)) {
clearTimeout(this.folderReads[state.folderId]); clearTimeout(this.folderReads[state.folderId]);
this.folderReads[state.folderId] = setTimeout(() => { this.folderReads[state.folderId] = setTimeout(() => {
BDFDB.markGuildAsRead(instance.props.guildIds); BDFDB.GuildUtils.markAsRead(instance.props.guildIds);
}, 10000); }, 10000);
} }
if (state.expanded) setImmediate(() => { if (state.expanded) setImmediate(() => {
@ -465,7 +463,7 @@ class ServerFolders {
if (!this.foldercontentguilds) return; if (!this.foldercontentguilds) return;
if (instance.props && instance.props.guild) { if (instance.props && instance.props.guild) {
if (methodnames.includes("componentDidMount")) { if (methodnames.includes("componentDidMount")) {
BDFDB.addEventListener(this, wrapper, "click", () => {setImmediate(() => { BDFDB.ListenerUtils.add(this, wrapper, "click", () => {setImmediate(() => {
let folder = this.getFolderOfGuildId(instance.props.guild.id); let folder = this.getFolderOfGuildId(instance.props.guild.id);
let folderid = folder ? folder.folderId : null; let folderid = folder ? folder.folderId : null;
let settings = BDFDB.getAllData(this, "settings"); let settings = BDFDB.getAllData(this, "settings");
@ -524,17 +522,17 @@ class ServerFolders {
BDFDB.setColorSwatches(root, data.color3); BDFDB.setColorSwatches(root, data.color3);
BDFDB.setColorSwatches(root, data.color4); BDFDB.setColorSwatches(root, data.color4);
BDFDB.addChildEventListener(root, "change", "input[type='file'][option]", e => { BDFDB.ListenerUtils.addToChildren(root, "change", "input[type='file'][option]", e => {
let input = e.currentTarget, file = input.files[0]; let input = e.currentTarget, file = input.files[0];
if (file) setImmediate(() => {this.fetchCustomIcon(root, input.getAttribute("option"))}); if (file) setImmediate(() => {this.fetchCustomIcon(root, input.getAttribute("option"))});
}); });
BDFDB.addChildEventListener(root, "keyup", "input[type='text'][option]", e => { BDFDB.ListenerUtils.addToChildren(root, "keyup", "input[type='text'][option]", e => {
if (e.which == 13) this.fetchCustomIcon(root, e.currentTarget.getAttribute("option")); if (e.which == 13) this.fetchCustomIcon(root, e.currentTarget.getAttribute("option"));
}); });
BDFDB.addChildEventListener(root, "click", ".btn-addcustom", () => { BDFDB.ListenerUtils.addToChildren(root, "click", ".btn-addcustom", () => {
this.saveCustomIcon(root); this.saveCustomIcon(root);
}); });
BDFDB.addChildEventListener(root, "click", BDFDB.dotCNS.modalfooter + BDFDB.dotCN.button, e => { BDFDB.ListenerUtils.addToChildren(root, "click", BDFDB.dotCNS.modalfooter + BDFDB.dotCN.button, e => {
var olddata = Object.assign({}, data); var olddata = Object.assign({}, data);
var selectedIcon = root.querySelector(".ui-icon-picker-icon.selected"); var selectedIcon = root.querySelector(".ui-icon-picker-icon.selected");
data.iconID = selectedIcon.getAttribute("value"); data.iconID = selectedIcon.getAttribute("value");
@ -553,7 +551,7 @@ class ServerFolders {
data.icons.openicon = folderIcons[data.iconID] ? (!isCustom ? this.createBase64SVG(folderIcons[data.iconID].openicon, data.color1, data.color2) : folderIcons[data.iconID].openicon) : null; data.icons.openicon = folderIcons[data.iconID] ? (!isCustom ? this.createBase64SVG(folderIcons[data.iconID].openicon, data.color1, data.color2) : folderIcons[data.iconID].openicon) : null;
data.icons.closedicon = folderIcons[data.iconID] ? (!isCustom ? this.createBase64SVG(folderIcons[data.iconID].closedicon, data.color1, data.color2) : folderIcons[data.iconID].closedicon) : null; data.icons.closedicon = folderIcons[data.iconID] ? (!isCustom ? this.createBase64SVG(folderIcons[data.iconID].closedicon, data.color1, data.color2) : folderIcons[data.iconID].closedicon) : null;
BDFDB.saveData(folderid, data, this, "folders"); BDFDB.saveData(folderid, data, this, "folders");
instance.handleColorChange(data.color1 ? parseInt(BDFDB.colorCONVERT(data.color1 && BDFDB.isObject(data.color1) ? data.color1[Object.keys(data.color1)[0]] : data.color1, "HEX").slice(1), 16) : null); instance.handleColorChange(data.color1 ? parseInt(BDFDB.colorCONVERT(data.color1 && BDFDB.ObjectUtils.is(data.color1) ? data.color1[Object.keys(data.color1)[0]] : data.color1, "HEX").slice(1), 16) : null);
this.changeFolder(folderid); this.changeFolder(folderid);
} }
}); });
@ -566,7 +564,7 @@ class ServerFolders {
if (this.SettingsUpdated && this.foldercontent) { if (this.SettingsUpdated && this.foldercontent) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
this.folderStates = {}; this.folderStates = {};
BDFDB.WebModules.forceAllUpdates(this, "GuildFolder"); BDFDB.ModuleUtils.forceAllUpdates(this, "GuildFolder");
} }
} }
@ -589,7 +587,7 @@ class ServerFolders {
return; return;
} }
} }
BDFDB.showToast("Use a valid direct link to an image source. They usually end on something like .png, .jpg or .gif.", {type:"danger"}); BDFDB.NotificationUtils.toast("Use a valid direct link to an image source. They usually end on something like .png, .jpg or .gif.", {type:"danger"});
}); });
} }
else { else {
@ -602,7 +600,7 @@ class ServerFolders {
}); });
} }
else { else {
BDFDB.showToast("Could not fetch file. Please make sure the file exists.", {type:"danger"}); BDFDB.NotificationUtils.toast("Could not fetch file. Please make sure the file exists.", {type:"danger"});
} }
} }
@ -653,12 +651,10 @@ class ServerFolders {
BDFDB.addClass(iconpreviewswitching, "nopic"); BDFDB.addClass(iconpreviewswitching, "nopic");
iconpreviewswitchinginner.style.removeProperty("background-image"); iconpreviewswitchinginner.style.removeProperty("background-image");
clearInterval(iconpreviewswitching.switchInterval); clearInterval(iconpreviewswitching.switchInterval);
BDFDB.showToast(`Custom Icon was added to selection.`, {type:"success"}); BDFDB.NotificationUtils.toast(`Custom Icon was added to selection.`, {type:"success"});
this.setIcons(modal, modal.querySelector(".ui-icon-picker-icon.selected").getAttribute("value")); this.setIcons(modal, modal.querySelector(".ui-icon-picker-icon.selected").getAttribute("value"));
} }
else { else BDFDB.NotificationUtils.toast(`Add an image for the open and the closed icon.`, {type:"danger"});
BDFDB.showToast(`Add an image for the open and the closed icon.`, {type:"danger"});
}
} }
generateID (prefix) { generateID (prefix) {
@ -688,22 +684,22 @@ class ServerFolders {
setIcon(wrapper.querySelector(`.ui-icon-picker-icon[value="${folderIcons[selection] ? selection : -1}"]`), false, true); setIcon(wrapper.querySelector(`.ui-icon-picker-icon[value="${folderIcons[selection] ? selection : -1}"]`), false, true);
BDFDB.addChildEventListener(wrapper, "click", ".ui-icon-picker-icon", e => { BDFDB.ListenerUtils.addToChildren(wrapper, "click", ".ui-icon-picker-icon", e => {
if (BDFDB.containsClass(e.target, BDFDB.disCN.hovercardbutton)) return; if (BDFDB.containsClass(e.target, BDFDB.disCN.hovercardbutton)) return;
setIcon(wrapper.querySelector(".ui-icon-picker-icon.selected"), false, false); setIcon(wrapper.querySelector(".ui-icon-picker-icon.selected"), false, false);
setIcon(e.currentTarget, true, true); setIcon(e.currentTarget, true, true);
}); });
BDFDB.addChildEventListener(wrapper, "click", BDFDB.dotCN.hovercardbutton, e => { BDFDB.ListenerUtils.addToChildren(wrapper, "click", BDFDB.dotCN.hovercardbutton, e => {
if (BDFDB.containsClass(e.currentTarget.parentElement, "selected")) return; if (BDFDB.containsClass(e.currentTarget.parentElement, "selected")) return;
BDFDB.removeData(e.currentTarget.getAttribute("value"), this, "customicons"); BDFDB.removeData(e.currentTarget.getAttribute("value"), this, "customicons");
e.currentTarget.parentElement.remove(); e.currentTarget.parentElement.remove();
BDFDB.showToast(`Custom Icon was deleted.`, {type:"success"}); BDFDB.NotificationUtils.toast(`Custom Icon was deleted.`, {type:"success"});
}); });
BDFDB.addChildEventListener(wrapper, "mouseenter", ".ui-icon-picker-icon", e => { BDFDB.ListenerUtils.addToChildren(wrapper, "mouseenter", ".ui-icon-picker-icon", e => {
setIcon(e.currentTarget, true); setIcon(e.currentTarget, true);
if (e.currentTarget.getAttribute("value") == -1) BDFDB.createTooltip(BDFDB.LanguageUtils.LanguageStrings.DEFAULT, e.currentTarget, {type:"top"}); if (e.currentTarget.getAttribute("value") == -1) BDFDB.TooltipUtils.create(e.currentTarget, BDFDB.LanguageUtils.LanguageStrings.DEFAULT, {type:"top"});
}); });
BDFDB.addChildEventListener(wrapper, "mouseleave", ".ui-icon-picker-icon", e => { BDFDB.ListenerUtils.addToChildren(wrapper, "mouseleave", ".ui-icon-picker-icon", e => {
setIcon(e.currentTarget, false); setIcon(e.currentTarget, false);
}); });
@ -771,7 +767,7 @@ class ServerFolders {
} }
changeFolder (folderid, wrapper) { changeFolder (folderid, wrapper) {
wrapper = wrapper || BDFDB.getFolderDiv(folderid); wrapper = wrapper || BDFDB.FolderUtils.getDiv(folderid);
if (wrapper) { if (wrapper) {
let folderinner = wrapper.querySelector(`${BDFDB.dotCN.guildfolderexpandendbackground} ~ ${BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildinner}`); let folderinner = wrapper.querySelector(`${BDFDB.dotCN.guildfolderexpandendbackground} ~ ${BDFDB.dotCNS.guildouter + BDFDB.dotCN.guildinner}`);
let foldericon = wrapper.querySelector(BDFDB.dotCN.guildfolder); let foldericon = wrapper.querySelector(BDFDB.dotCN.guildfolder);
@ -785,7 +781,7 @@ class ServerFolders {
if (BDFDB.getData("showCountBadge", this, "settings")) { if (BDFDB.getData("showCountBadge", this, "settings")) {
folderinner.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.guildupperbadge} count" style="opacity: 1; transform: translate(0px, 0px);"><div class="${BDFDB.disCN.guildbadgenumberbadge}" style="background-color: rgb(114, 137, 218); width: ${folder.guildIds.length > 99 ? 28 : (folder.guildIds.length > 9 ? 22 : 16)}px; padding-right: ${folder.guildIds.length > 99 ? 0 : (folder.guildIds.length > 9 ? 0 : 1)}px;">${folder.guildIds.length}</div></div>`)); folderinner.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.guildupperbadge} count" style="opacity: 1; transform: translate(0px, 0px);"><div class="${BDFDB.disCN.guildbadgenumberbadge}" style="background-color: rgb(114, 137, 218); width: ${folder.guildIds.length > 99 ? 28 : (folder.guildIds.length > 9 ? 22 : 16)}px; padding-right: ${folder.guildIds.length > 99 ? 0 : (folder.guildIds.length > 9 ? 0 : 1)}px;">${folder.guildIds.length}</div></div>`));
let width = folder.guildIds.length > 99 ? 36 : (folder.guildIds.length > 9 ? 30 : 24); let width = folder.guildIds.length > 99 ? 36 : (folder.guildIds.length > 9 ? 30 : 24);
foldericon.parentElement.parentElement.style.setProperty("-webkit-mask", `url(data:image/svg+xml;base64,${btoa(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" fill="black" x="0" y="0" width="48" height="48"><path d="M ${width-7} 0 C ${width-5} 2 ${width-4} 5 ${width-4} 8 C ${width-4} ${width/1.8+3} 15 20 8 20 C 5 20 2 19 0 17 L 0 50 L 50 50 L 50 0 L 17 0 z"></path></svg>`)})`); foldericon.parentElement.parentElement.style.setProperty("-webkit-mask", `url(data:image/svg+xml;base64,${btoa(`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" fill="black" x="0" y="0" width="48" height="48"><path d="M ${width-7} 0 C ${width-5} 2 ${width-4} 5 ${width-4} 8 C ${width-4} ${width/1.8+3} 15 20 8 20 C 5 20 2 19 0 17 L 0 50 L 50 50 L 50 0 L 17 0 z"></path></svg>`)}) center/cover no-repeat`);
} }
let icontype = BDFDB.LibraryModules.FolderUtils.isFolderExpanded(folderid) ? "openicon" : "closedicon"; let icontype = BDFDB.LibraryModules.FolderUtils.isFolderExpanded(folderid) ? "openicon" : "closedicon";
let icon = icontype != "closedicon" || data.useCloseIcon ? data.icons[icontype] : null; let icon = icontype != "closedicon" || data.useCloseIcon ? data.icons[icontype] : null;
@ -795,13 +791,13 @@ class ServerFolders {
folderinner.removeEventListener("mouseenter", folderinner.ServerFoldersTooltipListener); folderinner.removeEventListener("mouseenter", folderinner.ServerFoldersTooltipListener);
folderinner.removeEventListener("mousedown", folderinner.ServerFoldersClickListener); folderinner.removeEventListener("mousedown", folderinner.ServerFoldersClickListener);
if (data.color3 || data.color4) { if (data.color3 || data.color4) {
var isgradient3 = data.color3 && BDFDB.isObject(data.color3); var isgradient3 = data.color3 && BDFDB.ObjectUtils.is(data.color3);
var isgradient4 = data.color4 && BDFDB.isObject(data.color4); var isgradient4 = data.color4 && BDFDB.ObjectUtils.is(data.color4);
var bgColor = data.color3 ? (!isgradient3 ? BDFDB.colorCONVERT(data.color3, "RGBA") : BDFDB.colorGRADIENT(data.color3)) : ""; var bgColor = data.color3 ? (!isgradient3 ? BDFDB.colorCONVERT(data.color3, "RGBA") : BDFDB.colorGRADIENT(data.color3)) : "";
var fontColor = data.color4 ? (!isgradient4 ? BDFDB.colorCONVERT(data.color4, "RGBA") : BDFDB.colorGRADIENT(data.color4)) : ""; var fontColor = data.color4 ? (!isgradient4 ? BDFDB.colorCONVERT(data.color4, "RGBA") : BDFDB.colorGRADIENT(data.color4)) : "";
var folderName = folder.folderName || BDFDB.getReactValue(wrapper, "return.stateNode.props.defaultFolderName"); var folderName = folder.folderName || BDFDB.ReactUtils.getValue(wrapper, "return.stateNode.props.defaultFolderName");
folderinner.ServerFoldersTooltipListener = () => { folderinner.ServerFoldersTooltipListener = () => {
BDFDB.createTooltip(isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(folderName)}</span>` : folderName, folderinner, {type:"right", selector:"ServerFolders-tooltip", style:`${isgradient4 ? '' : `color: ${fontColor} !important; `}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(data.color3[0], "RGBA") : bgColor} !important;`, html:isgradient3, hide:true}); BDFDB.TooltipUtils.create(folderinner, isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(folderName)}</span>` : folderName, {type:"right", selector:"ServerFolders-tooltip", style:`${isgradient4 ? '' : `color: ${fontColor} !important; `}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(data.color3[0], "RGBA") : bgColor} !important;`, html:isgradient3, hide:true});
}; };
folderinner.addEventListener("mouseenter", folderinner.ServerFoldersTooltipListener); folderinner.addEventListener("mouseenter", folderinner.ServerFoldersTooltipListener);
} }
@ -851,8 +847,8 @@ class ServerFolders {
createBase64SVG (paths, color1 = "#000000", color2 = "#FFFFFF") { createBase64SVG (paths, color1 = "#000000", color2 = "#FFFFFF") {
if (paths.indexOf("<path ") != 0) return paths; if (paths.indexOf("<path ") != 0) return paths;
let isgradient1 = color1 && BDFDB.isObject(color1); let isgradient1 = color1 && BDFDB.ObjectUtils.is(color1);
let isgradient2 = color1 && BDFDB.isObject(color2); let isgradient2 = color1 && BDFDB.ObjectUtils.is(color2);
let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="-60 -50 1100 1100">`; let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1000" height="1000" viewBox="-60 -50 1100 1100">`;
if (isgradient1) { if (isgradient1) {
svg += `<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">`; svg += `<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">`;
@ -872,8 +868,8 @@ class ServerFolders {
createCopyOfServer (folderid, guildid) { createCopyOfServer (folderid, guildid) {
if (!folderid || !guildid) return; if (!folderid || !guildid) return;
let guild = BDFDB.LibraryModules.GuildStore.getGuild(guildid); let guild = BDFDB.LibraryModules.GuildStore.getGuild(guildid);
let guilddiv = BDFDB.getServerDiv(guildid); let guilddiv = BDFDB.GuildUtils.getDiv(guildid);
let props = BDFDB.getReactValue(guilddiv, "return.stateNode.props"); let props = BDFDB.ReactUtils.getValue(guilddiv, "return.stateNode.props");
if (!guild || !guilddiv || !props) return; if (!guild || !guilddiv || !props) return;
let guildcopy = guilddiv.cloneNode(true); let guildcopy = guilddiv.cloneNode(true);
@ -950,18 +946,18 @@ class ServerFolders {
}; };
guildcopyinner.addEventListener("mouseenter", () => { guildcopyinner.addEventListener("mouseenter", () => {
let EditServers = BDFDB.getPlugin("EditServers"); let EditServers = BDFDB.BdUtils.getPlugin("EditServers");
let ESdata = EditServers ? EditServers.getGuildData(guildid, guildcopyinner) : null; let ESdata = EditServers ? EditServers.getGuildData(guildid, guildcopyinner) : null;
if (ESdata && (ESdata.name || ESdata.color3 || ESdata.color4)) EditServers.changeTooltip(guild, guildcopyinner, "right"); if (ESdata && (ESdata.name || ESdata.color3 || ESdata.color4)) EditServers.changeTooltip(guild, guildcopyinner, "right");
else { else {
let folderData = BDFDB.loadData(folderid, this, "folders") || {}; let folderData = BDFDB.loadData(folderid, this, "folders") || {};
let color3 = folderData.copyTooltipColor ? folderData.color3 : null; let color3 = folderData.copyTooltipColor ? folderData.color3 : null;
let color4 = folderData.copyTooltipColor ? folderData.color4 : null; let color4 = folderData.copyTooltipColor ? folderData.color4 : null;
let isgradient3 = color3 && BDFDB.isObject(color3); let isgradient3 = color3 && BDFDB.ObjectUtils.is(color3);
let isgradient4 = color4 && BDFDB.isObject(color4); let isgradient4 = color4 && BDFDB.ObjectUtils.is(color4);
let bgColor = color3 ? (!isgradient3 ? BDFDB.colorCONVERT(color3, "RGBA") : BDFDB.colorGRADIENT(color3)) : ""; let bgColor = color3 ? (!isgradient3 ? BDFDB.colorCONVERT(color3, "RGBA") : BDFDB.colorGRADIENT(color3)) : "";
let fontColor = color4 ? (!isgradient4 ? BDFDB.colorCONVERT(color4, "RGBA") : BDFDB.colorGRADIENT(color4)) : ""; let fontColor = color4 ? (!isgradient4 ? BDFDB.colorCONVERT(color4, "RGBA") : BDFDB.colorGRADIENT(color4)) : "";
BDFDB.createTooltip(isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(guild.name)}</span>` : guild.name, guildcopyinner, {type:"right", selector:"guild-folder-tooltip", style:`${isgradient4 ? '' : 'color: ' + fontColor + ' !important; '}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(color3[0], "RGBA") : bgColor} !important;`, html:isgradient3, hide:true}); BDFDB.TooltipUtils.create(guildcopyinner, isgradient4 ? `<span style="pointer-events: none; -webkit-background-clip: text !important; color: transparent !important; background-image: ${fontColor} !important;">${BDFDB.encodeToHTML(guild.name)}</span>` : guild.name, {type:"right", selector:"guild-folder-tooltip", style:`${isgradient4 ? '' : 'color: ' + fontColor + ' !important; '}background: ${bgColor} !important; border-color: ${isgradient3 ? BDFDB.colorCONVERT(color3[0], "RGBA") : bgColor} !important;`, html:isgradient3, hide:true});
} }
if (guildicon && guildicon.src && guild.icon && guild.icon.startsWith("a_") && guild.features.has("ANIMATED_ICON") && guildicon.src.includes("discordapp.com/icons/")) { if (guildicon && guildicon.src && guild.icon && guild.icon.startsWith("a_") && guild.features.has("ANIMATED_ICON") && guildicon.src.includes("discordapp.com/icons/")) {
guildicon.src = guildicon.src.replace(".webp", ".gif"); guildicon.src = guildicon.src.replace(".webp", ".gif");
@ -973,7 +969,7 @@ class ServerFolders {
} }
}); });
guildcopyinner.addEventListener("mouseleave", () => { guildcopyinner.addEventListener("mouseleave", () => {
if (guildicon && guildicon.src && guild.icon && guild.icon.startsWith("a_") && guild.features.has("ANIMATED_ICON") && guildicon.src.includes("discordapp.com/icons/") && !BDFDB.getReactValue(BDFDB.getPlugin("AutoPlayGifs", true), "settings.guildList")) { if (guildicon && guildicon.src && guild.icon && guild.icon.startsWith("a_") && guild.features.has("ANIMATED_ICON") && guildicon.src.includes("discordapp.com/icons/") && !BDFDB.ReactUtils.getValue(BDFDB.BdUtils.getPlugin("AutoPlayGifs", true), "settings.guildList")) {
guildicon.src = guildicon.src.replace(".gif", ".webp"); guildicon.src = guildicon.src.replace(".gif", ".webp");
} }
if (BDFDB.LibraryModules.LastGuildStore.getGuildId() != guildid) { if (BDFDB.LibraryModules.LastGuildStore.getGuildId() != guildid) {
@ -982,7 +978,7 @@ class ServerFolders {
} }
}); });
guildcopy.addEventListener("click", e => { guildcopy.addEventListener("click", e => {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
if (BDFDB.pressedKeys.includes(46)) this.removeGuildFromFolder(folderid, guildid); if (BDFDB.pressedKeys.includes(46)) this.removeGuildFromFolder(folderid, guildid);
else { else {
BDFDB.LibraryModules.GuildUtils.transitionToGuildSync(guild.id); BDFDB.LibraryModules.GuildUtils.transitionToGuildSync(guild.id);
@ -992,7 +988,7 @@ class ServerFolders {
} }
}); });
guildcopy.addEventListener("contextmenu", e => { guildcopy.addEventListener("contextmenu", e => {
BDFDB.openGuildContextMenu(guilddiv, e); BDFDB.GuildUtils.openMenu(guilddiv, e);
}); });
guildcopy.addEventListener("mousedown", e => { guildcopy.addEventListener("mousedown", e => {
let x = e.pageX, y = e.pageY; let x = e.pageX, y = e.pageY;
@ -1020,7 +1016,7 @@ class ServerFolders {
BDFDB.removeEles(placeholder, dragpreview); BDFDB.removeEles(placeholder, dragpreview);
BDFDB.toggleEles(guildcopy, true); BDFDB.toggleEles(guildcopy, true);
let dropfolderdiv = BDFDB.getParentEle(BDFDB.dotCN.guildfolderwrapper, e3.target); let dropfolderdiv = BDFDB.getParentEle(BDFDB.dotCN.guildfolderwrapper, e3.target);
let newfolderid = dropfolderdiv ? BDFDB.getFolderID(dropfolderdiv) : null; let newfolderid = dropfolderdiv ? BDFDB.FolderUtils.getId(dropfolderdiv) : null;
if (newfolderid) { if (newfolderid) {
if (newfolderid != folderid) { if (newfolderid != folderid) {
BDFDB.removeEles(guildcopy); BDFDB.removeEles(guildcopy);
@ -1076,7 +1072,7 @@ class ServerFolders {
let targetedguildsids = {}; let targetedguildsids = {};
let container = modal.querySelector(".entries"); let container = modal.querySelector(".entries");
BDFDB.addChildEventListener(modal, "click", ".btn-done", () => { BDFDB.ListenerUtils.addToChildren(modal, "click", ".btn-done", () => {
let ids = []; let ids = [];
for (let id in targetedguildsids) if (targetedguildsids[id]) ids.push(id); for (let id in targetedguildsids) if (targetedguildsids[id]) ids.push(id);
this.createFolder(ids); this.createFolder(ids);
@ -1084,7 +1080,7 @@ class ServerFolders {
for (let guild of guilds) { for (let guild of guilds) {
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.divider}"></div>`)); if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.divider}"></div>`));
let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">${BDFDB.createServerDivCopy(guild.id, {size: 48}).outerHTML}<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCN.overflowellipsis}" style="flex: 1 1 auto; white-space: nowrap;">${BDFDB.encodeToHTML(guild.name)}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"></div></div>`); let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCN.marginbottom4} entry" style="flex: 1 1 auto;">${BDFDB.GuildUtils.createCopy(guild.id, {size: 48}).outerHTML}<h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCNS.flexchild + BDFDB.disCN.overflowellipsis}" style="flex: 1 1 auto; white-space: nowrap;">${BDFDB.encodeToHTML(guild.name)}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner}"></div></div>`);
container.appendChild(entry); container.appendChild(entry);
let switchinput = entry.querySelector(BDFDB.dotCN.switchinner); let switchinput = entry.querySelector(BDFDB.dotCN.switchinner);
switchinput.checked = guild.id == initguildid; switchinput.checked = guild.id == initguildid;
@ -1141,7 +1137,7 @@ class ServerFolders {
if (oldGuildFolders[i].folderId) { if (oldGuildFolders[i].folderId) {
let newFolder = Object.assign({}, oldGuildFolders[i]); let newFolder = Object.assign({}, oldGuildFolders[i]);
if (oldGuildFolders[i].folderId == folderid) newFolder.guildIds.push(guildid); if (oldGuildFolders[i].folderId == folderid) newFolder.guildIds.push(guildid);
else BDFDB.removeFromArray(newFolder.guildIds, guildid); else BDFDB.ArrayUtils.remove(newFolder.guildIds, guildid);
guildFolders.push(newFolder); guildFolders.push(newFolder);
} }
else if (oldGuildFolders[i].guildIds[0] != guildid) guildFolders.push(oldGuildFolders[i]); else if (oldGuildFolders[i].guildIds[0] != guildid) guildFolders.push(oldGuildFolders[i]);
@ -1159,7 +1155,7 @@ class ServerFolders {
for (let i in oldGuildFolders) { for (let i in oldGuildFolders) {
if (oldGuildFolders[i].folderId == folderid) { if (oldGuildFolders[i].folderId == folderid) {
let newFolder = Object.assign({}, oldGuildFolders[i]); let newFolder = Object.assign({}, oldGuildFolders[i]);
BDFDB.removeFromArray(newFolder.guildIds, guildid); BDFDB.ArrayUtils.remove(newFolder.guildIds, guildid);
guildFolders.push(newFolder); guildFolders.push(newFolder);
guildFolders.push({guildIds:[guildid]}); guildFolders.push({guildIds:[guildid]});
} }
@ -1190,7 +1186,7 @@ class ServerFolders {
} }
setLabelsByLanguage () { setLabelsByLanguage () {
switch (BDFDB.getDiscordLanguage().id) { switch (BDFDB.LanguageUtils.getLanguage().id) {
case "hr": //croatian case "hr": //croatian
return { return {
servercontext_serverfolders_text: "Poslužitelj mapu", servercontext_serverfolders_text: "Poslužitelj mapu",

View File

@ -89,10 +89,10 @@ class ServerHider {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".reset-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => { BDFDB.openConfirmModal(this, "Are you sure you want to reset all servers?", () => {
BDFDB.removeAllData(this, "servers"); BDFDB.removeAllData(this, "servers");
BDFDB.readServerList().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, false);}); BDFDB.GuildUtils.getAll().forEach(info => {if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, false);});
}); });
}); });
return settingspanel; return settingspanel;
@ -122,26 +122,24 @@ class ServerHider {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.readServerList().forEach(info => { BDFDB.GuildUtils.getAll().forEach(info => {
if (info.div.ServerHiderChangeObserver && typeof info.div.ServerHiderChangeObserver.disconnect == "function") info.div.ServerHiderChangeObserver.disconnect(); if (info.div.ServerHiderChangeObserver && typeof info.div.ServerHiderChangeObserver.disconnect == "function") info.div.ServerHiderChangeObserver.disconnect();
if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, true); if (!info.div.getAttribute("folder")) BDFDB.toggleEles(info.div, true);
delete info.div.ServerHiderChanged; delete info.div.ServerHiderChanged;
}); });
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -158,16 +156,16 @@ class ServerHider {
if (document.querySelector(".BDFDB-modal")) return; if (document.querySelector(".BDFDB-modal")) return;
if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(`${this.name}-contextMenuSubItem`)) { if (instance.props && instance.props.target && instance.props.type.indexOf("GUILD_ICON_") == 0 && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_serverhider_text, label: this.labels.context_serverhider_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem`,
render: [BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { render: [BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_openhidemenu_text, label: this.labels.submenu_openhidemenu_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hidemenu-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hidemenu-ContextMenuItem`,
action: e => { action: e => {
@ -175,7 +173,7 @@ class ServerHider {
this.showServerModal(); this.showServerModal();
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.submenu_hideserver_text, label: this.labels.submenu_hideserver_text,
className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hideserver-ContextMenuItem`, className: `BDFDB-ContextMenuItem ${this.name}-ContextMenuItem ${this.name}-hideserver-ContextMenuItem`,
disabled: !(instance.props.guild && !instance.props.target.getAttribute("folder")), disabled: !(instance.props.guild && !instance.props.target.getAttribute("folder")),
@ -207,7 +205,7 @@ class ServerHider {
let container = serverHiderModal.querySelector(".entries"); let container = serverHiderModal.querySelector(".entries");
if (!container) return; if (!container) return;
BDFDB.addChildEventListener(serverHiderModal, "click", ".btn-all", () => { BDFDB.ListenerUtils.addToChildren(serverHiderModal, "click", ".btn-all", () => {
let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox"); let firstcheckbox = serverHiderModal.querySelector(".serverhiderCheckbox");
firstcheckbox.click(); firstcheckbox.click();
serverHiderModal.querySelectorAll(".serverhiderCheckbox").forEach(checkbox => { serverHiderModal.querySelectorAll(".serverhiderCheckbox").forEach(checkbox => {
@ -215,14 +213,14 @@ class ServerHider {
}); });
}); });
for (let info of BDFDB.readServerList()) { for (let info of BDFDB.GuildUtils.getAll()) {
if (!info.div.getAttribute("folder")) { if (!info.div.getAttribute("folder")) {
if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.divider}"></div>`)); if (container.firstElementChild) container.appendChild(BDFDB.htmlToElement(`<div class="${BDFDB.disCN.divider}"></div>`));
let entry = BDFDB.htmlToElement(this.serverEntryMarkup); let entry = BDFDB.htmlToElement(this.serverEntryMarkup);
container.appendChild(entry); container.appendChild(entry);
let name = entry.querySelector(".serverhiderName"); let name = entry.querySelector(".serverhiderName");
name.innerText = info.name || ""; name.innerText = info.name || "";
name.parentElement.insertBefore(BDFDB.createServerDivCopy(info, {click: () => {BDFDB.removeEles(serverHiderModal);}, menu: true, size: 48}), name); name.parentElement.insertBefore(BDFDB.GuildUtils.createCopy(info, {click: () => {BDFDB.removeEles(serverHiderModal);}, menu: true, size: 48}), name);
let hidecheckbox = entry.querySelector(".serverhiderCheckbox"); let hidecheckbox = entry.querySelector(".serverhiderCheckbox");
hidecheckbox.checked = !BDFDB.isEleHidden(info.div); hidecheckbox.checked = !BDFDB.isEleHidden(info.div);
hidecheckbox.addEventListener("click", e => { hidecheckbox.addEventListener("click", e => {
@ -239,20 +237,20 @@ class ServerHider {
if (!guilddiv || guilddiv.getAttribute("folder")) return; if (!guilddiv || guilddiv.getAttribute("folder")) return;
BDFDB.toggleEles(guilddiv, visible); BDFDB.toggleEles(guilddiv, visible);
let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || []; let hiddenservers = BDFDB.loadData("hiddenservers", this, "hiddenservers") || [];
BDFDB.removeFromArray(hiddenservers, info.id); BDFDB.ArrayUtils.remove(hiddenservers, info.id);
if (!visible) { if (!visible) {
if (BDFDB.getReactValue(guilddiv, "return.stateNode.props").unread) this.unreadServer(info.id); if (BDFDB.ReactUtils.getValue(guilddiv, "return.stateNode.props").unread) this.unreadServer(info.id);
hiddenservers.push(info.id); hiddenservers.push(info.id);
} }
BDFDB.saveData("hiddenservers", hiddenservers, this, "hiddenservers"); BDFDB.saveData("hiddenservers", hiddenservers, this, "hiddenservers");
} }
unreadServer (id) { unreadServer (id) {
if (BDFDB.getData("clearNotifications", this, "settings") && !this.isInFolder(id)) BDFDB.markGuildAsRead(id); if (BDFDB.getData("clearNotifications", this, "settings") && !this.isInFolder(id)) BDFDB.GuildUtils.markAsRead(id);
} }
isInFolder (id) { isInFolder (id) {
if (!BDFDB.isPluginEnabled("ServerFolders")) return false; if (!BDFDB.BdUtils.isPluginEnabled("ServerFolders")) return false;
let folders = BDFDB.loadAllData("ServerFolders", "folders"); let folders = BDFDB.loadAllData("ServerFolders", "folders");
for (let folderid in folders) if ((folders[folderid].servers || []).includes(id)) return true; for (let folderid in folders) if ((folders[folderid].servers || []).includes(id)) return true;
return false; return false;

View File

@ -152,13 +152,11 @@ class ShowHiddenChannels {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this, "Channels"); BDFDB.ModuleUtils.forceAllUpdates(this, "Channels");
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -166,7 +164,7 @@ class ShowHiddenChannels {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".container-hidden"); BDFDB.removeEles(".container-hidden");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -191,7 +189,7 @@ class ShowHiddenChannels {
processStandardSidebarView (instance, wrapper, returnvalue) { processStandardSidebarView (instance, wrapper, returnvalue) {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.WebModules.forceAllUpdates(this, "Channels"); BDFDB.ModuleUtils.forceAllUpdates(this, "Channels");
} }
} }
@ -220,7 +218,7 @@ class ShowHiddenChannels {
} }
} }
} }
if (BDFDB.isUserAllowedTo("VIEW_CHANNEL", BDFDB.myData.id, channel.id)) isHidden = false; if (BDFDB.UserUtils.can("VIEW_CHANNEL", BDFDB.UserUtils.me.id, channel.id)) isHidden = false;
if (isHidden) hiddenChannels[channel.type].push(channel); if (isHidden) hiddenChannels[channel.type].push(channel);
} }
} }
@ -229,7 +227,7 @@ class ShowHiddenChannels {
var count = 0; var count = 0;
for (let type in BDFDB.DiscordConstants.ChannelTypes) { for (let type in BDFDB.DiscordConstants.ChannelTypes) {
if (this.settingsMap[type] && !settings[this.settingsMap[type]]) hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]] = []; if (this.settingsMap[type] && !settings[this.settingsMap[type]]) hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]] = [];
BDFDB.sortArrayByKey(hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]], "name"); BDFDB.ArrayUtils.keySort(hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]], "name");
count += hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]].length; count += hiddenChannels[BDFDB.DiscordConstants.ChannelTypes[type]].length;
} }
hiddenChannels.count = count; hiddenChannels.count = count;
@ -256,8 +254,8 @@ class ShowHiddenChannels {
} }
let channellist = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller); let channellist = document.querySelector(BDFDB.dotCNS.channels + BDFDB.dotCN.scroller);
if (channellist) { if (channellist) {
BDFDB.removeEventListener(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault); BDFDB.ListenerUtils.remove(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault);
if (settings.showForNormal) BDFDB.addEventListener(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault, e => { if (settings.showForNormal) BDFDB.ListenerUtils.add(this, channellist, "mouseenter", BDFDB.dotCNC.channelcontainerdefault + BDFDB.dotCN.categorycontainerdefault, e => {
if (!BDFDB.containsClass(e.currentTarget, "hidden-channel")) { if (!BDFDB.containsClass(e.currentTarget, "hidden-channel")) {
var channel = BDFDB.getKeyInformation({"node":e.currentTarget,"key":"channel"}); var channel = BDFDB.getKeyInformation({"node":e.currentTarget,"key":"channel"});
if (channel) this.showAccessRoles(guild, channel, e, true); if (channel) this.showAccessRoles(guild, channel, e, true);
@ -274,11 +272,11 @@ class ShowHiddenChannels {
iconinner.setAttribute("d", this.channelIcons[type] ? this.channelIcons[type] : this.channelIcons.DEFAULT); iconinner.setAttribute("d", this.channelIcons[type] ? this.channelIcons[type] : this.channelIcons.DEFAULT);
iconinner.setAttribute("mask", `url(#showHiddenChannelsMask${info.id})`); iconinner.setAttribute("mask", `url(#showHiddenChannelsMask${info.id})`);
this.setReactInstanceOfChannel(info, channel); this.setReactInstanceOfChannel(info, channel);
BDFDB.addChildEventListener(channel, "mouseenter mouseleave", BDFDB.dotCN.channelwrapper, e => { BDFDB.ListenerUtils.addToChildren(channel, "mouseenter mouseleave", BDFDB.dotCN.channelwrapper, e => {
this.showAccessRoles(guild, info, e, false); this.showAccessRoles(guild, info, e, false);
}); });
channel.addEventListener("click", () => { channel.addEventListener("click", () => {
BDFDB.showToast(`You can not ${this.channelMessage[type] ? this.channelMessage[type] : this.channelMessage.DEFAULT}&nbsp;&nbsp;<strong>${BDFDB.encodeToHTML(info.name)}</strong>.`, {type:"error", html:true}); BDFDB.NotificationUtils.toast(`You can not ${this.channelMessage[type] ? this.channelMessage[type] : this.channelMessage.DEFAULT}&nbsp;&nbsp;<strong>${BDFDB.encodeToHTML(info.name)}</strong>.`, {type:"error", html:true});
}); });
channel.addEventListener("contextmenu", e => { channel.addEventListener("contextmenu", e => {
this.createHiddenObjContextMenu(guild, info, type, e); this.createHiddenObjContextMenu(guild, info, type, e);
@ -299,20 +297,20 @@ class ShowHiddenChannels {
} }
setReactInstanceOfChannel (guild, div) { setReactInstanceOfChannel (guild, div) {
var reactInstance = BDFDB.React.createElement(div); var reactInstance = BDFDB.ReactUtils.createElement(div);
reactInstance.memoizedProps = {channel:guild}; reactInstance.memoizedProps = {channel:guild};
div.__reactInternalInstance = reactInstance; div.__reactInternalInstance = reactInstance;
} }
createHiddenObjContextMenu (guild, channel, type, e) { createHiddenObjContextMenu (guild, channel, type, e) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
BDFDB.openChannelContextMenu(channel, e); BDFDB.ChannelUtils.openMenu(channel, e);
} }
showAccessRoles (guild, channel, e, allowed) { showAccessRoles (guild, channel, e, allowed) {
if ((e.type != "mouseenter" && e.type != "mouseover") || !guild || !channel) return; if ((e.type != "mouseenter" && e.type != "mouseover") || !guild || !channel) return;
var settings = BDFDB.getAllData(this, "settings"); var settings = BDFDB.getAllData(this, "settings");
var myMember = BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.myData.id); var myMember = BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.UserUtils.me.id);
var allowedRoles = [], allowedUsers = [], overwrittenRoles = [], deniedRoles = [], deniedUsers = []; var allowedRoles = [], allowedUsers = [], overwrittenRoles = [], deniedRoles = [], deniedUsers = [];
var everyoneDenied = false; var everyoneDenied = false;
for (let id in channel.permissionOverwrites) { for (let id in channel.permissionOverwrites) {
@ -358,7 +356,7 @@ class ShowHiddenChannels {
let member = BDFDB.LibraryModules.MemberStore.getMember(guild.id, voicestate.userId); let member = BDFDB.LibraryModules.MemberStore.getMember(guild.id, voicestate.userId);
if (user && member) { if (user && member) {
let color = member.colorString ? BDFDB.colorCONVERT(member.colorString, "RGBCOMP") : [255,255,255]; let color = member.colorString ? BDFDB.colorCONVERT(member.colorString, "RGBCOMP") : [255,255,255];
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-voiceuser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.getUserAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(member.nick || user.username)}</div></div>`; htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-voiceuser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.UserUtils.getAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(member.nick || user.username)}</div></div>`;
} }
} }
htmlString += `</div>`; htmlString += `</div>`;
@ -380,7 +378,7 @@ class ShowHiddenChannels {
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Allowed Users:</div><div class="${BDFDB.disCNS.flex2 + BDFDB.disCN.wrap}">`; htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Allowed Users:</div><div class="${BDFDB.disCNS.flex2 + BDFDB.disCN.wrap}">`;
for (let user of allowedUsers) { for (let user of allowedUsers) {
let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255]; let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255];
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-alloweduser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.getUserAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick || user.name)}</div></div>`; htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-alloweduser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.UserUtils.getAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick || user.name)}</div></div>`;
} }
htmlString += `</div>`; htmlString += `</div>`;
} }
@ -396,13 +394,13 @@ class ShowHiddenChannels {
htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Denied Users:</div><div class="${BDFDB.disCNS.flex2 + BDFDB.disCN.wrap}">`; htmlString += `<div class="${BDFDB.disCN.marginbottom4}">Denied Users:</div><div class="${BDFDB.disCNS.flex2 + BDFDB.disCN.wrap}">`;
for (let user of deniedUsers) { for (let user of deniedUsers) {
let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255]; let color = user.colorString ? BDFDB.colorCONVERT(user.colorString, "RGBCOMP") : [255,255,255];
htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-denieduser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.getUserAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick || user.name)}</div></div>`; htmlString += `<div class="${BDFDB.disCNS.userpopoutrole + BDFDB.disCNS.flex2 + BDFDB.disCNS.aligncenter} SHC-denieduser" style="padding-left: 0; border-color: rgba(${color[0]}, ${color[1]}, ${color[2]}, 0.6);"><div class="${BDFDB.disCN.avatarwrapper}" role="img" aria-label="${user.username}" aria-hidden="false" style="width: 22px; height: 18px; z-index: 1003;"><svg width="18" height="18" viewBox="0 0 18 18" class="${BDFDB.disCN.avatarmask}" aria-hidden="true"><foreignObject x="0" y="0" width="18" height="18" mask="url(#svg-mask-avatar-default)"><img src="${BDFDB.UserUtils.getAvatar(user.id)}" alt=" " class="${BDFDB.disCN.avatar}" aria-hidden="true"></foreignObject></svg></div><div class="${BDFDB.disCN.userpopoutrolecircle}" style="background-color: rgb(${color[0]}, ${color[1]}, ${color[2]});"></div><div class="${BDFDB.disCNS.userpopoutrolename}">${BDFDB.encodeToHTML(user.nick || user.name)}</div></div>`;
} }
htmlString += `</div>`; htmlString += `</div>`;
} }
if (htmlString) { if (htmlString) {
var width = window.outerWidth/2; var width = window.outerWidth/2;
var tooltip = BDFDB.createTooltip(htmlString, e.currentTarget, {type:"right", selector:"showhiddenchannels-tooltip", html:true, style:`max-width: ${width < 200 ? 400 : width}px !important;`, delay:BDFDB.getData("hoverDelay", this, "amounts")}); var tooltip = BDFDB.TooltipUtils.create(e.currentTarget, htmlString, {type:"right", selector:"showhiddenchannels-tooltip", html:true, style:`max-width: ${width < 200 ? 400 : width}px !important;`, delay:BDFDB.getData("hoverDelay", this, "amounts")});
var style = getComputedStyle(e.currentTarget); var style = getComputedStyle(e.currentTarget);
tooltip.style.setProperty("top", BDFDB.getRects(tooltip).top - style.paddingBottom.replace("px","")/2 + style.paddingTop.replace("px","")/2 + "px"); tooltip.style.setProperty("top", BDFDB.getRects(tooltip).top - style.paddingBottom.replace("px","")/2 + style.paddingTop.replace("px","")/2 + "px");
} }

View File

@ -87,13 +87,11 @@ class ShowImageDetails {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -102,7 +100,7 @@ class ShowImageDetails {
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);}); document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -120,14 +118,14 @@ class ShowImageDetails {
} }
processLazyImageZoomable (instance, image, returnvalue) { processLazyImageZoomable (instance, image, returnvalue) {
let attachment = BDFDB.getReactValue(instance, "_reactInternalFiber.return.return.memoizedProps.attachment"); let attachment = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.return.memoizedProps.attachment");
if (attachment && !attachment.filename.endsWith(".bdemote.png") && !attachment.filename.endsWith(".bdemote.gif")) { if (attachment && !attachment.filename.endsWith(".bdemote.png") && !attachment.filename.endsWith(".bdemote.gif")) {
if (BDFDB.containsClass(image.parentElement.parentElement, BDFDB.disCN.spoilercontainer, BDFDB.disCN.spoilertext, false)) image = image.parentElement.parentElement; if (BDFDB.containsClass(image.parentElement.parentElement, BDFDB.disCN.spoilercontainer, BDFDB.disCN.spoilertext, false)) image = image.parentElement.parentElement;
BDFDB.addClass(image, "image-details-added"); BDFDB.addClass(image, "image-details-added");
image.removeEventListener("mouseenter", image.mouseenterShowImageDetails); image.removeEventListener("mouseenter", image.mouseenterShowImageDetails);
if (BDFDB.getData("showOnHover", this, "settings")) { if (BDFDB.getData("showOnHover", this, "settings")) {
image.mouseenterShowImageDetails = () => { image.mouseenterShowImageDetails = () => {
BDFDB.createTooltip(`<div class="image-details-tooltip-name">${attachment.filename}</div><div class="image-details-tooltip-size">${BDFDB.formatBytes(attachment.size)}</div><div class="image-details-tooltip-dimensions">${attachment.width}x${attachment.height}px</div>`, image, {type:"right", html:true, selector:"image-details-tooltip", delay:BDFDB.getData("hoverDelay", this, "amounts")}); BDFDB.TooltipUtils.create(image, `<div class="image-details-tooltip-name">${attachment.filename}</div><div class="image-details-tooltip-size">${BDFDB.formatBytes(attachment.size)}</div><div class="image-details-tooltip-dimensions">${attachment.width}x${attachment.height}px</div>`, {type:"right", html:true, selector:"image-details-tooltip", delay:BDFDB.getData("hoverDelay", this, "amounts")});
}; };
image.addEventListener("mouseenter", image.mouseenterShowImageDetails); image.addEventListener("mouseenter", image.mouseenterShowImageDetails);
} }
@ -145,7 +143,7 @@ class ShowImageDetails {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);}); document.querySelectorAll(".image-details-added").forEach(image => {this.resetImage(image);});
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }
} }

View File

@ -81,8 +81,8 @@ class SpellCheck {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".remove-word", e => {this.removeFromOwnDictionarye;}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-word", e => {this.removeFromOwnDictionarye;});
BDFDB.addEventListener(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => { BDFDB.ListenerUtils.add(this, settingspanel, "click", BDFDB.dotCN.selectcontrol, e => {
BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages); BDFDB.openDropdownMenu(e, this.saveSelectChoice.bind(this), this.createSelectChoice.bind(this), this.languages);
}); });
return settingspanel; return settingspanel;
@ -112,17 +112,15 @@ class SpellCheck {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.languages = Object.assign({}, BDFDB.languages); this.languages = Object.assign({}, BDFDB.LanguageUtils.languages);
this.languages = BDFDB.filterObject(this.languages, (lang) => {return lang.dic == true ? lang : null}); this.languages = BDFDB.ObjectUtils.filter(this.languages, (lang) => {return lang.dic == true ? lang : null});
this.setDictionary(BDFDB.getData("dictionaryLanguage", this, "choices")); this.setDictionary(BDFDB.getData("dictionaryLanguage", this, "choices"));
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -134,7 +132,7 @@ class SpellCheck {
this.killLanguageToast(); this.killLanguageToast();
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -173,7 +171,7 @@ class SpellCheck {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
let items = []; let items = [];
let similarWords = this.getSimilarWords(word.toLowerCase().trim()); let similarWords = this.getSimilarWords(word.toLowerCase().trim());
for (let suggestion of similarWords.sort()) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { for (let suggestion of similarWords.sort()) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: suggestion, label: suggestion,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-suggestion-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-suggestion-contextMenuItem`,
action: e => { action: e => {
@ -181,18 +179,18 @@ class SpellCheck {
this.replaceWord(textarea, word, suggestion); this.replaceWord(textarea, word, suggestion);
} }
})); }));
if (!items.length) items.push(BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.similarwordssubmenu_none_text, label: this.labels.similarwordssubmenu_none_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-none-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-none-contextMenuItem`,
disabled: true disabled: true
})); }));
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: BDFDB.LanguageUtils.LanguageStrings.SPELLCHECK, label: BDFDB.LanguageUtils.LanguageStrings.SPELLCHECK,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-spellcheck-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-spellcheck-contextMenuSubItem`,
render: [ render: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_spellcheck_text, label: this.labels.context_spellcheck_text,
hint: word, hint: word,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addword-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-addword-contextMenuItem`,
@ -201,7 +199,7 @@ class SpellCheck {
this.addToOwnDictionary(word); this.addToOwnDictionary(word);
} }
}), }),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
label: this.labels.context_similarwords_text, label: this.labels.context_similarwords_text,
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-suggestions-contextMenuSubItem`, className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-suggestions-contextMenuSubItem`,
render: items render: items
@ -245,12 +243,12 @@ class SpellCheck {
BDFDB.addClass(wrapper, "spellcheck-added"); BDFDB.addClass(wrapper, "spellcheck-added");
updateSpellcheck(); updateSpellcheck();
BDFDB.addEventListener(this, textarea, "keyup", e => { BDFDB.ListenerUtils.add(this, textarea, "keyup", e => {
clearTimeout(textarea.spellchecktimeout); clearTimeout(textarea.spellchecktimeout);
if (textarea.value) textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100); if (textarea.value) textarea.spellchecktimeout = setTimeout(() => {updateSpellcheck();},100);
else updateSpellcheck(); else updateSpellcheck();
}); });
BDFDB.addEventListener(this, textarea, "scroll", e => { BDFDB.ListenerUtils.add(this, textarea, "scroll", e => {
spellcheck.scrollTop = textarea.scrollTop; spellcheck.scrollTop = textarea.scrollTop;
}); });
} }
@ -279,7 +277,7 @@ class SpellCheck {
if (!ownDictionary.includes(wordlow)) { if (!ownDictionary.includes(wordlow)) {
ownDictionary.push(wordlow); ownDictionary.push(wordlow);
BDFDB.saveData(lang, ownDictionary, this, "owndics"); BDFDB.saveData(lang, ownDictionary, this, "owndics");
BDFDB.showToast(this.labels.toast_wordadd_text ? this.labels.toast_wordadd_text.replace("${word}", word).replace("${dicname}", this.languages[lang].name) : "", {type:"success"}); BDFDB.NotificationUtils.toast(this.labels.toast_wordadd_text ? this.labels.toast_wordadd_text.replace("${word}", word).replace("${dicname}", this.languages[lang].name) : "", {type:"success"});
this.dictionary = this.langDictionary.concat(ownDictionary); this.dictionary = this.langDictionary.concat(ownDictionary);
} }
} }
@ -291,7 +289,7 @@ class SpellCheck {
entry.remove(); entry.remove();
var lang = BDFDB.getData("dictionaryLanguage", this, "choices"); var lang = BDFDB.getData("dictionaryLanguage", this, "choices");
var ownDictionary = BDFDB.loadData(lang, this, "owndics") || []; var ownDictionary = BDFDB.loadData(lang, this, "owndics") || [];
BDFDB.removeFromArray(ownDictionary, word); BDFDB.ArrayUtils.remove(ownDictionary, word);
BDFDB.saveData(lang, ownDictionary, this, "owndics"); BDFDB.saveData(lang, ownDictionary, this, "owndics");
this.dictionary = this.langDictionary.concat(ownDictionary); this.dictionary = this.langDictionary.concat(ownDictionary);
} }
@ -321,7 +319,7 @@ class SpellCheck {
setDictionary (lang) { setDictionary (lang) {
this.dictionary = BDFDB.loadData(lang, this, "owndics") || []; this.dictionary = BDFDB.loadData(lang, this, "owndics") || [];
this.killLanguageToast(); this.killLanguageToast();
this.languageToast = BDFDB.showToast("Grabbing dictionary (" + this.languages[lang].name + "). Please wait", {timeout:0}); this.languageToast = BDFDB.NotificationUtils.toast("Grabbing dictionary (" + this.languages[lang].name + "). Please wait", {timeout:0});
this.languageToast.interval = setInterval(() => { this.languageToast.interval = setInterval(() => {
this.languageToast.textContent = this.languageToast.textContent.indexOf(".....") > -1 ? "Grabbing dictionary (" + this.languages[lang].name + "). Please wait" : this.languageToast.textContent + "."; this.languageToast.textContent = this.languageToast.textContent.indexOf(".....") > -1 ? "Grabbing dictionary (" + this.languages[lang].name + "). Please wait" : this.languageToast.textContent + ".";
},500); },500);
@ -329,14 +327,14 @@ class SpellCheck {
BDFDB.LibraryRequires.request("https://mwittrien.github.io/BetterDiscordAddons/Plugins/SpellCheck/dic/" + lang + ".dic", (error, response, result) => { BDFDB.LibraryRequires.request("https://mwittrien.github.io/BetterDiscordAddons/Plugins/SpellCheck/dic/" + lang + ".dic", (error, response, result) => {
if (error || (response && result.toLowerCase().indexOf("<!doctype html>") > -1)) { if (error || (response && result.toLowerCase().indexOf("<!doctype html>") > -1)) {
this.killLanguageToast(); this.killLanguageToast();
BDFDB.showToast("Failed to grab dictionary (" + this.languages[lang].name + ").", {type: "error"}); BDFDB.NotificationUtils.toast("Failed to grab dictionary (" + this.languages[lang].name + ").", {type: "error"});
} }
else if (response && this.languageToast.lang == lang) { else if (response && this.languageToast.lang == lang) {
this.langDictionary = result.split("\n"); this.langDictionary = result.split("\n");
this.dictionary = this.langDictionary.concat(this.dictionary); this.dictionary = this.langDictionary.concat(this.dictionary);
this.dictionary = this.dictionary.map(word => word.toLowerCase()); this.dictionary = this.dictionary.map(word => word.toLowerCase());
this.killLanguageToast(); this.killLanguageToast();
BDFDB.showToast("Successfully grabbed dictionary (" + this.languages[lang].name + ").", {type: "success"}); BDFDB.NotificationUtils.toast("Successfully grabbed dictionary (" + this.languages[lang].name + ").", {type: "success"});
} }
}); });
} }

View File

@ -53,62 +53,30 @@ class StalkerNotifications {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.openConfirmModal(this, "StalkerNotifications has been discontinued and was merged with FriendNotifications. To download FriendNotifications click the 'OK' button bellow. This will delete StalkerNotifications and download FriendNotifications.", "Update Notification", () => { BDFDB.openConfirmModal(this, "StalkerNotifications has been discontinued and was merged with FriendNotifications. To download FriendNotifications click the 'OK' button bellow. This will delete StalkerNotifications and download FriendNotifications.", "Update Notification", () => {
require("request")("https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js", (error, response, body) => { require("request")("https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js", (error, response, body) => {
if (error) BDFDB.showToast(`Unable to download FriendNotifications.plugin.js.`, {type:"error"}); if (error) BDFDB.NotificationUtils.toast(`Unable to download FriendNotifications.plugin.js.`, {type:"error"});
else { else {
require("fs").writeFile(require("path").join(BDFDB.getPluginsFolder(), "FriendNotifications.plugin.js"), body, (error) => { require("fs").writeFile(require("path").join(BDFDB.BdUtils.getPluginsFolder(), "FriendNotifications.plugin.js"), body, (error) => {
if (!error) { if (!error) {
BDFDB.showToast(`Successfully downloaded FriendNotifications.plugin.js.`, {type:"success"}); BDFDB.NotificationUtils.toast(`Successfully downloaded FriendNotifications.plugin.js.`, {type:"success"});
require("fs").unlinkSync(require("path").join(BDFDB.getPluginsFolder(), "StalkerNotifications.plugin.js")); require("fs").unlinkSync(require("path").join(BDFDB.BdUtils.getPluginsFolder(), "StalkerNotifications.plugin.js"));
} }
}); });
} }
}); });
}); });
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
}
}
// begin of own functions
}
BDFDB.openConfirmModal(this, "StalkerNotifications has been discontinued and was merged with FriendNotifications. To download FriendNotifications click the 'OK' button bellow. This will delete StalkerNotifications and download FriendNotifications.", "Update Notification", () => {
require("request")("https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/FriendNotifications/FriendNotifications.plugin.js", (error, response, body) => {
if (error) BDFDB.showToast(`Unable to download FriendNotifications.plugin.js.`, {type:"error"});
else {
require("fs").writeFile(require("path").join(BDFDB.getPluginsFolder(), "FriendNotifications.plugin.js"), body, (error) => {
if (!error) {
BDFDB.showToast(`Successfully downloaded FriendNotifications.plugin.js.`, {type:"success"});
require("fs").unlinkSync(require("path").join(BDFDB.getPluginsFolder(), "StalkerNotifications.plugin.js"));
}
});
}
});
});
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
}
stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true;
BDFDB.unloadMessage(this);
} }
} }

View File

@ -39,18 +39,16 @@ class SteamProfileLink {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.addEventListener(this, document, "click", "a[href^='https://steamcommunity.'], a[href^='https://store.steampowered.'], a[href*='a.akamaihd.net/'][href*='steam']", e => {this.openInSteam(e, e.currentTarget.href);}); BDFDB.ListenerUtils.add(this, document, "click", "a[href^='https://steamcommunity.'], a[href^='https://store.steampowered.'], a[href*='a.akamaihd.net/'][href*='steam']", e => {this.openInSteam(e, e.currentTarget.href);});
BDFDB.addEventListener(this, document, "click", BDFDB.dotCN.cardstore + BDFDB.dotCN.cardstoreinteractive, e => { BDFDB.ListenerUtils.add(this, document, "click", BDFDB.dotCN.cardstore + BDFDB.dotCN.cardstoreinteractive, e => {
let news = BDFDB.getReactValue(e.currentTarget, "return.return.memoizedProps.news"); let news = BDFDB.ReactUtils.getValue(e.currentTarget, "return.return.memoizedProps.news");
if (news && news.url && news.url.includes("steam")) this.openInSteam(e, news.url); if (news && news.url && news.url.includes("steam")) this.openInSteam(e, news.url);
}); });
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
@ -60,12 +58,12 @@ class SteamProfileLink {
BDFDB.removeEles(".urlCheckFrame"); BDFDB.removeEles(".urlCheckFrame");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
openInSteam (e, url) { openInSteam (e, url) {
BDFDB.stopEvent(e); BDFDB.ListenerUtils.stopEvent(e);
BDFDB.LibraryRequires.request(url, (error, response, body) => { BDFDB.LibraryRequires.request(url, (error, response, body) => {
if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href)); if (BDFDB.LibraryRequires.electron.shell.openExternal("steam://openurl/" + response.request.href));
else window.open(response.request.href, "_blank"); else window.open(response.request.href, "_blank");

View File

@ -329,11 +329,11 @@ class ThemeRepo {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".btn-addtheme", () => {this.addThemeToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", "#input-themeurl", e => {if (e.which == 13) this.addThemeToOwnList(settingspanel);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", "#input-themeurl", e => {if (e.which == 13) this.addThemeToOwnList(settingspanel);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);}); BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);});
BDFDB.addEventListener(this, settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);}) BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-all", () => {this.removeAllFromOwnList(settingspanel);})
BDFDB.addEventListener(this, settingspanel, "click", ".refresh-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".refresh-button", () => {
this.loading = {is:false, timeout:null, amount:0}; this.loading = {is:false, timeout:null, amount:0};
this.loadThemes(); this.loadThemes();
}); });
@ -365,17 +365,15 @@ class ThemeRepo {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.loadThemes(); this.loadThemes();
this.updateInterval = setInterval(() => {this.checkForNewThemes();},1000*60*30); this.updateInterval = setInterval(() => {this.checkForNewThemes();},1000*60*30);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -388,7 +386,7 @@ class ThemeRepo {
BDFDB.removeEles("iframe.discordPreview",".themerepo-notice",".bd-themerepobutton",".themerepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty"); BDFDB.removeEles("iframe.discordPreview",".themerepo-notice",".bd-themerepobutton",".themerepo-loadingicon",BDFDB.dotCN.app + " > .repo-loadingwrapper:empty");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -397,7 +395,7 @@ class ThemeRepo {
onUserSettingsCogContextMenu (instance, menu, returnvalue) { onUserSettingsCogContextMenu (instance, menu, returnvalue) {
setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) { setImmediate(() => {for (let child of returnvalue.props.children) if (child && child.props && child.props.label == "BandagedBD" && Array.isArray(child.props.render)) {
const repoItem = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { const repoItem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: "Theme Repo", label: "Theme Repo",
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-repo-contextMenuItem`,
action: e => { action: e => {
@ -419,7 +417,7 @@ class ThemeRepo {
this.openThemeRepoModal() this.openThemeRepoModal()
}); });
repoButton.addEventListener("mouseenter", () => { repoButton.addEventListener("mouseenter", () => {
BDFDB.createTooltip("Open Theme Repo", repoButton, {type:"top",selector:"themerepo-button-tooltip"}); BDFDB.TooltipUtils.create(repoButton, "Open Theme Repo", {type:"top",selector:"themerepo-button-tooltip"});
}); });
folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling); folderbutton.parentElement.insertBefore(repoButton, folderbutton.nextSibling);
} }
@ -437,7 +435,7 @@ class ThemeRepo {
ownlist.push(url); ownlist.push(url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-theme"></div></div>`) let entry = BDFDB.htmlToElement(`<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.vertical + BDFDB.disCNS.directionrow + BDFDB.disCNS.justifystart + BDFDB.disCNS.alignstretch + BDFDB.disCNS.nowrap + BDFDB.disCNS.margintop4 + BDFDB.disCNS.marginbottom4 + BDFDB.disCN.hovercard}"><div class="${BDFDB.disCN.hovercardinner}"><div class="${BDFDB.disCNS.description + BDFDB.disCNS.formtext + BDFDB.disCNS.note + BDFDB.disCNS.margintop4 + BDFDB.disCNS.modedefault + BDFDB.disCNS.primary + BDFDB.disCN.ellipsis} entryurl">${url}</div></div><div class="${BDFDB.disCN.hovercardbutton} remove-theme"></div></div>`)
BDFDB.addChildEventListener(entry, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);}); BDFDB.ListenerUtils.addToChildren(entry, "click", ".remove-theme", e => {this.removeThemeFromOwnList(e);});
themeList.appendChild(entry); themeList.appendChild(entry);
} }
} }
@ -448,7 +446,7 @@ class ThemeRepo {
var url = entry.querySelector(".entryurl").textContent; var url = entry.querySelector(".entryurl").textContent;
entry.remove(); entry.remove();
var ownlist = BDFDB.loadData("ownlist", this, "ownlist") || []; var ownlist = BDFDB.loadData("ownlist", this, "ownlist") || [];
BDFDB.removeFromArray(ownlist, url); BDFDB.ArrayUtils.remove(ownlist, url);
BDFDB.saveData("ownlist", ownlist, this, "ownlist"); BDFDB.saveData("ownlist", ownlist, this, "ownlist");
} }
@ -461,7 +459,7 @@ class ThemeRepo {
openThemeRepoModal (options = {}) { openThemeRepoModal (options = {}) {
if (this.loading.is) { if (this.loading.is) {
BDFDB.showToast(`Themes are still being fetched. Try again in some seconds.`, {type:"danger"}); BDFDB.NotificationUtils.toast(`Themes are still being fetched. Try again in some seconds.`, {type:"danger"});
return; return;
} }
@ -485,10 +483,10 @@ class ThemeRepo {
else if (typeof e.data === "object" && e.data.origin == "DiscordPreview") { else if (typeof e.data === "object" && e.data.origin == "DiscordPreview") {
switch (e.data.reason) { switch (e.data.reason) {
case "OnLoad": case "OnLoad":
var username = BDFDB.myData.username; var username = BDFDB.UserUtils.me.username;
var id = BDFDB.myData.id; var id = BDFDB.UserUtils.me.id;
var discriminator = BDFDB.myData.discriminator; var discriminator = BDFDB.UserUtils.me.discriminator;
var avatar = BDFDB.getUserAvatar(); var avatar = BDFDB.UserUtils.getAvatar();
var nativecss = document.querySelector("head link[rel='stylesheet'][integrity]"); var nativecss = document.querySelector("head link[rel='stylesheet'][integrity]");
nativecss = nativecss && nativecss.href ? nativecss.href : null; nativecss = nativecss && nativecss.href ? nativecss.href : null;
var titlebar = document.querySelector(BDFDB.dotCN.titlebar); var titlebar = document.querySelector(BDFDB.dotCN.titlebar);
@ -537,14 +535,14 @@ class ThemeRepo {
var normalizeinput = themeRepoModal.querySelector("#input-normalize"); var normalizeinput = themeRepoModal.querySelector("#input-normalize");
var customcssinput = themeRepoModal.querySelector("#input-customcss"); var customcssinput = themeRepoModal.querySelector("#input-customcss");
var themefixerinput = themeRepoModal.querySelector("#input-themefixer"); var themefixerinput = themeRepoModal.querySelector("#input-themefixer");
darklightinput.checked = BDFDB.getDiscordTheme() == BDFDB.disCN.themelight; darklightinput.checked = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
normalizeinput.checked = window.settingsCookie["fork-ps-4"] == true; normalizeinput.checked = window.settingsCookie["fork-ps-4"] == true;
customcssinput.checked = false; customcssinput.checked = false;
themefixerinput.checked = false; themefixerinput.checked = false;
themeRepoModal.querySelector("#input-hideupdated").checked = hiddenSettings.updated || options.showOnlyOutdated; themeRepoModal.querySelector("#input-hideupdated").checked = hiddenSettings.updated || options.showOnlyOutdated;
themeRepoModal.querySelector("#input-hideoutdated").checked = hiddenSettings.outdated && !options.showOnlyOutdated; themeRepoModal.querySelector("#input-hideoutdated").checked = hiddenSettings.outdated && !options.showOnlyOutdated;
themeRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || options.showOnlyOutdated; themeRepoModal.querySelector("#input-hidedownloadable").checked = hiddenSettings.downloadable || options.showOnlyOutdated;
if (!BDFDB.isRestartNoMoreEnabled()) themeRepoModal.querySelector("#RNMoption").remove(); if (!BDFDB.BdUtils.isAutoLoadEnabled()) themeRepoModal.querySelector("#RNMoption").remove();
else themeRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "RNMstart"); else themeRepoModal.querySelector("#input-rnmstart").checked = BDFDB.loadData("RNMstart", this, "RNMstart");
if (options.forcedSort && this.sortings.sort[options.forcedSort]) { if (options.forcedSort && this.sortings.sort[options.forcedSort]) {
@ -580,7 +578,7 @@ class ThemeRepo {
}); });
themeRepoModal.querySelector("#download-generated").addEventListener("click", e => { themeRepoModal.querySelector("#download-generated").addEventListener("click", e => {
let inputs = themeRepoModal.querySelectorAll(".varinput"); let inputs = themeRepoModal.querySelectorAll(".varinput");
if (!inputs.length) BDFDB.showToast(`Select a Theme to download a custom generated Theme.`, {type:"error"}); if (!inputs.length) BDFDB.NotificationUtils.toast(`Select a Theme to download a custom generated Theme.`, {type:"error"});
else { else {
let data = this.loadedThemes[this.generatorThemes[themeRepoModal.querySelector(".generator-select " + BDFDB.dotCN.select).getAttribute("value")-1]]; let data = this.loadedThemes[this.generatorThemes[themeRepoModal.querySelector(".generator-select " + BDFDB.dotCN.select).getAttribute("value")-1]];
let css = data.fullcss; let css = data.fullcss;
@ -595,12 +593,12 @@ class ThemeRepo {
this.createThemeFile(data.name + ".theme.css", css); this.createThemeFile(data.name + ".theme.css", css);
} }
}); });
BDFDB.addChildEventListener(themeRepoModal, "click", BDFDB.dotCNC.modalclose + BDFDB.dotCN.backdrop, () => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", BDFDB.dotCNC.modalclose + BDFDB.dotCN.backdrop, () => {
frame.remove(); frame.remove();
document.removeEventListener("keyup", keyPressed); document.removeEventListener("keyup", keyPressed);
window.removeEventListener("message", messageReceived); window.removeEventListener("message", messageReceived);
}); });
BDFDB.addChildEventListener(themeRepoModal, "mouseenter", BDFDB.dotCN.backdrop, e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "mouseenter", BDFDB.dotCN.backdrop, e => {
if (!document.querySelector(BDFDB.dotCN.colorpicker)) { if (!document.querySelector(BDFDB.dotCN.colorpicker)) {
for (let child of themeRepoModal.childNodes) { for (let child of themeRepoModal.childNodes) {
child.style.setProperty("transition", "opacity .5s ease-in-out", "important"); child.style.setProperty("transition", "opacity .5s ease-in-out", "important");
@ -608,35 +606,35 @@ class ThemeRepo {
} }
} }
}); });
BDFDB.addChildEventListener(themeRepoModal, "mouseleave", BDFDB.dotCN.backdrop, e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "mouseleave", BDFDB.dotCN.backdrop, e => {
if (!document.querySelector(BDFDB.dotCN.colorpicker)) { if (!document.querySelector(BDFDB.dotCN.colorpicker)) {
themeRepoModal.childNodes[0].style.setProperty("opacity", "0.85"); themeRepoModal.childNodes[0].style.setProperty("opacity", "0.85");
themeRepoModal.childNodes[1].style.setProperty("opacity", "1"); themeRepoModal.childNodes[1].style.setProperty("opacity", "1");
setTimeout(() => {for (let child of themeRepoModal.childNodes) child.style.removeProperty("transition");}, 500); setTimeout(() => {for (let child of themeRepoModal.childNodes) child.style.removeProperty("transition");}, 500);
} }
}); });
BDFDB.addChildEventListener(themeRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "keyup", BDFDB.dotCN.searchbarinput, () => {
clearTimeout(themeRepoModal.searchTimeout); clearTimeout(themeRepoModal.searchTimeout);
themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000); themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000);
}); });
BDFDB.addChildEventListener(themeRepoModal, "click", BDFDB.dotCN.searchbarclear, () => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", BDFDB.dotCN.searchbarclear, () => {
clearTimeout(themeRepoModal.searchTimeout); clearTimeout(themeRepoModal.searchTimeout);
themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000); themeRepoModal.searchTimeout = setTimeout(() => {this.sortEntries(themeRepoModal);},1000);
}); });
BDFDB.addChildEventListener(themeRepoModal, "change", ".hide-checkbox", e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "change", ".hide-checkbox", e => {
themeRepoModal.updateHidden = true; themeRepoModal.updateHidden = true;
BDFDB.saveData(e.currentTarget.value, e.currentTarget.checked, this, "hidden"); BDFDB.saveData(e.currentTarget.value, e.currentTarget.checked, this, "hidden");
}); });
BDFDB.addChildEventListener(themeRepoModal, "change", "#input-rnmstart", e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "change", "#input-rnmstart", e => {
BDFDB.saveData("RNMstart", e.currentTarget.checked, this, "RNMstart"); BDFDB.saveData("RNMstart", e.currentTarget.checked, this, "RNMstart");
}); });
BDFDB.addChildEventListener(themeRepoModal, "click", ".sort-filter", e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", ".sort-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.sortEntries(themeRepoModal);}); BDFDB.createSortPopout(e.currentTarget, this.sortPopoutMarkup, () => {this.sortEntries(themeRepoModal);});
}); });
BDFDB.addChildEventListener(themeRepoModal, "click", ".order-filter", e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", ".order-filter", e => {
BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(themeRepoModal);}); BDFDB.createSortPopout(e.currentTarget, this.orderPopoutMarkup, () => {this.sortEntries(themeRepoModal);});
}); });
BDFDB.addChildEventListener(themeRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=themes]", e => { BDFDB.ListenerUtils.addToChildren(themeRepoModal, "click", BDFDB.dotCN.tabbaritem + "[tab=themes]", e => {
if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected)) { if (!BDFDB.containsClass(e.currentTarget, BDFDB.disCN.settingsitemselected)) {
if (themeRepoModal.updateHidden) { if (themeRepoModal.updateHidden) {
delete themeRepoModal.updateHidden; delete themeRepoModal.updateHidden;
@ -650,7 +648,7 @@ class ThemeRepo {
themeRepoModal.entries = {}; themeRepoModal.entries = {};
for (let url in this.loadedThemes) { for (let url in this.loadedThemes) {
let theme = this.loadedThemes[url]; let theme = this.loadedThemes[url];
let instTheme = BDFDB.getTheme(theme.name); let instTheme = BDFDB.BdUtils.getTheme(theme.name);
if (instTheme && instTheme.author.toUpperCase() == theme.author.toUpperCase()) theme.state = instTheme.version != theme.version ? 1 : 0; if (instTheme && instTheme.author.toUpperCase() == theme.author.toUpperCase()) theme.state = instTheme.version != theme.version ? 1 : 0;
else theme.state = 2; else theme.state = 2;
let data = { let data = {
@ -761,7 +759,7 @@ class ThemeRepo {
frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"NewTheme",checked:true,css},"*"); frame.contentWindow.postMessage({origin:"ThemeRepo",reason:"NewTheme",checked:true,css},"*");
}, 1000); }, 1000);
}; };
BDFDB.addChildEventListener(container, "change input", ".varinput", updatePreview); BDFDB.ListenerUtils.addToChildren(container, "change input", ".varinput", updatePreview);
BDFDB.initElements(container); BDFDB.initElements(container);
} }
@ -800,18 +798,18 @@ class ThemeRepo {
if (giturl) window.open(giturl, "_blank"); if (giturl) window.open(giturl, "_blank");
}); });
gitbutton.addEventListener("mouseenter", e => { gitbutton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Go to Git", gitbutton, {type:"top",selector:"themerepo-giticon-tooltip"}); BDFDB.TooltipUtils.create(gitbutton, "Go to Git", {type:"top",selector:"themerepo-giticon-tooltip"});
}); });
let trashbutton = entry.querySelector(".trashIcon"); let trashbutton = entry.querySelector(".trashIcon");
trashbutton.addEventListener("click", e => { trashbutton.addEventListener("click", e => {
if (BDFDB.containsClass(entry, "outdated", "updated", false)) { if (BDFDB.containsClass(entry, "outdated", "updated", false)) {
setEntryState(2); setEntryState(2);
this.deleteThemeFile(data); this.deleteThemeFile(data);
if (!BDFDB.isRestartNoMoreEnabled()) this.removeTheme(data); if (!BDFDB.BdUtils.isAutoLoadEnabled()) this.removeTheme(data);
} }
}); });
trashbutton.addEventListener("mouseenter", e => { trashbutton.addEventListener("mouseenter", e => {
BDFDB.createTooltip("Delete Themefile", trashbutton, {type:"top",selector:"themerepo-trashicon-tooltip"}); BDFDB.TooltipUtils.create(trashbutton, "Delete Themefile", {type:"top",selector:"themerepo-trashicon-tooltip"});
}); });
entry.querySelector(".btn-download").addEventListener("click", e => { entry.querySelector(".btn-download").addEventListener("click", e => {
setEntryState(0); setEntryState(0);
@ -855,14 +853,14 @@ class ThemeRepo {
let searchstring = themeRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase(); let searchstring = themeRepoModal.querySelector(BDFDB.dotCN.searchbarinput).value.replace(/[<|>]/g, "").toUpperCase();
let entries = themeRepoModal.entries; let entries = themeRepoModal.entries;
if (themeRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state < 1 ? null : entry;}); if (themeRepoModal.querySelector("#input-hideupdated").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state < 1 ? null : entry;});
if (themeRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state == 1 ? null : entry;}); if (themeRepoModal.querySelector("#input-hideoutdated").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state == 1 ? null : entry;});
if (themeRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.filterObject(entries, entry => {return entry.state > 1 ? null : entry;}); if (themeRepoModal.querySelector("#input-hidedownloadable").checked) entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.state > 1 ? null : entry;});
entries = BDFDB.filterObject(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;}); entries = BDFDB.ObjectUtils.filter(entries, entry => {return entry.search.indexOf(searchstring) > -1 ? entry : null;});
let sortfilter = themeRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option"); let sortfilter = themeRepoModal.querySelector(".sort-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option");
entries = BDFDB.sortObject(entries, sortfilter == "new" && !themeRepoModal.querySelector(".newentries-tag") ? "name" : sortfilter); entries = BDFDB.ObjectUtils.sort(entries, sortfilter == "new" && !themeRepoModal.querySelector(".newentries-tag") ? "name" : sortfilter);
if (themeRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.reverseObject(entries); if (themeRepoModal.querySelector(".order-filter " + BDFDB.dotCN.quickselectvalue).getAttribute("option") == "desc") entries = BDFDB.ObjectUtils.reverse(entries);
let entrypositions = Object.keys(entries); let entrypositions = Object.keys(entries);
@ -915,7 +913,9 @@ class ThemeRepo {
} }
var loadingicon = BDFDB.htmlToElement(this.themeRepoIconMarkup); var loadingicon = BDFDB.htmlToElement(this.themeRepoIconMarkup);
BDFDB.addClass(loadingicon, "themerepo-loadingicon"); BDFDB.addClass(loadingicon, "themerepo-loadingicon");
loadingicon.addEventListener("mouseenter", () => {BDFDB.createTooltip(this.getLoadingTooltipText(),loadingicon,{type:"left",delay:500,style:"max-width:unset;",selector:"themerepo-loading-tooltip"});}) loadingicon.addEventListener("mouseenter", () => {
BDFDB.TooltipUtils.create(loadingicon, this.getLoadingTooltipText(), {type:"left", delay:500, style:"max-width:unset;", selector:"themerepo-loading-tooltip"});
});
loadingiconwrapper.appendChild(loadingicon); loadingiconwrapper.appendChild(loadingicon);
getThemeInfo(() => { getThemeInfo(() => {
@ -928,11 +928,11 @@ class ThemeRepo {
clearTimeout(this.loading.timeout); clearTimeout(this.loading.timeout);
this.loading = {is:false, timeout:null, amount:this.loading.amount}; this.loading = {is:false, timeout:null, amount:this.loading.amount};
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Themes."); console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Finished fetching Themes.");
if (document.querySelector(".bd-themerepobutton")) BDFDB.showToast(`Finished fetching Themes.`, {type:"success"}); if (document.querySelector(".bd-themerepobutton")) BDFDB.NotificationUtils.toast(`Finished fetching Themes.`, {type:"success"});
if ((settings.notifyOutdated || settings.notifyOutdated == undefined) && outdated > 0) { if ((settings.notifyOutdated || settings.notifyOutdated == undefined) && outdated > 0) {
var oldbarbutton = document.querySelector(".themerepo-outdate-notice " + BDFDB.dotCN.noticedismiss); var oldbarbutton = document.querySelector(".themerepo-outdate-notice " + BDFDB.dotCN.noticedismiss);
if (oldbarbutton) oldbarbutton.click(); if (oldbarbutton) oldbarbutton.click();
var bar = BDFDB.createNotificationsBar(`${outdated} of your Themes ${outdated == 1 ? "is" : "are"} outdated. Check:`,{type:"danger",btn:"ThemeRepo",selector:"themerepo-notice themerepo-outdate-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`${outdated} of your Themes ${outdated == 1 ? "is" : "are"} outdated. Check:`,{type:"danger",btn:"ThemeRepo",selector:"themerepo-notice themerepo-outdate-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
this.openThemeRepoModal({showOnlyOutdated:true}); this.openThemeRepoModal({showOnlyOutdated:true});
bar.querySelector(BDFDB.dotCN.noticedismiss).click(); bar.querySelector(BDFDB.dotCN.noticedismiss).click();
@ -941,19 +941,19 @@ class ThemeRepo {
if ((settings.notifyNewentries || settings.notifyNewentries == undefined) && newentries > 0) { if ((settings.notifyNewentries || settings.notifyNewentries == undefined) && newentries > 0) {
var oldbarbutton = document.querySelector(".themerepo-newentries-notice " + BDFDB.dotCN.noticedismiss); var oldbarbutton = document.querySelector(".themerepo-newentries-notice " + BDFDB.dotCN.noticedismiss);
if (oldbarbutton) oldbarbutton.click(); if (oldbarbutton) oldbarbutton.click();
var bar = BDFDB.createNotificationsBar(`There ${newentries == 1 ? "is" : "are"} ${newentries} new Theme${newentries == 1 ? "" : "s"} in the Repo. Check:`, {type:"success", btn:"ThemeRepo", selector:"themerepo-notice themerepo-newentries-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`There ${newentries == 1 ? "is" : "are"} ${newentries} new Theme${newentries == 1 ? "" : "s"} in the Repo. Check:`, {type:"success", btn:"ThemeRepo", selector:"themerepo-notice themerepo-newentries-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
this.openThemeRepoModal({forcedSort:"new",forcedOrder:"asc"}); this.openThemeRepoModal({forcedSort:"new",forcedOrder:"asc"});
bar.querySelector(BDFDB.dotCN.noticedismiss).click(); bar.querySelector(BDFDB.dotCN.noticedismiss).click();
}); });
} }
if (BDFDB.myData.id == "278543574059057154") { if (BDFDB.UserUtils.me.id == "278543574059057154") {
let wrongUrls = []; let wrongUrls = [];
for (let url of this.foundThemes) if (url && !this.loadedThemes[url] && !wrongUrls.includes(url)) wrongUrls.push(url); for (let url of this.foundThemes) if (url && !this.loadedThemes[url] && !wrongUrls.includes(url)) wrongUrls.push(url);
if (wrongUrls.length > 0) { if (wrongUrls.length > 0) {
var bar = BDFDB.createNotificationsBar(`ThemeRepo: ${wrongUrls.length} Theme${wrongUrls.length > 1 ? "s" : ""} could not be loaded.`, {type:"danger", btn:"List", selector:"themerepo-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")}); var bar = BDFDB.NotificationUtils.notice(`ThemeRepo: ${wrongUrls.length} Theme${wrongUrls.length > 1 ? "s" : ""} could not be loaded.`, {type:"danger", btn:"List", selector:"themerepo-notice", customicon:this.themeRepoIconMarkup.replace(/#7289da/gi,"#FFF").replace(/#7f8186/gi,"#B9BBBE")});
bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => { bar.querySelector(BDFDB.dotCN.noticebutton).addEventListener("click", e => {
var toast = BDFDB.showToast(wrongUrls.join("\n"),{type:"error"}); var toast = BDFDB.NotificationUtils.toast(wrongUrls.join("\n"),{type:"error"});
toast.style.overflow = "hidden"; toast.style.overflow = "hidden";
console.log(wrongUrls.length == 1 ? wrongUrls[0] : wrongUrls); console.log(wrongUrls.length == 1 ? wrongUrls[0] : wrongUrls);
}); });
@ -976,7 +976,7 @@ class ThemeRepo {
let requesturl = NFLDreplace && url.includes("NFLD99/Better-Discord/master/Themes") ? url.replace("master/Themes", "master/" + NFLDreplace) : url; let requesturl = NFLDreplace && url.includes("NFLD99/Better-Discord/master/Themes") ? url.replace("master/Themes", "master/" + NFLDreplace) : url;
BDFDB.LibraryRequires.request(requesturl, (error, response, body) => { BDFDB.LibraryRequires.request(requesturl, (error, response, body) => {
if (!response) { if (!response) {
if (url && BDFDB.getAllIndexes(this.foundThemes, url).length < 2) this.foundThemes.push(url); if (url && BDFDB.ArrayUtils.getAllIndexes(this.foundThemes, url).length < 2) this.foundThemes.push(url);
} }
else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
let theme = {}; let theme = {};
@ -1009,7 +1009,7 @@ class ThemeRepo {
theme.url = url; theme.url = url;
theme.requesturl = requesturl; theme.requesturl = requesturl;
this.loadedThemes[url] = theme; this.loadedThemes[url] = theme;
var instTheme = BDFDB.getTheme(theme.name); var instTheme = BDFDB.BdUtils.getTheme(theme.name);
if (instTheme && instTheme.author.toUpperCase() == theme.author.toUpperCase() && instTheme.version != theme.version) outdated++; if (instTheme && instTheme.author.toUpperCase() == theme.author.toUpperCase() && instTheme.version != theme.version) outdated++;
if (!this.cachedThemes.includes(url)) newentries++; if (!this.cachedThemes.includes(url)) newentries++;
} }
@ -1019,7 +1019,7 @@ class ThemeRepo {
var loadingtooltip = document.querySelector(".themerepo-loading-tooltip"); var loadingtooltip = document.querySelector(".themerepo-loading-tooltip");
if (loadingtooltip) { if (loadingtooltip) {
BDFDB.setInnerText(loadingtooltip, this.getLoadingTooltipText()); BDFDB.setInnerText(loadingtooltip, this.getLoadingTooltipText());
BDFDB.updateTooltipPosition(loadingtooltip); BDFDB.TooltipUtils.update(loadingtooltip);
} }
getThemeInfo(callback); getThemeInfo(callback);
}); });
@ -1041,20 +1041,20 @@ class ThemeRepo {
downloadTheme (data) { downloadTheme (data) {
BDFDB.LibraryRequires.request(data.requesturl, (error, response, body) => { BDFDB.LibraryRequires.request(data.requesturl, (error, response, body) => {
if (error) BDFDB.showToast(`Unable to download Theme "${data.name}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to download Theme "${data.name}".`, {type:"danger"});
else this.createThemeFile(data.requesturl.split("/").pop(), body); else this.createThemeFile(data.requesturl.split("/").pop(), body);
}); });
} }
createThemeFile (filename, content) { createThemeFile (filename, content) {
BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.getThemesFolder(), filename), content, (error) => { BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BdUtils.getThemesFolder(), filename), content, (error) => {
if (error) BDFDB.showToast(`Unable to save Theme "${filename}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to save Theme "${filename}".`, {type:"danger"});
else BDFDB.showToast(`Successfully saved Theme "${filename}".`, {type:"success"}); else BDFDB.NotificationUtils.toast(`Successfully saved Theme "${filename}".`, {type:"success"});
}); });
} }
applyTheme (data) { applyTheme (data) {
if (BDFDB.isThemeEnabled(data.name) == false) { if (BDFDB.BdUtils.isThemeEnabled(data.name) == false) {
BDFDB.removeEles(`style#${data.name}`); BDFDB.removeEles(`style#${data.name}`);
document.head.appendChild(BDFDB.htmlToElement(`<style id=${data.name}>${data.css}</style>`)); document.head.appendChild(BDFDB.htmlToElement(`<style id=${data.name}>${data.css}</style>`));
window.themeModule.enableTheme(data.name); window.themeModule.enableTheme(data.name);
@ -1064,14 +1064,14 @@ class ThemeRepo {
deleteThemeFile (data) { deleteThemeFile (data) {
let filename = data.requesturl.split("/").pop(); let filename = data.requesturl.split("/").pop();
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.getThemesFolder(), filename), (error) => { BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BdUtils.getThemesFolder(), filename), (error) => {
if (error) BDFDB.showToast(`Unable to delete Theme "${filename}".`, {type:"danger"}); if (error) BDFDB.NotificationUtils.toast(`Unable to delete Theme "${filename}".`, {type:"danger"});
else BDFDB.showToast(`Successfully deleted Theme "${filename}".`); else BDFDB.NotificationUtils.toast(`Successfully deleted Theme "${filename}".`);
}); });
} }
removeTheme (data) { removeTheme (data) {
if (BDFDB.isThemeEnabled(data.name) == true) { if (BDFDB.BdUtils.isThemeEnabled(data.name) == true) {
BDFDB.removeEles(`style#${data.name}`); BDFDB.removeEles(`style#${data.name}`);
window.themeModule.disableTheme(data.name); window.themeModule.disableTheme(data.name);
console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Removed Theme " + data.name + "."); console.log(`%c[${this.name}]%c`, "color: #3a71c1; font-weight: 700;", "", "Removed Theme " + data.name + ".");

View File

@ -43,15 +43,13 @@ class ThemeSettings {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
this.dir = BDFDB.getThemesFolder(); this.dir = BDFDB.BdUtils.getThemesFolder();
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -59,7 +57,7 @@ class ThemeSettings {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".themes-settings-button",".themes-settings-footer"); BDFDB.removeEles(".themes-settings-button",".themes-settings-footer");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -167,7 +165,7 @@ class ThemeSettings {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".update-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".update-button", () => {
let path = BDFDB.LibraryRequires.path.join(this.dir, theme.filename); let path = BDFDB.LibraryRequires.path.join(this.dir, theme.filename);
let css = BDFDB.LibraryRequires.fs.readFileSync(path).toString(); let css = BDFDB.LibraryRequires.fs.readFileSync(path).toString();
if (css) { if (css) {
@ -183,11 +181,11 @@ class ThemeSettings {
} }
if (amount > 0) { if (amount > 0) {
BDFDB.LibraryRequires.fs.writeFileSync(path, css); BDFDB.LibraryRequires.fs.writeFileSync(path, css);
BDFDB.showToast(`Updated ${amount} variable${amount == 1 ? "" : "s"} in ${theme.filename}`, {type:"success"}); BDFDB.NotificationUtils.toast(`Updated ${amount} variable${amount == 1 ? "" : "s"} in ${theme.filename}`, {type:"success"});
} }
else BDFDB.showToast(`There are no changed variables to be updated in ${theme.filename}`, {type:"warning"}); else BDFDB.NotificationUtils.toast(`There are no changed variables to be updated in ${theme.filename}`, {type:"warning"});
} }
else BDFDB.showToast(`Could not find themefile: ${theme.filename}`, {type:"error"}); else BDFDB.NotificationUtils.toast(`Could not find themefile: ${theme.filename}`, {type:"error"});
}); });
wrapper.appendChild(settingspanel); wrapper.appendChild(settingspanel);

View File

@ -55,15 +55,13 @@ class TimedLightDarkMode {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
this.startInterval(); this.startInterval();
} }
else { else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
}
} }
stop () { stop () {
@ -74,7 +72,7 @@ class TimedLightDarkMode {
BDFDB.removeEles(".TLDM-settingsbox"); BDFDB.removeEles(".TLDM-settingsbox");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -91,9 +89,9 @@ class TimedLightDarkMode {
BDFDB.initElements(settingsbox, this); BDFDB.initElements(settingsbox, this);
this.updateSlider(slider, values); this.updateSlider(slider, values);
BDFDB.addChildEventListener(settingsbox, "mousedown", BDFDB.dotCN.slidergrabber + ".timer-grabber", e => {this.dragSlider(e.currentTarget);}); BDFDB.ListenerUtils.addToChildren(settingsbox, "mousedown", BDFDB.dotCN.slidergrabber + ".timer-grabber", e => {this.dragSlider(e.currentTarget);});
BDFDB.addChildEventListener(settingsbox, "mouseenter", BDFDB.dotCN.slidergrabber + ".date-grabber", e => {this.showCurrentTime(e.currentTarget);}); BDFDB.ListenerUtils.addToChildren(settingsbox, "mouseenter", BDFDB.dotCN.slidergrabber + ".date-grabber", e => {this.showCurrentTime(e.currentTarget);});
BDFDB.addChildEventListener(settingsbox, "click", ".settings-switch", e => { BDFDB.ListenerUtils.addToChildren(settingsbox, "click", ".settings-switch", e => {
this.startInterval(); this.startInterval();
BDFDB.toggleClass(slider, BDFDB.disCN.sliderdisabled, !e.currentTarget.checked); BDFDB.toggleClass(slider, BDFDB.disCN.sliderdisabled, !e.currentTarget.checked);
}); });
@ -124,7 +122,7 @@ class TimedLightDarkMode {
} }
changeTheme (dark) { changeTheme (dark) {
var theme = BDFDB.getDiscordTheme(); var theme = BDFDB.DiscordUtils.getTheme();
if (dark && theme == BDFDB.disCN.themelight) BDFDB.LibraryModules.SettingsUtils.updateRemoteSettings({theme:"dark"}); if (dark && theme == BDFDB.disCN.themelight) BDFDB.LibraryModules.SettingsUtils.updateRemoteSettings({theme:"dark"});
else if (!dark && theme == BDFDB.disCN.themedark) BDFDB.LibraryModules.SettingsUtils.updateRemoteSettings({theme:"light"}); else if (!dark && theme == BDFDB.disCN.themedark) BDFDB.LibraryModules.SettingsUtils.updateRemoteSettings({theme:"light"});
} }

View File

@ -89,13 +89,11 @@ class TopRoleEverywhere {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
@ -103,7 +101,7 @@ class TopRoleEverywhere {
this.stopping = true; this.stopping = true;
BDFDB.removeEles(".TRE-tag"); BDFDB.removeEles(".TRE-tag");
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -117,7 +115,7 @@ class TopRoleEverywhere {
} }
processMessageUsername (instance, wrapper, returnvalue) { processMessageUsername (instance, wrapper, returnvalue) {
let message = BDFDB.getReactValue(instance, "props.message"); let message = BDFDB.ReactUtils.getValue(instance, "props.message");
if (message) { if (message) {
let username = wrapper.querySelector(BDFDB.dotCN.messageusername); let username = wrapper.querySelector(BDFDB.dotCN.messageusername);
if (username && BDFDB.getData("showInChat", this, "settings")) { if (username && BDFDB.getData("showInChat", this, "settings")) {
@ -131,7 +129,7 @@ class TopRoleEverywhere {
if (this.SettingsUpdated) { if (this.SettingsUpdated) {
delete this.SettingsUpdated; delete this.SettingsUpdated;
BDFDB.removeEles(".TRE-tag"); BDFDB.removeEles(".TRE-tag");
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
} }
} }

View File

@ -74,7 +74,7 @@ class UserNotes {
BDFDB.initElements(settingspanel, this); BDFDB.initElements(settingspanel, this);
BDFDB.addEventListener(this, settingspanel, "click", ".remove-button", () => { BDFDB.ListenerUtils.add(this, settingspanel, "click", ".remove-button", () => {
BDFDB.openConfirmModal(this, "Are you sure you want to remove all usernotes?", () => { BDFDB.openConfirmModal(this, "Are you sure you want to remove all usernotes?", () => {
BDFDB.removeAllData(this, "notes"); BDFDB.removeAllData(this, "notes");
}); });
@ -106,11 +106,9 @@ class UserNotes {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
@ -118,7 +116,7 @@ class UserNotes {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -128,10 +126,10 @@ class UserNotes {
onUserContextMenu (instance, menu, returnvalue) { onUserContextMenu (instance, menu, returnvalue) {
if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuItem`)) { if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuItem`)) {
let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]); let [children, index] = BDFDB.getContextMenuGroupAndIndex(returnvalue, ["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]);
const itemgroup = BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, { const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`, className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
children: [ children: [
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE, label: BDFDB.LanguageUtils.LanguageStrings.USERS + " " + BDFDB.LanguageUtils.LanguageStrings.NOTE,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-usernote-contextMenuItem`, className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-usernote-contextMenuItem`,
action: e => { action: e => {
@ -155,7 +153,7 @@ class UserNotes {
noteinput.value = note; noteinput.value = note;
noteinput.setAttribute("placeholder", note); noteinput.setAttribute("placeholder", note);
BDFDB.appendModal(userNotesModal); BDFDB.appendModal(userNotesModal);
BDFDB.addChildEventListener(userNotesModal, "click", ".btn-save", (e) => { BDFDB.ListenerUtils.addToChildren(userNotesModal, "click", ".btn-save", (e) => {
e.preventDefault(); e.preventDefault();
BDFDB.saveData(info.id, noteinput.value, this, "notes") BDFDB.saveData(info.id, noteinput.value, this, "notes")
}); });

View File

@ -42,20 +42,18 @@ class WriteUpperCase {
initialize () { initialize () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
if (this.started) return; if (this.started) return;
BDFDB.loadMessage(this); BDFDB.PluginUtils.init(this);
BDFDB.WebModules.forceAllUpdates(this); BDFDB.ModuleUtils.forceAllUpdates(this);
}
else {
console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
else console.error(`%c[${this.getName()}]%c`, 'color: #3a71c1; font-weight: 700;', '', 'Fatal Error: Could not load BD functions!');
} }
stop () { stop () {
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
this.stopping = true; this.stopping = true;
BDFDB.unloadMessage(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -66,7 +64,7 @@ class WriteUpperCase {
if (instance.props && instance.props.type) { if (instance.props && instance.props.type) {
var textarea = wrapper.querySelector("textarea"); var textarea = wrapper.querySelector("textarea");
if (!textarea) return; if (!textarea) return;
BDFDB.addEventListener(this, textarea, "keyup", () => { BDFDB.ListenerUtils.add(this, textarea, "keyup", () => {
clearTimeout(textarea.WriteUpperCaseTimeout); clearTimeout(textarea.WriteUpperCaseTimeout);
textarea.WriteUpperCaseTimeout = setTimeout(() => { textarea.WriteUpperCaseTimeout = setTimeout(() => {
let string = textarea.value; let string = textarea.value;