Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2021-03-03 13:45:25 +01:00
parent 2d6b26cd39
commit 75afa05eee
1 changed files with 12 additions and 17 deletions

View File

@ -19,12 +19,7 @@ module.exports = (_ => {
"version": "1.4.0",
"description": "Give other plugins utility functions"
},
"rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js",
"changeLog": {
"progress": {
"New Meta Headers": "Adjusted Update Check for new Plugin Meta Headers"
}
}
"rawUrl": "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js"
};
const DiscordObjects = {};
@ -1845,15 +1840,12 @@ module.exports = (_ => {
stringFind: InternalData.ModuleUtilsConfig.Finder[unmappedType] && InternalData.ModuleUtilsConfig.Finder[unmappedType].strings,
propertyFind: InternalData.ModuleUtilsConfig.Finder[unmappedType] && InternalData.ModuleUtilsConfig.Finder[unmappedType].props,
specialFilter: InternalData.ModuleUtilsConfig.Finder[unmappedType] && InternalData.ModuleUtilsConfig.Finder[unmappedType].special && InternalBDFDB.createFilter(InternalData.ModuleUtilsConfig.Finder[unmappedType].special),
memoComponent: InternalData.ModuleUtilsConfig.MemoComponent.includes(unmappedType),
subRender: InternalData.ModuleUtilsConfig.SubRender.includes(unmappedType),
forceObserve: InternalData.ModuleUtilsConfig.ForceObserve.includes(unmappedType),
nonRender: BDFDB.ObjectUtils.toArray(pluginData.patchTypes).flat(10).filter(n => n && !InternalData.ModuleUtilsConfig.InstanceFunctions.includes(n)).length > 0,
exported: InternalData.ModuleUtilsConfig.Finder[unmappedType] && InternalData.ModuleUtilsConfig.Finder[unmappedType].exported || false,
mapped: InternalData.ModuleUtilsConfig.PatchMap[type]
};
config.ignoreCheck = !!(config.codeFind || config.propertyFind || config.specialFilter || config.nonRender || config.memoComponent);
config.nonPrototype = InternalData.ModuleUtilsConfig.NonPrototype.includes(unmappedType) || !!(config.codeFind || config.propertyFind || config.nonRender);
config.nonRender = config.specialFilter || BDFDB.ObjectUtils.toArray(pluginData.patchTypes).flat(10).filter(n => n && !InternalData.ModuleUtilsConfig.InstanceFunctions.includes(n)).length > 0;
config.nonPrototype = !!(config.codeFind || config.propertyFind || config.nonRender);
let component = InternalData.ModuleUtilsConfig.LoadedInComponents[type] && BDFDB.ObjectUtils.get(InternalComponents, InternalData.ModuleUtilsConfig.LoadedInComponents[type]);
if (component) InternalBDFDB.patchComponent(pluginData, config.nonRender ? (BDFDB.ModuleUtils.find(m => m == component, config.exported) || {}).exports : component, type, config);
@ -1870,7 +1862,7 @@ module.exports = (_ => {
let patchSpecial = (func, argument) => {
let module = BDFDB.ModuleUtils[func](argument, config.exported);
let exports = module && !config.exported && module.exports || module;
exports && InternalBDFDB.patchComponent(pluginData, config.memoComponent ? exports.default : exports, mappedType, config);
exports && InternalBDFDB.patchComponent(pluginData, InternalBDFDB.isMemo(exports) ? exports.default : exports, mappedType, config);
};
if (config.classNames.length) InternalBDFDB.checkForInstance(pluginData, mappedType, config);
else if (config.stringFind) patchSpecial("findByString", config.stringFind);
@ -1885,11 +1877,11 @@ module.exports = (_ => {
if (pluginDataObjs.length && instance) {
let name = type.split(" _ _ ")[0];
instance = instance[BDFDB.ReactUtils.instanceKey] && instance[BDFDB.ReactUtils.instanceKey].type ? instance[BDFDB.ReactUtils.instanceKey].type : instance;
instance = config.ignoreCheck || BDFDB.ReactUtils.isCorrectInstance(instance, name) || InternalData.ModuleUtilsConfig.LoadedInComponents[type] ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up: true}));
instance = config.nonPrototype || BDFDB.ReactUtils.isCorrectInstance(instance, name) || InternalData.ModuleUtilsConfig.LoadedInComponents[type] ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up: true}));
if (instance) {
instance = instance[BDFDB.ReactUtils.instanceKey] && instance[BDFDB.ReactUtils.instanceKey].type ? instance[BDFDB.ReactUtils.instanceKey].type : instance;
let toBePatched = config.nonPrototype ? instance : instance.prototype;
toBePatched = config.subRender && toBePatched ? toBePatched.type : toBePatched;
let toBePatched = config.nonPrototype || !instance.prototype ? instance : instance.prototype;
toBePatched = toBePatched && toBePatched.type && typeof toBePatched.type.render == "function" ? toBePatched.type : toBePatched;
for (let pluginData of pluginDataObjs) for (let patchType in pluginData.patchTypes) {
let patchMethods = {};
patchMethods[patchType] = e => {
@ -1900,7 +1892,7 @@ module.exports = (_ => {
patchtypes: [patchType]
});
};
BDFDB.PatchUtils.patch(pluginData.plugin, toBePatched, config.subRender ? "render" : pluginData.patchTypes[patchType], patchMethods);
BDFDB.PatchUtils.patch(pluginData.plugin, toBePatched, pluginData.patchTypes[patchType], patchMethods);
}
}
}
@ -1911,6 +1903,9 @@ module.exports = (_ => {
return value && (!prop.value || [prop.value].flat(10).filter(n => typeof n == "string").some(n => value.toUpperCase().indexOf(n.toUpperCase()) == 0));
}) && ins.return.type;
};
InternalBDFDB.isMemo = function (exports) {
return exports && exports.default && typeof exports.default.$$typeof == "symbol" && (exports.default.$$typeof.toString() || "").indexOf("memo") > -1
};
InternalBDFDB.checkEle = function (pluginDataObjs, ele, type, config) {
pluginDataObjs = [pluginDataObjs].flat(10).filter(n => n);
let unmappedType = type.split(" _ _ ")[1] || type;
@ -1920,7 +1915,7 @@ module.exports = (_ => {
if (component) {
if (config.nonRender) {
let exports = (BDFDB.ModuleUtils.find(m => m == component, false) || {}).exports;
InternalBDFDB.patchComponent(pluginDataObjs, exports && config.memoComponent ? exports.default : exports, type, config);
InternalBDFDB.patchComponent(pluginDataObjs, InternalBDFDB.isMemo(exports) ? exports.default : exports, type, config);
}
else InternalBDFDB.patchComponent(pluginDataObjs, component, type, config);
BDFDB.PatchUtils.forceAllUpdates(pluginDataObjs.map(n => n.plugin), type);