diff --git a/Plugins/BDFDB.js b/Plugins/BDFDB.js index 8b79745c23..2724a9db66 100644 --- a/Plugins/BDFDB.js +++ b/Plugins/BDFDB.js @@ -1787,14 +1787,14 @@ depth++; var result = undefined; if (instance && !Node.prototype.isPrototypeOf(instance) && !BDFDB.ReactUtils.getInstance(instance) && depth < maxdepth && performance.now() - start < maxtime) { - if (instance.type && types.some(name => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name) === name.split(" _ _ ")[0])) { + if (instance.type && types.some(name => InternalBDFDB.isInstanceCorrect(instance, name.split(" _ _ ")[0]))) { if (config.all === undefined || !config.all) result = instance.type; else if (config.all) { if (!instance.type.BDFDBreactSearch) { instance.type.BDFDBreactSearch = true; if (config.group) { if (instance.type && (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name)) { - let group = config.name.find(n => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type).split(" _ _ ")[0] == n) || "Default"; + let group = config.name.find(name => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type) == name.split(" _ _ ")[0]) || "Default"; if (!BDFDB.ArrayUtils.is(foundConstructors[group])) foundConstructors[group] = []; foundConstructors[group].push(instance.stateNode); } @@ -1858,7 +1858,7 @@ instance.stateNode.BDFDBreactSearch = true; if (config.group) { if (config.name && instance.type && (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type)) { - let group = config.name.find(n => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type) == n.split(" _ _ ")[0]) || "Default"; + let group = config.name.find(name => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type) == name.split(" _ _ ")[0]) || "Default"; if (!BDFDB.ArrayUtils.is(foundInstances[group])) foundInstances[group] = []; foundInstances[group].push(instance.stateNode); } @@ -1902,7 +1902,7 @@ depth++; var result = undefined; if (instance && !Node.prototype.isPrototypeOf(instance) && !BDFDB.ReactUtils.getInstance(instance) && depth < maxdepth && performance.now() - start < maxtime) { - if (instance.memoizedProps && (instance.type && config.name && config.name.some(name => (instance.type.render && instance.type.render.displayName || instance.type.displayName || instance.type.name || instance.type) === name.split(" _ _ ")[0]) || config.key && config.key.some(key => instance.key == key))) result = instance.memoizedProps; + if (instance.memoizedProps && (instance.type && config.name && config.name.some(name => InternalBDFDB.isInstanceCorrect(instance, name.split(" _ _ ")[0])) || config.key && config.key.some(key => instance.key == key))) result = instance.memoizedProps; if (result === undefined) { let keys = Object.getOwnPropertyNames(instance); for (let i = 0; result === undefined && i < keys.length; i++) { diff --git a/Plugins/BDFDB.min.js b/Plugins/BDFDB.min.js index 54676c1241..d862c2c22d 100644 --- a/Plugins/BDFDB.min.js +++ b/Plugins/BDFDB.min.js @@ -1 +1 @@ -(a=>{if(window['BDFDB']&&window['BDFDB']['ListenerUtils']&&typeof window['BDFDB']['ListenerUtils']['remove']=='function')window['BDFDB']['ListenerUtils']['remove'](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']);var b={'myPlugins':Object['assign']({},window['BDFDB']&&window['BDFDB']['myPlugins']),'InternalData':Object['assign']({'pressedKeys':[],'mousePosition':{'pageX':0x0,'pageY':0x0},'componentPatchQueries':{}},window['BDFDB']&&window['BDFDB']['InternalData'],{'creationTime':performance['now']()}),'BDv2Api':window['BDFDB']&&window['BDFDB']['BDv2Api']||undefined,'name':'BDFDB'};var c=Math['round'](Math['random']()*0x2386f26fc10000),d={};b['InternalData']['loadid']=c;if(typeof Array['prototype']['flat']!='function')Array['prototype']['flat']=function(){return this;};d['defaults']={'settings':{'showToasts':{'value':!![],'description':'Show\x20Plugin\x20start\x20and\x20stop\x20Toasts'},'showSupportBadges':{'value':!![],'description':'Show\x20little\x20Badges\x20for\x20Users\x20who\x20support\x20my\x20Patreon'}}};b['LogUtils']={};b['LogUtils']['log']=function(y,z){console['log']('%c['+(typeof z=='string'&&z||'BDFDB')+']','color:\x20#3a71c1;\x20font-weight:\x20700;',(typeof y=='string'&&y||'')['trim']());};b['LogUtils']['warn']=function(y,z){console['warn']('%c['+(typeof z=='string'&&z||'BDFDB')+']','color:\x20#3a71c1;\x20font-weight:\x20700;',(typeof y=='string'&&y||'')['trim']());};b['LogUtils']['error']=function(y,z){console['error']('%c['+(typeof z=='string'&&z||'BDFDB')+']','color:\x20#3a71c1;\x20font-weight:\x20700;','Fatal\x20Error:\x20'+(typeof y=='string'&&y||'')['trim']());};b['LogUtils']['log']('Loading\x20library.');b['PluginUtils']={};b['PluginUtils']['init']=function(y){y['name']=y['name']||(typeof y['getName']=='function'?y['getName']():null);y['version']=y['version']||(typeof y['getVersion']=='function'?y['getVersion']():null);y['author']=y['author']||(typeof y['getAuthor']=='function'?y['getAuthor']():null);y['description']=y['description']||(typeof y['getDescription']=='function'?y['getDescription']():null);d['clearStartTimeout'](y);let z=b['LanguageUtils']['LibraryStringsFormat']('toast_plugin_started','v'+y['version']);b['LogUtils']['log'](z,y['name']);if(!b['BDUtils']['getSettings']('fork-ps-2')&&b['DataUtils']['get'](b,'settings','showToasts'))b['NotificationUtils']['toast'](y['name']+'\x20'+z,{'nopointer':!![],'selector':'plugin-started-toast'});let A=typeof y['getRawUrl']=='function'&&typeof y['getRawUrl']()=='string'?y['getRawUrl']():'https://mwittrien.github.io/BetterDiscordAddons/Plugins/'+y['name']+'/'+y['name']+'.plugin.js';b['PluginUtils']['checkUpdate'](y['name'],A);if(b['ObjectUtils']['is'](y['classes']))d['addPluginClasses'](y);if(typeof y['initConstructor']==='function')b['TimeUtils']['suppress'](y['initConstructor']['bind'](y),'Could\x20not\x20initiate\x20constructor!',y['name'])();if(typeof y['css']==='string')b['DOMUtils']['appendLocalStyle'](y['name'],y['css']);d['patchPlugin'](y);d['addSpecialListeners'](y);b['PluginUtils']['translate'](y);b['PluginUtils']['checkChangeLog'](y);if(!window['PluginUpdates']||typeof window['PluginUpdates']!=='object')window['PluginUpdates']={'plugins':{}};window['PluginUpdates']['plugins'][A]={'name':y['name'],'raw':A,'version':y['version']};if(typeof window['PluginUpdates']['interval']==='undefined')window['PluginUpdates']['interval']=b['TimeUtils']['interval'](B=>{b['PluginUtils']['checkAllUpdates']();},0x3e8*0x3c*0x3c*0x2);y['started']=!![];delete y['stopping'];for(let B in b['myPlugins'])if(!b['myPlugins'][B]['started']&&typeof b['myPlugins'][B]['initialize']=='function')setImmediate(C=>{b['TimeUtils']['suppress'](b['myPlugins'][B]['initialize']['bind'](b['myPlugins'][B]),'Could\x20not\x20initiate\x20plugin!',B)();});};b['PluginUtils']['clear']=function(y){d['clearStartTimeout'](y);delete b['myPlugins'][y['name']];let z=b['LanguageUtils']['LibraryStringsFormat']('toast_plugin_stopped','v'+y['version']);b['LogUtils']['log'](z,y['name']);if(!b['BDUtils']['getSettings']('fork-ps-2')&&b['DataUtils']['get'](b,'settings','showToasts'))b['NotificationUtils']['toast'](y['name']+'\x20'+z,{'nopointer':!![],'selector':'plugin-stopped-toast'});let A=typeof y['getRawUrl']=='function'&&typeof y['getRawUrl']()=='string'?y['getRawUrl']():'https://mwittrien.github.io/BetterDiscordAddons/Plugins/'+y['name']+'/'+y['name']+'.plugin.js';if(b['ObjectUtils']['is'](y['classes']))d['removePluginClasses'](y);if(typeof y['css']==='string')b['DOMUtils']['removeLocalStyle'](y['name']);b['ModuleUtils']['unpatch'](y);b['ListenerUtils']['remove'](y);b['StoreChangeUtils']['remove'](y);b['ObserverUtils']['disconnect'](y);b['WindowUtils']['closeAll'](y);b['WindowUtils']['removeListener'](y);for(let B in b['InternalData']['componentPatchQueries'])b['ArrayUtils']['remove'](b['InternalData']['componentPatchQueries'][B]['query'],y,!![]);for(let C of document['querySelectorAll']('.'+y['name']+'-modal,\x20.'+y['name']['toLowerCase']()+'-modal,\x20.'+y['name']+'-settingsmodal,\x20.'+y['name']['toLowerCase']()+'-settingsmodal')){let D=C['querySelector'](b['dotCN']['modalclose']);if(D)D['click']();}delete b['DataUtils']['cached'][y['name']];delete window['PluginUpdates']['plugins'][A];delete y['started'];b['TimeUtils']['timeout'](E=>{delete y['stopping'];});};b['PluginUtils']['translate']=function(y){y['labels']={};if(typeof y['setLabelsByLanguage']==='function'||typeof y['changeLanguageStrings']==='function'){if(document['querySelector']('html')['lang'])z();else{let A=b['TimeUtils']['interval'](B=>{if(document['querySelector']('html')['lang']){b['TimeUtils']['clear'](A);z();}},0x64);}function z(){let B=b['LanguageUtils']['getLanguage']();if(typeof y['setLabelsByLanguage']==='function')y['labels']=y['setLabelsByLanguage'](B['id']);if(typeof y['changeLanguageStrings']==='function')y['changeLanguageStrings']();b['LogUtils']['log'](b['LanguageUtils']['LibraryStringsFormat']('toast_plugin_translated',B['ownlang']),y['name']);}}};b['PluginUtils']['checkUpdate']=function(y,z){if(y&&z)return new Promise(A=>{j['request'](z,(B,C,D)=>{if(B)return A(null);let E=D['match'](/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i);if(!E)return A(null);if(b['NumberUtils']['getVersionDifference'](E[0x0],window['PluginUpdates']['plugins'][z]['version'])>0.2){b['NotificationUtils']['toast'](y+'\x20will\x20be\x20force\x20updated,\x20because\x20your\x20version\x20is\x20heavily\x20outdated.',{'type':'warn','nopointer':!![],'selector':'plugin-forceupdate-toast'});b['PluginUtils']['downloadUpdate'](y,z);return A(0x2);}else if(b['NumberUtils']['compareVersions'](E[0x0],window['PluginUpdates']['plugins'][z]['version'])){b['PluginUtils']['showUpdateNotice'](y,z);return A(0x1);}else{b['PluginUtils']['removeUpdateNotice'](y);return A(0x0);}});});return new Promise(A=>{callback(null);});};b['PluginUtils']['checkAllUpdates']=function(){return new Promise(y=>{let z=0x0,A=0x0;for(let B in window['PluginUpdates']['plugins']){let C=window['PluginUpdates']['plugins'][B];if(C)b['PluginUtils']['checkUpdate'](C['name'],C['raw'])['then'](D=>{z++;if(D==0x1)A++;if(z>=Object['keys'](window['PluginUpdates']['plugins'])['length'])y(A);});}});};b['PluginUtils']['showUpdateNotice']=function(y,z){if(!y||!z)return;let A=document['querySelector']('#pluginNotice');if(!A){A=b['NotificationUtils']['notice']('The\x20following\x20plugins\x20need\x20to\x20be\x20updated: ',{'html':!![],'id':'pluginNotice','type':'info','btn':!b['BDUtils']['isAutoLoadEnabled']()?'Reload':'','customicon':''});A['style']['setProperty']('display','block','important');A['style']['setProperty']('visibility','visible','important');A['style']['setProperty']('opacity','1','important');A['querySelector'](b['dotCN']['noticedismiss'])['addEventListener']('click',C=>{b['DOMUtils']['remove']('.update-clickme-tooltip');});let B=A['querySelector'](b['dotCN']['noticebutton']);if(B){b['DOMUtils']['toggle'](B,!![]);B['addEventListener']('click',C=>{j['electron']['remote']['getCurrentWindow']()['reload']();});B['addEventListener']('mouseenter',C=>{if(window['PluginUpdates']['downloaded'])b['TooltipUtils']['create'](B,window['PluginUpdates']['downloaded']['join'](',\x20'),{'type':'bottom','selector':'update-notice-tooltip','style':'max-width:\x20420px'});});}}if(A){let C=A['querySelector']('#outdatedPlugins');if(C&&!C['querySelector']('#'+y+'-notice')){if(C['querySelector']('span'))C['appendChild'](b['DOMUtils']['create'](',\x20'));let D=b['DOMUtils']['create'](''+y+'');D['addEventListener']('click',E=>{b['PluginUtils']['downloadUpdate'](y,z);});C['appendChild'](D);if(!document['querySelector']('.update-clickme-tooltip'))b['TooltipUtils']['create'](C,'Click\x20us!',{'type':'bottom','selector':'update-clickme-tooltip','delay':0x1f4});}}};b['PluginUtils']['removeUpdateNotice']=function(y,z=document['querySelector']('#pluginNotice')){if(!y||!z)return;let A=z['querySelector']('#outdatedPlugins');if(A){let B=A['querySelector']('#'+y+'-notice');if(B){let C=B['nextSibling'];let D=B['prevSibling'];if(C&&b['DOMUtils']['containsClass'](C,'separator'))C['remove']();else if(D&&b['DOMUtils']['containsClass'](D,'separator'))D['remove']();B['remove']();}if(!A['querySelector']('span')){let E=z['querySelector'](b['dotCN']['noticebutton']);if(E){z['querySelector']('.notice-message')['innerText']='To\x20finish\x20updating\x20you\x20need\x20to\x20reload.';b['DOMUtils']['toggle'](E,![]);}else z['querySelector'](b['dotCN']['noticedismiss'])['click']();}}};b['PluginUtils']['downloadUpdate']=function(y,z){if(!y||!z)return;j['request'](z,(A,B,C)=>{if(A)return b['LogUtils']['warn']('Unable\x20to\x20get\x20update\x20for\x20'+y);b['InternalData']['creationTime']=0x0;let D=C['match'](/['"][0-9]+\.[0-9]+\.[0-9]+['"]/i);D=D['toString']()['replace'](/['"]/g,'');j['fs']['writeFileSync'](j['path']['join'](b['BDUtils']['getPluginsFolder'](),z['split']('/')['slice'](-0x1)[0x0]),C);b['NotificationUtils']['toast'](y+'\x20v'+window['PluginUpdates']['plugins'][z]['version']+'\x20has\x20been\x20replaced\x20by\x20'+y+'\x20v'+D+'.',{'nopointer':!![],'selector':'plugin-updated-toast'});let E=document['querySelector']('#pluginNotice');if(E){if(E['querySelector'](b['dotCN']['noticebutton'])){window['PluginUpdates']['plugins'][z]['version']=D;if(!window['PluginUpdates']['downloaded'])window['PluginUpdates']['downloaded']=[];if(!window['PluginUpdates']['downloaded']['includes'](y))window['PluginUpdates']['downloaded']['push'](y);}b['PluginUtils']['removeUpdateNotice'](y,E);}});};b['PluginUtils']['checkChangeLog']=function(y){if(!b['ObjectUtils']['is'](y)||!y['changelog'])return;let z=b['DataUtils']['load'](y,'changelog');if(!z['currentversion']||b['NumberUtils']['compareVersions'](y['version'],z['currentversion'])){z['currentversion']=y['version'];b['DataUtils']['save'](z,y,'changelog');b['PluginUtils']['openChangeLog'](y);}};b['PluginUtils']['openChangeLog']=function(y){if(!b['ObjectUtils']['is'](y)||!y['changelog'])return;let z='',A={'added':'New\x20Features','fixed':'Bug\x20Fixes','improved':'Improvements','progress':'Progress'};for(let B in y['changelog']){B=B['toLowerCase']();let C=b['disCN']['changelog'+B];if(C){z+='