Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2023-04-04 10:49:35 +02:00
parent bfa6badcbe
commit 93eaaac8f7
1 changed files with 40 additions and 41 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB * @name BDFDB
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 3.2.2 * @version 3.2.3
* @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
@ -2404,49 +2404,48 @@ module.exports = (_ => {
return false; return false;
}; };
Internal.findModuleViaData = (moduleStorage, dataStorage, item) => { Internal.findModuleViaData = (moduleStorage, dataStorage, item) => {
if (dataStorage[item]) { if (!dataStorage[item]) return;
let defaultExport = typeof dataStorage[item].exported != "boolean" ? true : dataStorage[item].exported; let defaultExport = typeof dataStorage[item].exported != "boolean" ? true : dataStorage[item].exported;
if (dataStorage[item].props) moduleStorage[item] = BDFDB.ModuleUtils.findByProperties(dataStorage[item].props, {defaultExport}); if (dataStorage[item].props) moduleStorage[item] = BDFDB.ModuleUtils.findByProperties(dataStorage[item].props, {defaultExport});
else if (dataStorage[item].protos) moduleStorage[item] = BDFDB.ModuleUtils.findByPrototypes(dataStorage[item].protos, {defaultExport}); else if (dataStorage[item].protos) moduleStorage[item] = BDFDB.ModuleUtils.findByPrototypes(dataStorage[item].protos, {defaultExport});
else if (dataStorage[item].name) moduleStorage[item] = BDFDB.ModuleUtils.findByName(dataStorage[item].name, {defaultExport}); else if (dataStorage[item].name) moduleStorage[item] = BDFDB.ModuleUtils.findByName(dataStorage[item].name, {defaultExport});
else if (dataStorage[item].strings) { else if (dataStorage[item].strings) {
if (dataStorage[item].nonStrings) { if (dataStorage[item].nonStrings) {
moduleStorage[item] = Internal.findModule("strings + nonStrings", JSON.stringify([dataStorage[item].strings, dataStorage[item].nonStrings].flat(10)), m => Internal.checkModuleStrings(m, dataStorage[item].strings) && Internal.checkModuleStrings(m, dataStorage[item].nonStrings, {hasNot: true}) && m, {defaultExport}); moduleStorage[item] = Internal.findModule("strings + nonStrings", JSON.stringify([dataStorage[item].strings, dataStorage[item].nonStrings].flat(10)), m => Internal.checkModuleStrings(m, dataStorage[item].strings) && Internal.checkModuleStrings(m, dataStorage[item].nonStrings, {hasNot: true}) && m, {defaultExport});
}
else moduleStorage[item] = BDFDB.ModuleUtils.findByString(dataStorage[item].strings, {defaultExport});
} }
if (dataStorage[item].value) moduleStorage[item] = (moduleStorage[item] || {})[dataStorage[item].value]; else moduleStorage[item] = BDFDB.ModuleUtils.findByString(dataStorage[item].strings, {defaultExport});
if (dataStorage[item].assign) moduleStorage[item] = Object.assign({}, moduleStorage[item]); }
if (moduleStorage[item]) { if (dataStorage[item].value) moduleStorage[item] = (moduleStorage[item] || {})[dataStorage[item].value];
if (dataStorage[item].funcStrings) moduleStorage[item] = (Object.entries(moduleStorage[item]).find(n => { if (dataStorage[item].assign) moduleStorage[item] = Object.assign({}, moduleStorage[item]);
if (!n || !n[1]) return; if (!moduleStorage[item]) return;
let funcString = typeof n[1] == "function" ? n[1].toString() : (_ => {try {return JSON.stringify(n[1])}catch(err){return n[1].toString()}})(); if (moduleStorage[item][item]) moduleStorage[item] = moduleStorage[item][item];
let renderFuncString = typeof n[1].render == "function" && n[1].render.toString() || ""; if (dataStorage[item].funcStrings) moduleStorage[item] = (Object.entries(moduleStorage[item]).find(n => {
return [dataStorage[item].funcStrings].flat(10).filter(s => s && typeof s == "string").every(string => funcString.indexOf(string) > -1 || renderFuncString.indexOf(string) > -1); if (!n || !n[1]) return;
}) || [])[1]; let funcString = typeof n[1] == "function" ? n[1].toString() : (_ => {try {return JSON.stringify(n[1])}catch(err){return n[1].toString()}})();
if (dataStorage[item].map) { let renderFuncString = typeof n[1].render == "function" && n[1].render.toString() || "";
dataStorage[item]._originalModule = moduleStorage[item]; return [dataStorage[item].funcStrings].flat(10).filter(s => s && typeof s == "string").every(string => funcString.indexOf(string) > -1 || renderFuncString.indexOf(string) > -1);
dataStorage[item]._mappedItems = {}; }) || [])[1];
moduleStorage[item] = new Proxy(Object.assign({}, dataStorage[item]._originalModule, dataStorage[item].map), { if (dataStorage[item].map) {
get: function (_, item2) { dataStorage[item]._originalModule = moduleStorage[item];
if (dataStorage[item]._originalModule[item2]) return dataStorage[item]._originalModule[item2]; dataStorage[item]._mappedItems = {};
if (dataStorage[item]._mappedItems[item2]) return dataStorage[item]._originalModule[dataStorage[item]._mappedItems[item2]]; moduleStorage[item] = new Proxy(Object.assign({}, dataStorage[item]._originalModule, dataStorage[item].map), {
if (!dataStorage[item].map[item2]) return dataStorage[item]._originalModule[item2]; get: function (_, item2) {
let foundFunc = Object.entries(dataStorage[item]._originalModule).find(n => { if (dataStorage[item]._originalModule[item2]) return dataStorage[item]._originalModule[item2];
if (!n || !n[1]) return; if (dataStorage[item]._mappedItems[item2]) return dataStorage[item]._originalModule[dataStorage[item]._mappedItems[item2]];
let funcString = typeof n[1] == "function" ? n[1].toString() : (_ => {try {return JSON.stringify(n[1])}catch(err){return n[1].toString()}})(); if (!dataStorage[item].map[item2]) return dataStorage[item]._originalModule[item2];
let renderFuncString = typeof n[1].render == "function" && n[1].render.toString() || ""; let foundFunc = Object.entries(dataStorage[item]._originalModule).find(n => {
return [dataStorage[item].map[item2]].flat(10).filter(s => s && typeof s == "string").every(string => funcString.indexOf(string) > -1 || renderFuncString.indexOf(string) > -1); if (!n || !n[1]) return;
}); let funcString = typeof n[1] == "function" ? n[1].toString() : (_ => {try {return JSON.stringify(n[1])}catch(err){return n[1].toString()}})();
if (foundFunc) { let renderFuncString = typeof n[1].render == "function" && n[1].render.toString() || "";
dataStorage[item]._mappedItems[item2] = foundFunc[0]; return [dataStorage[item].map[item2]].flat(10).filter(s => s && typeof s == "string").every(string => funcString.indexOf(string) > -1 || renderFuncString.indexOf(string) > -1);
return foundFunc[1];
}
return "div";
}
}); });
if (foundFunc) {
dataStorage[item]._mappedItems[item2] = foundFunc[0];
return foundFunc[1];
}
return "div";
} }
} });
} }
}; };