This commit is contained in:
Mirco Wittrien 2022-02-09 19:35:23 +01:00
parent a42da8005b
commit c2510362de
2 changed files with 40 additions and 33 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB * @name BDFDB
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.1.0 * @version 2.1.1
* @description Required Library for DevilBro's Plugins * @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -19,13 +19,14 @@ module.exports = (_ => {
"info": { "info": {
"name": "BDFDB", "name": "BDFDB",
"author": "DevilBro", "author": "DevilBro",
"version": "2.1.0", "version": "2.1.1",
"description": "Required Library for DevilBro's Plugins" "description": "Required Library for DevilBro's Plugins"
}, },
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`, "rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`,
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Context Menus": "Fully work again, no further crashes" "Context Menus": "Fully work again, no further crashes",
"Better Friend List": "Fixed Crash"
} }
} }
}; };
@ -2199,6 +2200,7 @@ module.exports = (_ => {
lazyLoaded: finderData && finderData.lazyLoaded, lazyLoaded: finderData && finderData.lazyLoaded,
stringFind: finderData && finderData.strings, stringFind: finderData && finderData.strings,
propertyFind: finderData && finderData.props, propertyFind: finderData && finderData.props,
prototypeFind: finderData && finderData.protos,
specialFilter: finderData && finderData.special && InternalBDFDB.createFilter(finderData.special), specialFilter: finderData && finderData.special && InternalBDFDB.createFilter(finderData.special),
subComponent: finderData && finderData.subComponent, subComponent: finderData && finderData.subComponent,
forceObserve: finderData && finderData.forceObserve, forceObserve: finderData && finderData.forceObserve,
@ -2207,7 +2209,7 @@ module.exports = (_ => {
mapped: InternalData.ModuleUtilsConfig.PatchMap[type] mapped: InternalData.ModuleUtilsConfig.PatchMap[type]
}; };
config.nonRender = config.specialFilter || BDFDB.ObjectUtils.toArray(pluginData.patchTypes).flat(10).filter(n => n && !InternalData.ModuleUtilsConfig.InstanceFunctions.includes(n)).length > 0; config.nonRender = config.specialFilter || BDFDB.ObjectUtils.toArray(pluginData.patchTypes).flat(10).filter(n => n && !InternalData.ModuleUtilsConfig.InstanceFunctions.includes(n)).length > 0;
config.nonPrototype = !!(config.subComponent && config.subComponent.strings || config.stringFind || config.subComponent && config.subComponent.props || config.propertyFind || config.nonRender); config.nonPrototype = !!(config.subComponent && config.subComponent.strings || config.stringFind || config.subComponent && config.subComponent.props || config.propertyFind || config.subComponent && config.subComponent.protos || config.prototypeFind || config.nonRender);
config.mappedType = config.mapped ? config.mapped + " _ _ " + type : type; config.mappedType = config.mapped ? config.mapped + " _ _ " + type : type;
config.name = config.subComponent && config.subComponent.name || config.mappedType.split(" _ _ ")[0]; config.name = config.subComponent && config.subComponent.name || config.mappedType.split(" _ _ ")[0];
@ -2230,6 +2232,7 @@ module.exports = (_ => {
else if (config.classNames.length) InternalBDFDB.searchComponent(pluginData, config); else if (config.classNames.length) InternalBDFDB.searchComponent(pluginData, config);
else if (config.subComponent && config.subComponent.strings || config.stringFind) patchSpecial("findByString", config.subComponent && config.subComponent.strings || config.stringFind); else if (config.subComponent && config.subComponent.strings || config.stringFind) patchSpecial("findByString", config.subComponent && config.subComponent.strings || config.stringFind);
else if (config.subComponent && config.subComponent.props || config.propertyFind) patchSpecial("findByProperties", config.subComponent && config.subComponent.props || config.propertyFind); else if (config.subComponent && config.subComponent.props || config.propertyFind) patchSpecial("findByProperties", config.subComponent && config.subComponent.props || config.propertyFind);
else if (config.subComponent && config.subComponent.protos || config.prototypeFind) patchSpecial("findByPrototypes", config.subComponent && config.subComponent.protos || config.prototypeFind);
else if (config.nonRender) patchSpecial("findByName", config.name); else if (config.nonRender) patchSpecial("findByName", config.name);
else InternalBDFDB.patchComponent(pluginData, BDFDB.ModuleUtils.findByName(config.name), config); else InternalBDFDB.patchComponent(pluginData, BDFDB.ModuleUtils.findByName(config.name), config);
} }
@ -4035,13 +4038,11 @@ module.exports = (_ => {
const RealMenuItems = BDFDB.ModuleUtils.findByProperties("MenuItem", "MenuGroup"); const RealMenuItems = BDFDB.ModuleUtils.findByProperties("MenuItem", "MenuGroup");
BDFDB.ContextMenuUtils = {}; BDFDB.ContextMenuUtils = {};
BDFDB.ContextMenuUtils.open = function (plugin, e, children) { BDFDB.ContextMenuUtils.open = function (plugin, e, children) {
LibraryModules.ContextMenuUtils.openContextMenu(e, function (e) { LibraryModules.ContextMenuUtils.openContextMenu(e, _ => BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, { navId: "bdfdb-context",
navId: "bdfdb-context", onClose: LibraryModules.ContextMenuUtils.closeContextMenu,
onClose: LibraryModules.ContextMenuUtils.closeContextMenu, children: children
children: children }, true));
}, true);
});
}; };
BDFDB.ContextMenuUtils.close = function (nodeOrInstance) { BDFDB.ContextMenuUtils.close = function (nodeOrInstance) {
if (!BDFDB.ObjectUtils.is(nodeOrInstance)) return; if (!BDFDB.ObjectUtils.is(nodeOrInstance)) return;
@ -6868,25 +6869,21 @@ module.exports = (_ => {
align: InternalComponents.LibraryComponents.Flex.Align.CENTER, align: InternalComponents.LibraryComponents.Flex.Align.CENTER,
className: BDFDB.disCN.quickselectclick, className: BDFDB.disCN.quickselectclick,
onClick: event => { onClick: event => {
LibraryModules.ContextMenuUtils.openContextMenu(event, _ => { LibraryModules.ContextMenuUtils.openContextMenu(event, _ => BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, {
return BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.Menu, { navId: "bdfdb-quickselect",
navId: "bdfdb-quickselect", onClose: LibraryModules.ContextMenuUtils.closeContextMenu,
onClose: LibraryModules.ContextMenuUtils.closeContextMenu, className: this.props.popoutClassName,
className: this.props.popoutClassName, children: BDFDB.ContextMenuUtils.createItem(InternalComponents.LibraryComponents.MenuItems.MenuGroup, {
children: BDFDB.ContextMenuUtils.createItem(InternalComponents.LibraryComponents.MenuItems.MenuGroup, { children: options.map((option, i) => {
children: options.map((option, i) => { let selected = option.value && option.value === selectedOption.value || option.key && option.key === selectedOption.key;
let selected = option.value && option.value === selectedOption.value || option.key && option.key === selectedOption.key; return BDFDB.ContextMenuUtils.createItem(InternalComponents.LibraryComponents.MenuItems.MenuItem, {
return BDFDB.ContextMenuUtils.createItem(InternalComponents.LibraryComponents.MenuItems.MenuItem, { label: option.label,
label: option.label, id: BDFDB.ContextMenuUtils.createItemId("option", option.key || option.value || i),
id: BDFDB.ContextMenuUtils.createItemId("option", option.key || option.value || i), action: selected ? null : event2 => this.handleChange.bind(this)(option)
action: selected ? null : event2 => { });
this.handleChange.bind(this)(option)
}
});
})
}) })
}); })
}); }));
}, },
children: [ children: [
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
@ -7971,6 +7968,7 @@ module.exports = (_ => {
InternalBDFDB.patchedModules = { InternalBDFDB.patchedModules = {
before: { before: {
SearchBar: "render",
EmojiPicker: "type", EmojiPicker: "type",
EmojiPickerListRow: "default" EmojiPickerListRow: "default"
}, },
@ -8025,6 +8023,11 @@ module.exports = (_ => {
} }
}; };
InternalBDFDB.processSearchBar = function (e) {
if (typeof e.instance.props.query != "string") e.instance.props.query = "";
};
InternalBDFDB.processSettingsView = function (e) { InternalBDFDB.processSettingsView = function (e) {
if (e.node && e.node.parentElement && e.node.parentElement.getAttribute("aria-label") == BDFDB.DiscordConstants.Layers.USER_SETTINGS) InternalBDFDB.addListObserver(e.node.parentElement); if (e.node && e.node.parentElement && e.node.parentElement.getAttribute("aria-label") == BDFDB.DiscordConstants.Layers.USER_SETTINGS) InternalBDFDB.addListObserver(e.node.parentElement);
}; };
@ -8167,6 +8170,7 @@ module.exports = (_ => {
let module; let module;
if (config.stringFind) module = BDFDB.ModuleUtils.findByString(config.stringFind, false, true); if (config.stringFind) module = BDFDB.ModuleUtils.findByString(config.stringFind, false, true);
else if (config.propertyFind) module = BDFDB.ModuleUtils.findByProperties(config.propertyFind, false, true); else if (config.propertyFind) module = BDFDB.ModuleUtils.findByProperties(config.propertyFind, false, true);
else if (config.prototypeFind) module = BDFDB.ModuleUtils.findByPrototypes(config.prototypeFind, false, true);
else module = BDFDB.ModuleUtils.findByName(config.name, false, true); else module = BDFDB.ModuleUtils.findByName(config.name, false, true);
if (module) { if (module) {
let exports = !config.exported && module.exports || module; let exports = !config.exported && module.exports || module;
@ -8182,6 +8186,10 @@ module.exports = (_ => {
const value = m[prop]; const value = m[prop];
return value !== undefined && !(typeof value == "string" && !value); return value !== undefined && !(typeof value == "string" && !value);
}) && m; }) && m;
else if (config.prototypeFind) filter = m => m.prototype && [config.prototypeFind].flat(10).filter(n => n).every(prop => {
const value = m.prototype[prop];
return value !== undefined && !(typeof value == "string" && !value);
}) && m;
else filter = m => m.displayName === config.name && m || m.render && m.render.displayName === config.name && m || m[config.name] && m[config.name].displayName === name && m[config.name]; else filter = m => m.displayName === config.name && m || m.render && m.render.displayName === config.name && m || m[config.name] && m[config.name].displayName === name && m[config.name];
PluginStores.chunkObserver[config.mappedType].filter = filter; PluginStores.chunkObserver[config.mappedType].filter = filter;
} }

View File

@ -233,7 +233,6 @@
"MessageUsername": {"strings": [".default.username", "colorString", "compact"]}, "MessageUsername": {"strings": [".default.username", "colorString", "compact"]},
"ModalLayer": {"class": "modal"}, "ModalLayer": {"class": "modal"},
"Note": {"class": "usernotetextarea"}, "Note": {"class": "usernotetextarea"},
"PeopleListSectionedNonLazy": {"strings": ["statusSections", "getSectionTitle", "peopleList"]},
"PeoplePageList": {"strings": ["FriendsSections", "emptyStateContainer"]}, "PeoplePageList": {"strings": ["FriendsSections", "emptyStateContainer"]},
"PopoutContainer": {"class": "popout"}, "PopoutContainer": {"class": "popout"},
"PrivateChannelCall": {"class": "callcurrentcontainer"}, "PrivateChannelCall": {"class": "callcurrentcontainer"},
@ -249,6 +248,7 @@
"RichChannelMention": {"props": ["ChannelMention"]}, "RichChannelMention": {"props": ["ChannelMention"]},
"RichUserMention": {"props": ["UserMention"]}, "RichUserMention": {"props": ["UserMention"]},
"RTCConnection": {"class": "voicedetails"}, "RTCConnection": {"class": "voicedetails"},
"SearchBar": {"props": ["SearchIcon"], "path": "default.prototype"},
"SearchResults": {"class": "searchresultswrap"}, "SearchResults": {"class": "searchresultswrap"},
"SearchResultsInner": {"strings": ["SEARCH_HIDE_BLOCKED_MESSAGES", "totalResults", "SEARCH_PAGE_SIZE"]}, "SearchResultsInner": {"strings": ["SEARCH_HIDE_BLOCKED_MESSAGES", "totalResults", "SEARCH_PAGE_SIZE"]},
"StandardSidebarView": {"class": "settingswindowstandardsidebarview"}, "StandardSidebarView": {"class": "settingswindowstandardsidebarview"},
@ -261,8 +261,7 @@
"UserMention": {"strings": ["UserMention", "userId", "getAvatarURL"]}, "UserMention": {"strings": ["UserMention", "userId", "getAvatarURL"]},
"UserProfileModal": {"lazyLoaded": true}, "UserProfileModal": {"lazyLoaded": true},
"UserProfileModalHeader": {"lazyLoaded": true}, "UserProfileModalHeader": {"lazyLoaded": true},
"UserSettingsAppearance": {"class": "usersettingsappearancepreview"}, "UserSettingsAppearance": {"class": "usersettingsappearancepreview"}
"V2C_ContentColumn": {"class": "settingswindowcontentcolumn", "special": [{"path": "return.stateNode.props.title", "value": ["PLUGINS", "THEMES"]}]}
}, },
"LoadedInComponents": { "LoadedInComponents": {
"AutocompleteChannelResult": "LibraryComponents.AutocompleteItems.Channel", "AutocompleteChannelResult": "LibraryComponents.AutocompleteItems.Channel",
@ -284,7 +283,7 @@
"PopoutContainer": {"name": "Popout"}, "PopoutContainer": {"name": "Popout"},
"QuickSelect": {"name": "QuickSelectWrapper"}, "QuickSelect": {"name": "QuickSelectWrapper"},
"RadioGroup": {"name": "RadioGroup"}, "RadioGroup": {"name": "RadioGroup"},
"SearchBar": {"name": "SearchBar", "protos": ["focus"]}, "SearchBar": {"name": "SearchBar", "protos": ["focus", "blur"]},
"SearchableSelect": {"name": "SingleSelect"}, "SearchableSelect": {"name": "SingleSelect"},
"Select": {"name": "SelectTempWrapper"}, "Select": {"name": "SelectTempWrapper"},
"Slider": {"name": "Slider"}, "Slider": {"name": "Slider"},