This commit is contained in:
Mirco Wittrien 2020-07-30 10:57:28 +02:00
parent 36d174393f
commit aa12d94d6b
2 changed files with 141 additions and 86 deletions

View File

@ -1,10 +1,5 @@
(_ => { (_ => {
if (window.BDFDB && window.BDFDB.ListenerUtils && typeof window.BDFDB.ListenerUtils.remove == "function") window.BDFDB.ListenerUtils.remove(window.BDFDB); if (window.BDFDB && window.BDFDB.PluginUtils && typeof window.BDFDB.PluginUtils.cleanUp == "function") window.BDFDB.PluginUtils.cleanUp(window.BDFDB);
if (window.BDFDB && window.BDFDB.StoreChangeUtils && typeof window.BDFDB.StoreChangeUtils.remove == "function") window.BDFDB.StoreChangeUtils.remove(window.BDFDB);
if (window.BDFDB && window.BDFDB.ObserverUtils && typeof window.BDFDB.ObserverUtils.disconnect == "function") window.BDFDB.ObserverUtils.disconnect(window.BDFDB);
if (window.BDFDB && window.BDFDB.ModuleUtils && typeof window.BDFDB.ModuleUtils.unpatch == "function") window.BDFDB.ModuleUtils.unpatch(window.BDFDB);
if (window.BDFDB && window.BDFDB.WindowUtils && typeof window.BDFDB.WindowUtils.closeAll == "function") window.BDFDB.WindowUtils.closeAll(window.BDFDB);
if (window.BDFDB && window.BDFDB.WindowUtils && typeof window.BDFDB.WindowUtils.removeListener == "function") window.BDFDB.WindowUtils.removeListener(window.BDFDB);
const BDFDB = { const BDFDB = {
myPlugins: Object.assign({}, window.BDFDB && window.BDFDB.myPlugins), myPlugins: Object.assign({}, window.BDFDB && window.BDFDB.myPlugins),
@ -54,6 +49,8 @@
BDFDB.LogUtils.log("Loading library."); BDFDB.LogUtils.log("Loading library.");
BDFDB.cleanUp =
BDFDB.PluginUtils = {}; BDFDB.PluginUtils = {};
BDFDB.PluginUtils.init = BDFDB.loadMessage = function (plugin) { BDFDB.PluginUtils.init = BDFDB.loadMessage = function (plugin) {
plugin.name = plugin.name || (typeof plugin.getName == "function" ? plugin.getName() : null); plugin.name = plugin.name || (typeof plugin.getName == "function" ? plugin.getName() : null);
@ -103,12 +100,7 @@
if (typeof plugin.css === "string") BDFDB.DOMUtils.removeLocalStyle(plugin.name); if (typeof plugin.css === "string") BDFDB.DOMUtils.removeLocalStyle(plugin.name);
BDFDB.ModuleUtils.unpatch(plugin); BDFDB.PluginUtils.cleanUp(plugin);
BDFDB.ListenerUtils.remove(plugin);
BDFDB.StoreChangeUtils.remove(plugin);
BDFDB.ObserverUtils.disconnect(plugin);
BDFDB.WindowUtils.closeAll(plugin);
BDFDB.WindowUtils.removeListener(plugin);
for (let type in BDFDB.InternalData.componentPatchQueries) BDFDB.ArrayUtils.remove(BDFDB.InternalData.componentPatchQueries[type].query, plugin, true); for (let type in BDFDB.InternalData.componentPatchQueries) BDFDB.ArrayUtils.remove(BDFDB.InternalData.componentPatchQueries[type].query, plugin, true);
@ -141,6 +133,14 @@
} }
} }
}; };
BDFDB.PluginUtils.cleanUp = function (plugin) {
BDFDB.ListenerUtils.remove(plugin);
BDFDB.StoreChangeUtils.remove(plugin);
BDFDB.ObserverUtils.disconnect(plugin);
BDFDB.ModuleUtils.unpatch(plugin);
BDFDB.WindowUtils.closeAll(plugin);
BDFDB.WindowUtils.removeListener(plugin);
};
BDFDB.PluginUtils.checkUpdate = function (pluginName, url) { BDFDB.PluginUtils.checkUpdate = function (pluginName, url) {
if (pluginName && url) return new Promise(callback => { if (pluginName && url) return new Promise(callback => {
LibraryRequires.request(url, (error, response, result) => { LibraryRequires.request(url, (error, response, result) => {
@ -1408,43 +1408,65 @@
} }
} }
}; };
BDFDB.ModuleUtils.forceAllUpdates = function (plugin, selectedTypes) { BDFDB.ModuleUtils.forceAllUpdates = function (plugins, selectedTypes) {
plugin = plugin == BDFDB && InternalBDFDB || plugin; plugins = [plugins].flat(10).map(n => n == BDFDB && InternalBDFDB || n).filter(n => BDFDB.ObjectUtils.is(n.patchedModules));
if (BDFDB.ObjectUtils.is(plugin) && BDFDB.ObjectUtils.is(plugin.patchedModules)) { if (plugins.length) {
const app = document.querySelector(BDFDB.dotCN.app); const app = document.querySelector(BDFDB.dotCN.app);
const bdSettings = document.querySelector("#bd-settingspane-container > *"); const bdSettings = document.querySelector("#bd-settingspane-container > *");
if (app) { if (app) {
selectedTypes = [selectedTypes].flat(10).filter(n => n).map(type => type && WebModulesData.PatchMap[type] ? WebModulesData.PatchMap[type] + " _ _ " + type : type); selectedTypes = [selectedTypes].flat(10).filter(n => n).map(type => type && WebModulesData.PatchMap[type] ? WebModulesData.PatchMap[type] + " _ _ " + type : type);
let filteredModules = [], specialModules = [], patchtypes = {}; let updateData = {};
for (let patchType in plugin.patchedModules) for (let type in plugin.patchedModules[patchType]) { for (let plugin of plugins) {
let methodNames = [plugin.patchedModules[patchType][type]].flat(10).filter(n => n); updateData[plugin.name] = {
if (BDFDB.ArrayUtils.includes(methodNames, "componentDidMount", "componentDidUpdate", "render", false) && (!selectedTypes.length || selectedTypes.includes(type))) { filteredModules: [],
let unmappedType = type.split(" _ _ ")[1] || type; specialModules: [],
let classNames = [WebModulesData.PatchFinder[unmappedType]].flat(10).filter(n => DiscordClasses[n]); specialModuleTypes: [],
let filter = WebModulesData.SpecialFilter[unmappedType]; patchTypes: {}
if (classNames.length && typeof filter == "function") { };
for (let ele of document.querySelectorAll(classNames.map(n => BDFDB.dotCN[n]).join(", "))) { for (let patchType in plugin.patchedModules) for (let type in plugin.patchedModules[patchType]) {
let constro = filter(BDFDB.ReactUtils.getInstance(ele)); let methodNames = [plugin.patchedModules[patchType][type]].flat(10).filter(n => n);
if (constro) { if (BDFDB.ArrayUtils.includes(methodNames, "componentDidMount", "componentDidUpdate", "render", false) && (!selectedTypes.length || selectedTypes.includes(type))) {
specialModules.push([type, constro]); let unmappedType = type.split(" _ _ ")[1] || type;
break; let filter = WebModulesData.SpecialFilter[unmappedType];
let selector = [WebModulesData.PatchFinder[unmappedType]].flat(10).filter(n => DiscordClasses[n]).map(n => BDFDB.dotCN[n]).join(", ");
if (selector && typeof filter == "function") {
for (let ele of document.querySelectorAll(selector)) {
let constro = filter(BDFDB.ReactUtils.getInstance(ele));
if (constro) {
updateData[plugin.name].specialModules.push([type, constro]);
updateData[plugin.name].specialModuleTypes.push(type);
break;
}
} }
} }
else updateData[plugin.name].filteredModules.push(type);
let name = type.split(" _ _ ")[0];
if (!updateData[plugin.name].patchTypes[name]) updateData[plugin.name].patchTypes[name] = [];
updateData[plugin.name].patchTypes[name].push(patchType);
} }
else filteredModules.push(type);
let name = type.split(" _ _ ")[0];
if (!patchtypes[name]) patchtypes[name] = [];
patchtypes[name].push(patchType);
} }
} }
if (filteredModules.length || specialModules.length) { let updateDataArray = BDFDB.ObjectUtils.toArray(updateData);
filteredModules = BDFDB.ArrayUtils.removeCopies(filteredModules); if (BDFDB.ArrayUtils.sum(updateDataArray.map(n => n.filteredModules.length + n.specialModules.length))) {
specialModules = BDFDB.ArrayUtils.removeCopies(specialModules);
try { try {
let filteredModules = BDFDB.ArrayUtils.removeCopies(updateDataArray.map(n => n.filteredModules).flat(10));
let specialModules = BDFDB.ArrayUtils.removeCopies(updateDataArray.map(n => n.specialModules).flat(10));
console.log(filteredModules);
console.log(specialModules);
const appInsDown = BDFDB.ReactUtils.findOwner(app, {name:filteredModules, type:specialModules, all:true, group:true, unlimited:true}); const appInsDown = BDFDB.ReactUtils.findOwner(app, {name:filteredModules, type:specialModules, all:true, group:true, unlimited:true});
const appInsUp = BDFDB.ReactUtils.findOwner(app, {name:filteredModules, type:specialModules, all:true, group:true, unlimited:true, up:true}); const appInsUp = BDFDB.ReactUtils.findOwner(app, {name:filteredModules, type:specialModules, all:true, group:true, unlimited:true, up:true});
for (let type in appInsDown) for (let ins of appInsDown[type]) InternalBDFDB.forceInitiateProcess(plugin, ins, type, patchtypes[type]); console.log(appInsDown);
for (let type in appInsUp) for (let ins of appInsUp[type]) InternalBDFDB.forceInitiateProcess(plugin, ins, type, patchtypes[type]); console.log(appInsUp);
for (let type in appInsDown) {
let filteredPlugins = plugins.filter(n => updateData[n.name].filteredModules.includes(type) || updateData[n.name].specialModuleTypes.includes(type)).map(n => ({plugin:n, patchTypes:updateData[n.name].patchTypes}));
console.log(filteredPlugins);
for (let ins of appInsDown[type]) InternalBDFDB.forceInitiateProcess(filteredPlugins, ins, type);
}
for (let type in appInsUp) {
let filteredPlugins = plugins.filter(n => updateData[n.name].filteredModules.includes(type) || updateData[n.name].specialModuleTypes.includes(type)).map(n => ({plugin:n, patchTypes:updateData[n.name].patchTypes}));
console.log(filteredPlugins);
for (let ins of appInsUp[type]) InternalBDFDB.forceInitiateProcess(filteredPlugins, ins, type);
}
if (bdSettings) { if (bdSettings) {
const bdSettingsIns = BDFDB.ReactUtils.findOwner(bdSettings, {name:filteredModules, type:specialModules, all:true, unlimited:true}); const bdSettingsIns = BDFDB.ReactUtils.findOwner(bdSettings, {name:filteredModules, type:specialModules, all:true, unlimited:true});
if (bdSettingsIns.length) { if (bdSettingsIns.length) {
@ -1453,20 +1475,33 @@
} }
} }
} }
catch (err) {BDFDB.LogUtils.error("Could not force update components! " + err, plugin.name);} catch (err) {BDFDB.LogUtils.error("Could not force update components! " + err, plugins.map(n => n.name).join(", "));}
} }
} }
} }
}; };
InternalBDFDB.forceInitiateProcess = function (plugin, instance, type, patchtypes) { InternalBDFDB.forceInitiateProcess = function (pluginDataObjs, instance, type) {
plugin = plugin == BDFDB && InternalBDFDB || plugin; pluginDataObjs = [pluginDataObjs].flat(10).filter(n => n);
if (!plugin || !instance || !type) return; if (pluginDataObjs.length && instance && type) {
let methodNames = []; let forceRender = false;
for (let patchType in plugin.patchedModules) if (plugin.patchedModules[patchType][type]) methodNames.push(plugin.patchedModules[patchType][type]); for (let pluginData of pluginDataObjs) {
methodNames = BDFDB.ArrayUtils.removeCopies(methodNames).flat(10).filter(n => n); let plugin = pluginData.plugin == BDFDB && InternalBDFDB || pluginData.plugin, methodNames = [];
if (methodNames.includes("componentDidMount")) InternalBDFDB.initiateProcess(plugin, type, {instance, methodname:"componentDidMount", patchtypes}); for (let patchType in plugin.patchedModules) if (plugin.patchedModules[patchType][type]) methodNames.push(plugin.patchedModules[patchType][type]);
if (methodNames.includes("render")) BDFDB.ReactUtils.forceUpdate(instance); methodNames = BDFDB.ArrayUtils.removeCopies(methodNames).flat(10).filter(n => n);
else if (methodNames.includes("componentDidUpdate")) InternalBDFDB.initiateProcess(plugin, type, {instance, methodname:"componentDidUpdate", patchtypes}); if (methodNames.includes("componentDidMount")) InternalBDFDB.initiateProcess(plugin, type, {
instance: instance,
methodname: "componentDidMount",
patchtypes: pluginData.patchTypes
});
if (methodNames.includes("render")) forceRender = true;
else if (!forceRender && methodNames.includes("componentDidUpdate")) InternalBDFDB.initiateProcess(plugin, type, {
instance: instance,
methodname: "componentDidUpdate",
patchtypes: pluginData.patchTypes
});
}
if (forceRender) BDFDB.ReactUtils.forceUpdate(instance);
}
}; };
InternalBDFDB.initiateProcess = function (plugin, type, e) { InternalBDFDB.initiateProcess = function (plugin, type, e) {
plugin = plugin == BDFDB && InternalBDFDB || plugin; plugin = plugin == BDFDB && InternalBDFDB || plugin;
@ -1486,6 +1521,7 @@
} }
} }
}; };
if (!BDFDB.InternalData.patchObserverData) BDFDB.InternalData.patchObserverData = {observer:null, data:{}};
InternalBDFDB.patchPlugin = function (plugin) { InternalBDFDB.patchPlugin = function (plugin) {
plugin = plugin == BDFDB && InternalBDFDB || plugin; plugin = plugin == BDFDB && InternalBDFDB || plugin;
if (!BDFDB.ObjectUtils.is(plugin) || !BDFDB.ObjectUtils.is(plugin.patchedModules)) return; if (!BDFDB.ObjectUtils.is(plugin) || !BDFDB.ObjectUtils.is(plugin.patchedModules)) return;
@ -1493,7 +1529,7 @@
for (let patchType in plugin.patchedModules) for (let type in plugin.patchedModules[patchType]) { for (let patchType in plugin.patchedModules) for (let type in plugin.patchedModules[patchType]) {
let unmappedType = type.split(" _ _ ")[1] || type; let unmappedType = type.split(" _ _ ")[1] || type;
let component = WebModulesData.LoadedInComponents[type] && BDFDB.ReactUtils.getValue(InternalComponents, WebModulesData.LoadedInComponents[type]); let component = WebModulesData.LoadedInComponents[type] && BDFDB.ReactUtils.getValue(InternalComponents, WebModulesData.LoadedInComponents[type]);
if (component) patchInstance(WebModulesData.NonRender.includes(unmappedType) ? (BDFDB.ModuleUtils.find(m => m == component, false) || {}).exports : component, type, patchType); if (component) patchInstance(plugin, WebModulesData.NonRender.includes(unmappedType) ? (BDFDB.ModuleUtils.find(m => m == component, false) || {}).exports : component, type, patchType);
else { else {
let classNames = [WebModulesData.PatchFinder[unmappedType]].flat(10).filter(n => DiscordClasses[n]); let classNames = [WebModulesData.PatchFinder[unmappedType]].flat(10).filter(n => DiscordClasses[n]);
let codeFind = WebModulesData.CodeFinder[unmappedType]; let codeFind = WebModulesData.CodeFinder[unmappedType];
@ -1508,40 +1544,45 @@
if (classNames.length) checkForInstance(classNames, mappedType, patchType, WebModulesData.ForceObserve.includes(unmappedType)); if (classNames.length) checkForInstance(classNames, mappedType, patchType, WebModulesData.ForceObserve.includes(unmappedType));
else if (codeFind) { else if (codeFind) {
let exports = (BDFDB.ModuleUtils.findByString(codeFind, false) || {}).exports; let exports = (BDFDB.ModuleUtils.findByString(codeFind, false) || {}).exports;
patchInstance(exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true); patchInstance(plugin, exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true);
} }
else if (propertyFind) { else if (propertyFind) {
let exports = (BDFDB.ModuleUtils.findByProperties(propertyFind, false) || {}).exports; let exports = (BDFDB.ModuleUtils.findByProperties(propertyFind, false) || {}).exports;
patchInstance(exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true); patchInstance(plugin, exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true);
} }
else if (WebModulesData.NonRender.includes(unmappedType)) { else if (WebModulesData.NonRender.includes(unmappedType)) {
let exports = (BDFDB.ModuleUtils.findByName(name, false) || {}).exports; let exports = (BDFDB.ModuleUtils.findByName(name, false) || {}).exports;
patchInstance(exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true); patchInstance(plugin, exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, mappedType, patchType, true);
} }
else patchInstance(BDFDB.ModuleUtils.findByName(name), mappedType, patchType); else patchInstance(plugin, BDFDB.ModuleUtils.findByName(name), mappedType, patchType);
} }
} }
function patchInstance(instance, type, patchType, ignoreCheck) { function patchInstance(plugins, instance, type, patchType, ignoreCheck) {
if (instance) { plugins = [plugins].flat(10).filter(n => n);
if (plugins.length && instance) {
let name = type.split(" _ _ ")[0]; let name = type.split(" _ _ ")[0];
instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance; instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance;
instance = ignoreCheck || InternalBDFDB.isInstanceCorrect(instance, name) || WebModulesData.LoadedInComponents[type] ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up:true})); instance = ignoreCheck || InternalBDFDB.isInstanceCorrect(instance, name) || WebModulesData.LoadedInComponents[type] ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up:true}));
if (instance) { if (instance) {
instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance; instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance;
let patchMethods = {}; let toBePatched = WebModulesData.NonPrototype.includes(name) ? instance : instance.prototype;
patchMethods[patchType] = e => { for (let plugin of plugins) {
return InternalBDFDB.initiateProcess(plugin, type, { let patchMethods = {};
instance: window != e.thisObject ? e.thisObject : {props:e.methodArguments[0]}, patchMethods[patchType] = e => {
returnvalue: e.returnValue, return InternalBDFDB.initiateProcess(plugin, type, {
methodname: e.originalMethodName, instance: window != e.thisObject ? e.thisObject : {props:e.methodArguments[0]},
patchtypes: [patchType] returnvalue: e.returnValue,
}) methodname: e.originalMethodName,
}; patchtypes: [patchType]
BDFDB.ModuleUtils.patch(plugin, WebModulesData.NonPrototype.includes(name) ? instance : instance.prototype, plugin.patchedModules[patchType][type], patchMethods); })
};
BDFDB.ModuleUtils.patch(plugin, toBePatched, plugin.patchedModules[patchType][type], patchMethods);
}
} }
} }
} }
function checkEle(ele, type, patchType, instanceObserver) { function checkEle(plugins, ele, type, patchType) {
plugins = [plugins].flat(10).filter(n => n);
let unmappedType = type.split(" _ _ ")[1] || type; let unmappedType = type.split(" _ _ ")[1] || type;
let ins = BDFDB.ReactUtils.getInstance(ele); let ins = BDFDB.ReactUtils.getInstance(ele);
let filter = WebModulesData.SpecialFilter[unmappedType]; let filter = WebModulesData.SpecialFilter[unmappedType];
@ -1550,15 +1591,15 @@
if (component) { if (component) {
if (WebModulesData.NonRender.includes(unmappedType)) { if (WebModulesData.NonRender.includes(unmappedType)) {
let exports = (BDFDB.ModuleUtils.find(m => m == component, false) || {}).exports; let exports = (BDFDB.ModuleUtils.find(m => m == component, false) || {}).exports;
patchInstance(exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, type, patchType, true); patchInstance(plugins, exports && WebModulesData.MemoComponent.includes(unmappedType) ? exports.default : exports, type, patchType, true);
} }
else patchInstance(component, type, patchType, true); else patchInstance(plugins, component, type, patchType, true);
BDFDB.ModuleUtils.forceAllUpdates(plugin, type); BDFDB.ModuleUtils.forceAllUpdates(plugin, type);
return true; return true;
} }
} }
else if (isCorrectInstance(ins, type)) { else if (isCorrectInstance(ins, type)) {
patchInstance(ins, type, patchType); patchInstance(plugins, ins, type, patchType);
BDFDB.ModuleUtils.forceAllUpdates(plugin, type); BDFDB.ModuleUtils.forceAllUpdates(plugin, type);
return true; return true;
} }
@ -1570,30 +1611,44 @@
if (!forceObserve) { if (!forceObserve) {
if (app) { if (app) {
let appIns = BDFDB.ReactUtils.findConstructor(app, type, {unlimited:true}) || BDFDB.ReactUtils.findConstructor(app, type, {unlimited:true, up:true}); let appIns = BDFDB.ReactUtils.findConstructor(app, type, {unlimited:true}) || BDFDB.ReactUtils.findConstructor(app, type, {unlimited:true, up:true});
if (appIns && (instanceFound = true)) patchInstance(appIns, type, patchType); if (appIns && (instanceFound = true)) patchInstance(plugin, appIns, type, patchType);
} }
if (!instanceFound && bdSettings) { if (!instanceFound && bdSettings) {
let bdSettingsIns = BDFDB.ReactUtils.findConstructor(bdSettings, type, {unlimited:true}); let bdSettingsIns = BDFDB.ReactUtils.findConstructor(bdSettings, type, {unlimited:true});
if (bdSettingsIns && (instanceFound = true)) patchInstance(bdSettingsIns, type, patchType); if (bdSettingsIns && (instanceFound = true)) patchInstance(plugin, bdSettingsIns, type, patchType);
} }
} }
if (!instanceFound) { if (!instanceFound) {
let found = false, classes = classNames.map(n => BDFDB.disCN[n]), selector = classNames.map(n => BDFDB.dotCN[n]).join(", "); let elementFound = false, classes = classNames.map(n => BDFDB.disCN[n]), selector = classNames.map(n => BDFDB.dotCN[n]).join(", ");
for (let ele of document.querySelectorAll(selector)) { for (let ele of document.querySelectorAll(selector)) {
found = checkEle(ele, type, patchType); elementFound = checkEle(plugin, ele, type, patchType);
if (found) break; if (elementFound) break;
} }
if (!found) { if (!elementFound) {
let instanceObserver = new MutationObserver(cs => {cs.forEach(c => {c.addedNodes.forEach(n => { if (!BDFDB.InternalData.patchObserverData.observer) {
if (found || !n || !n.tagName) return; let appmount = document.querySelector(BDFDB.dotCN.appmount);
let ele = null; if (appmount) {
if ((ele = BDFDB.DOMUtils.containsClass(n, ...classes) ? n : n.querySelector(selector)) != null) { BDFDB.InternalData.patchObserverData.observer = new MutationObserver(cs => {cs.forEach(c => {c.addedNodes.forEach(n => {
found = checkEle(ele, type, patchType); if (!n || !n.tagName) return;
if (found) instanceObserver.disconnect(); for (let type in BDFDB.InternalData.patchObserverData.data) if (BDFDB.InternalData.patchObserverData.data[type].found) {
let ele = null;
if ((ele = BDFDB.DOMUtils.containsClass(n, ...BDFDB.InternalData.patchObserverData.data[type].classes) ? n : n.querySelector(BDFDB.InternalData.patchObserverData.data[type].selector)) != null) {
BDFDB.InternalData.patchObserverData.data[type].found = checkEle(BDFDB.InternalData.patchObserverData.data[type].plugins, ele, type, patchType);
if (BDFDB.InternalData.patchObserverData.data[type].found) {
delete BDFDB.InternalData.patchObserverData.data[type];
if (BDFDB.ObjectUtils.isEmpty(BDFDB.InternalData.patchObserverData.data)) {
BDFDB.InternalData.patchObserverData.observer.disconnect();
BDFDB.InternalData.patchObserverData.observer = null;
}
}
}
}
});});});
BDFDB.InternalData.patchObserverData.observer.observe(appmount, {childList:true, subtree:true});
} }
});});}); }
BDFDB.ObserverUtils.connect(plugin, BDFDB.dotCN.appmount, {name:"checkForinstanceObserver", instance:instanceObserver, multi:true if (!BDFDB.InternalData.patchObserverData.data[type]) BDFDB.InternalData.patchObserverData.data[type] = {selector, classes, found:false, plugins:[]};
}, {childList:true, subtree:true}); BDFDB.InternalData.patchObserverData.data[type].plugins.push(plugin);
} }
} }
} }
@ -1988,7 +2043,7 @@
if (!BDFDB.ArrayUtils.is(foundInstances[group])) foundInstances[group] = []; if (!BDFDB.ArrayUtils.is(foundInstances[group])) foundInstances[group] = [];
foundInstances[group].push(instance.stateNode); foundInstances[group].push(instance.stateNode);
} }
if (config.type && instance.type) { else if (config.type && instance.type) {
let group = [config.type.find(t => BDFDB.ArrayUtils.is(t) && instance.type === t[1])].flat(10)[0] || "Default"; let group = [config.type.find(t => BDFDB.ArrayUtils.is(t) && instance.type === t[1])].flat(10)[0] || "Default";
if (!BDFDB.ArrayUtils.is(foundInstances[group])) foundInstances[group] = []; if (!BDFDB.ArrayUtils.is(foundInstances[group])) foundInstances[group] = [];
foundInstances[group].push(instance.stateNode); foundInstances[group].push(instance.stateNode);
@ -10308,7 +10363,7 @@
} }
if (role && !avatar.querySelector(BDFDB.dotCN.bdfdbbadge)) { if (role && !avatar.querySelector(BDFDB.dotCN.bdfdbbadge)) {
if (settings.showSupportBadges) { if (settings.showSupportBadges) {
if (BDFDB_Patrons_T3_hasBadge.includes(user.id)) avatar.setAttribute("custom-badge-id", user.id); if (BDFDB_Patrons_T3_hasBadge.includes(user.id)) avatar.setAttribute("custombadge_id", user.id);
let badge = document.createElement("div"); let badge = document.createElement("div");
badge.className = BDFDB.disCN.bdfdbbadge; badge.className = BDFDB.disCN.bdfdbbadge;
badge.addEventListener("mouseenter", _ => {BDFDB.TooltipUtils.create(badge, role, {position});}); badge.addEventListener("mouseenter", _ => {BDFDB.TooltipUtils.create(badge, role, {position});});

File diff suppressed because one or more lines are too long