Update 0BDFDB.plugin.js

This commit is contained in:
Mirco Wittrien 2022-10-11 12:41:24 +02:00
parent 3d2b604d52
commit fd904fe87f
1 changed files with 23 additions and 14 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 2.6.8
* @version 2.6.9
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -1104,7 +1104,7 @@ module.exports = (_ => {
libraryCSS = css;
const backupObj = getBackup(dataFileName, dataFilePath);
if (backupObj.backup && backupObj.hashIsSame) parseData(backupObj.backup);
if (backupObj.backup && backupObj.hashIsSame || true) parseData(backupObj.backup);
else request.get(`https://mwittrien.github.io/BetterDiscordAddons/Library/_res/${dataFileName}`, (e, r, b) => {
if ((e || !b || r.statusCode != 200) && tryAgain) return BDFDB.TimeUtils.timeout(_ => requestLibraryData(), 10000);
if (!e && b && r.statusCode == 200) {
@ -2379,10 +2379,7 @@ module.exports = (_ => {
};
Internal.isCorrectModule = function (module, type, useCache = false) {
if (!InternalData.PatchModules || !InternalData.PatchModules[type]) {
BDFDB.LogUtils.warn(`[${type}] not found in PatchModules InternalData`);
return false;
}
if (!InternalData.PatchModules || !InternalData.PatchModules[type]) return false;
else if (useCache && Cache && Cache.modules && Cache.modules.patch && Cache.modules.patch[type] == module) return true;
else {
let foundModule = null;
@ -8304,6 +8301,22 @@ module.exports = (_ => {
});
break;
}
if (PluginStores.modulePatches.after && module.prototype && typeof module.prototype.render == "function") {
for (const type in PluginStores.modulePatches.after) if (Internal.isCorrectModule(module, type, true)) {
for (let plugin of PluginStores.modulePatches.after[type].flat(10)) if (!BDFDB.PatchUtils.isPatched(plugin, module.prototype, "render")) {
BDFDB.PatchUtils.patch(plugin, module.prototype, "render", {after: e2 => Internal.initiatePatch(plugin, type, {
arguments: e2.methodArguments,
instance: e2.thisObject,
returnvalue: e2.returnValue,
component: e.methodArguments[0],
name: type,
methodname: "render",
patchtypes: ["after"]
})});
}
break;
}
}
if (module.prototype) for (let patchType of ["componentDidMount", "componentDidUpdate", "componentWillUnmount"]) {
if (PluginStores.modulePatches[patchType]) for (const type in PluginStores.modulePatches[patchType]) if (Internal.isCorrectModule(module, type, true)) {
for (let plugin of PluginStores.modulePatches[patchType][type].flat(10)) if (!BDFDB.PatchUtils.isPatched(plugin, module.prototype, patchType)) {
@ -8323,20 +8336,16 @@ module.exports = (_ => {
},
after: e => {
let module = e.methodArguments[0] && (e.methodArguments[0].type || e.methodArguments[0].render || e.methodArguments[0]);
if (!module || typeof module != "function") return;
if (PluginStores.modulePatches.after && e.returnValue && e.returnValue.type) for (const type in PluginStores.modulePatches.after) if (Internal.isCorrectModule(module, type, true)) {
if (!module || typeof module != "function" || !PluginStores.modulePatches.after || module.prototype && typeof module.prototype.render == "function") return;
else if (e.returnValue) for (const type in PluginStores.modulePatches.after) if (Internal.isCorrectModule(module, type, true)) {
for (let plugin of PluginStores.modulePatches.after[type].flat(10)) {
let patchModule = e.returnValue, patchFunction = "type";
if (e.returnValue.type && e.returnValue.type.prototype && typeof e.returnValue.type.prototype.render == "function") {
patchModule = e.returnValue.type.prototype, patchFunction = "render";
}
if (!BDFDB.PatchUtils.isPatched(plugin, patchModule, patchFunction)) BDFDB.PatchUtils.patch(plugin, patchModule, patchFunction, {after: e2 => Internal.initiatePatch(plugin, type, {
if (!BDFDB.PatchUtils.isPatched(plugin, e.returnValue, "type")) BDFDB.PatchUtils.patch(plugin, e.returnValue, "type", {after: e2 => Internal.initiatePatch(plugin, type, {
arguments: e2.methodArguments,
instance: e2.thisObject,
returnvalue: e2.returnValue,
component: e.methodArguments[0],
name: type,
methodname: patchFunction,
methodname: "type",
patchtypes: ["after"]
})});
}