This commit is contained in:
Mirco Wittrien 2022-01-11 13:57:32 +01:00
parent 79cf7d94a7
commit 2cabe62e10
3 changed files with 76 additions and 73 deletions

View File

@ -2,7 +2,7 @@
* @name BDFDB
* @author DevilBro
* @authorId 278543574059057154
* @version 2.0.4
* @version 2.0.5
* @description Required Library for DevilBro's Plugins
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -19,10 +19,15 @@ module.exports = (_ => {
"info": {
"name": "BDFDB",
"author": "DevilBro",
"version": "2.0.4",
"version": "2.0.5",
"description": "Required Library for DevilBro's Plugins"
},
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`
"rawUrl": `https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js`,
"changeLog": {
"progress": {
"Update Fixes": "Slowly fixing all the Shit Discord broke"
}
}
};
const DiscordObjects = {};
@ -1187,14 +1192,14 @@ module.exports = (_ => {
else return "";
};
InternalBDFDB.findModule = function (type, cacheString, filter, getExport) {
InternalBDFDB.findModule = function (type, cacheString, filter, useExport) {
if (!BDFDB.ObjectUtils.is(Cache.modules[type])) Cache.modules[type] = {module: {}, export: {}};
if (getExport && Cache.modules[type].export[cacheString]) return Cache.modules[type].export[cacheString];
else if (!getExport && Cache.modules[type].module[cacheString]) return Cache.modules[type].module[cacheString];
if (useExport && Cache.modules[type].export[cacheString]) return Cache.modules[type].export[cacheString];
else if (!useExport && Cache.modules[type].module[cacheString]) return Cache.modules[type].module[cacheString];
else {
let m = BDFDB.ModuleUtils.find(filter, getExport);
let m = BDFDB.ModuleUtils.find(filter, {useExport: useExport});
if (m) {
if (getExport) Cache.modules[type].export[cacheString] = m;
if (useExport) Cache.modules[type].export[cacheString] = m;
else Cache.modules[type].module[cacheString] = m;
return m;
}
@ -1203,65 +1208,78 @@ module.exports = (_ => {
};
BDFDB.ModuleUtils = {};
BDFDB.ModuleUtils.find = function (filter, getExport) {
getExport = typeof getExport != "boolean" ? true : getExport;
BDFDB.ModuleUtils.find = function (filter, config = {}) {
let useExport = typeof config.useExport != "boolean" ? true : config.useExport;
let onlySearchUnloaded = typeof config.onlySearchUnloaded != "boolean" ? false : config.onlySearchUnloaded;
let req = InternalBDFDB.getWebModuleReq();
for (let i in req.c) if (req.c.hasOwnProperty(i)) {
if (!onlySearchUnloaded) for (let i in req.c) if (req.c.hasOwnProperty(i)) {
let m = req.c[i].exports, r = null;
if (m && (typeof m == "object" || typeof m == "function") && !!(r = filter(m))) return getExport ? r : req.c[i];
if (m && (typeof m == "object" || typeof m == "function") && !!(r = filter(m))) return useExport ? r : req.c[i];
if (m && m.__esModule && m.default && (typeof m.default == "object" || typeof m.default == "function")) {
if (!!(r = filter(m.default))) return getExport ? r : req.c[i];
else if (m.default.type && (typeof m.default.type == "object" || typeof m.default.type == "function") && !!(r = filter(m.default.type))) return getExport ? r : req.c[i];
if (!!(r = filter(m.default))) return useExport ? r : req.c[i];
else if (m.default.type && (typeof m.default.type == "object" || typeof m.default.type == "function") && !!(r = filter(m.default.type))) return useExport ? r : req.c[i];
}
}
for (let i in req.m) if (req.m.hasOwnProperty(i)) {
let m = req.m[i];
if (m && typeof m == "function" && filter(m)) {
if (req.c[i]) return getExport ? req.c[i].exports : req.c[i];
else {
if (m && typeof m == "function") {
if (req.c[i] && !onlySearchUnloaded && filter(m)) return useExport ? req.c[i].exports : req.c[i];
if (!req.c[i] && onlySearchUnloaded && filter(m)) {
let resolved = {}, resolved2 = {};
m(resolved, resolved2, req);
let trueResolved = resolved2 && BDFDB.ObjectUtils.isEmpty(resolved2) ? resolved : resolved2;
return getExport ? trueResolved.exports : trueResolved;
return useExport ? trueResolved.exports : trueResolved;
}
}
}
};
BDFDB.ModuleUtils.findByProperties = function (...properties) {
properties = properties.flat(10);
let getExport = properties.pop();
if (typeof getExport != "boolean") {
properties.push(getExport);
getExport = true;
let useExport = properties.pop();
if (typeof useExport != "boolean") {
properties.push(useExport);
useExport = true;
}
return InternalBDFDB.findModule("prop", JSON.stringify(properties), m => properties.every(prop => {
const value = m[prop];
return value !== undefined && !(typeof value == "string" && !value);
}) && m, getExport);
}) && m, useExport);
};
BDFDB.ModuleUtils.findByName = function (name, getExport) {
return InternalBDFDB.findModule("name", JSON.stringify(name), m => m.displayName === name && m || m.render && m.render.displayName === name && m || m[name] && m[name].displayName === name && m[name], typeof getExport != "boolean" ? true : getExport);
BDFDB.ModuleUtils.findByName = function (name, useExport) {
return InternalBDFDB.findModule("name", JSON.stringify(name), m => m.displayName === name && m || m.render && m.render.displayName === name && m || m[name] && m[name].displayName === name && m[name], typeof useExport != "boolean" ? true : useExport);
};
BDFDB.ModuleUtils.findByString = function (...strings) {
strings = strings.flat(10);
let getExport = strings.pop();
if (typeof getExport != "boolean") {
strings.push(getExport);
getExport = true;
let useExport = strings.pop();
if (typeof useExport != "boolean") {
strings.push(useExport);
useExport = true;
}
return InternalBDFDB.findModule("string", JSON.stringify(strings), m => strings.every(string => typeof m == "function" && (m.toString().indexOf(string) > -1 || typeof m.__originalMethod == "function" && m.__originalMethod.toString().indexOf(string) > -1 || typeof m.__originalFunction == "function" && m.__originalFunction.toString().indexOf(string) > -1) || BDFDB.ObjectUtils.is(m) && typeof m.type == "function" && m.type.toString().indexOf(string) > -1) && m, getExport);
return InternalBDFDB.findModule("string", JSON.stringify(strings), m => strings.every(string => typeof m == "function" && (m.toString().indexOf(string) > -1 || typeof m.__originalMethod == "function" && m.__originalMethod.toString().indexOf(string) > -1 || typeof m.__originalFunction == "function" && m.__originalFunction.toString().indexOf(string) > -1) || BDFDB.ObjectUtils.is(m) && typeof m.type == "function" && m.type.toString().indexOf(string) > -1) && m, useExport);
};
BDFDB.ModuleUtils.findByPrototypes = function (...protoProps) {
protoProps = protoProps.flat(10);
let getExport = protoProps.pop();
if (typeof getExport != "boolean") {
protoProps.push(getExport);
getExport = true;
let useExport = protoProps.pop();
if (typeof useExport != "boolean") {
protoProps.push(useExport);
useExport = true;
}
return InternalBDFDB.findModule("proto", JSON.stringify(protoProps), m => m.prototype && protoProps.every(prop => {
const value = m.prototype[prop];
return value !== undefined && !(typeof value == "string" && !value);
}) && m, getExport);
}) && m, useExport);
};
BDFDB.ModuleUtils.findStringObject = function (props, config = {}) {
return BDFDB.ModuleUtils.find(m => {
let amount = Object.keys(m).length;
return (!config.length || (config.smaller ? amount < config.length : amount == config.length)) && [props].flat(10).every(prop => typeof m[prop] == "string") && m;
}) || BDFDB.ModuleUtils.find(m => {
if (typeof m != "function") return false;
let stringified = m.toString().replace(/\s/g, "");
if (stringified.indexOf("e=>{e.exports={") != 0) return false;
let amount = stringified.split(":\"").length - 1;
return (!config.length || (config.smaller ? amount < config.length : amount == config.length)) && [props].flat(10).every(string => stringified.indexOf(`${string}:`) > -1) && m;
}, {onlySearchUnloaded: true});
};
BDFDB.ObserverUtils = {};
@ -2145,7 +2163,7 @@ module.exports = (_ => {
config.nonPrototype = !!(config.subComponent && config.subComponent.strings || config.stringFind || config.subComponent && config.subComponent.props || 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 && m, config.exported) || {}).exports : component, type, config);
if (component) InternalBDFDB.patchComponent(pluginData, config.nonRender ? (BDFDB.ModuleUtils.find(m => m == component && m, {useExport: config.exported}) || {}).exports : component, type, config);
else {
let mappedType = config.mapped ? config.mapped + " _ _ " + type : type;
let name = config.subComponent && config.subComponent.name || mappedType.split(" _ _ ")[0];
@ -2221,7 +2239,7 @@ module.exports = (_ => {
let component = config.specialFilter(ins);
if (component) {
if (config.nonRender) {
let exports = (BDFDB.ModuleUtils.find(m => m == component && m, false) || {}).exports;
let exports = (BDFDB.ModuleUtils.find(m => m == component && m, {useExport: false}) || {}).exports;
InternalBDFDB.patchComponent(pluginDataObjs, InternalBDFDB.isMemoOrForwardRef(exports) ? exports.default : exports, type, config);
}
else InternalBDFDB.patchComponent(pluginDataObjs, component, type, config);
@ -4410,10 +4428,7 @@ module.exports = (_ => {
};
const DiscordClassModules = Object.assign({}, InternalData.CustomClassModules);
for (let name in InternalData.DiscordClassModules) {
if (InternalData.DiscordClassModules[name].length) DiscordClassModules[name] = BDFDB.ModuleUtils.find(m => InternalData.DiscordClassModules[name].props.every(prop => typeof m[prop] == "string") && (InternalData.DiscordClassModules[name].smaller ? Object.keys(m).length < InternalData.DiscordClassModules[name].length : Object.keys(m).length == InternalData.DiscordClassModules[name].length) && m);
else DiscordClassModules[name] = BDFDB.ModuleUtils.findByProperties(InternalData.DiscordClassModules[name].props);
}
for (let name in InternalData.DiscordClassModules) DiscordClassModules[name] = BDFDB.ModuleUtils.findStringObject(InternalData.DiscordClassModules[name].props, Object.assign({}, InternalData.DiscordClassModules[name]));
BDFDB.DiscordClassModules = Object.assign({}, DiscordClassModules);
const DiscordClasses = Object.assign({}, InternalData.DiscordClasses);
@ -8108,7 +8123,7 @@ module.exports = (_ => {
if (BDFDB.ObjectUtils.is(menu) && menu.type && menu.type.displayName) {
for (let type of ContextMenuTypes) if (menu.type.displayName.indexOf(type) > -1) {
let patchType = type + "ContextMenu";
let module = BDFDB.ModuleUtils.find(m => m == menu.type && m, false);
let module = BDFDB.ModuleUtils.find(m => m == menu.type && m, {useExport: false});
if (module && module.exports && module.exports.default && PluginStores.patchQueues[patchType]) {
PluginStores.patchQueues[patchType].modules.push(module);
PluginStores.patchQueues[patchType].modules = BDFDB.ArrayUtils.removeCopies(PluginStores.patchQueues[patchType].modules);

View File

@ -130,7 +130,6 @@
"SoundStateUtils": {"props": ["isSoundDisabled", "getDisabledSounds"]},
"SoundUtils": {"props": ["playSound", "createSound"]},
"SpellCheckStore": {"strings": ["SPELLCHECK_LEARN_WORD", "isEnabled"], "value": "default"},
"SpellCheckUtils": {"props": ["learnWord", "toggleSpellcheck"]},
"SpotifyTrackUtils": {"props": ["hasConnectedAccount", "getLastPlayedTrackId"]},
"SpotifyUtils": {"props": ["setActiveDevice", "pause"]},
"StageChannelLiveStore": {"props": ["getAllLiveStageChannels", "useAllLiveStageChannels"]},
@ -231,7 +230,7 @@
"MessageHeader": {"strings": ["ANIMATE_CHAT_AVATAR", "showUsernamePopout"]},
"Messages": {"strings": ["group-spacing-", "canManageMessages"]},
"MessageUsername": {"strings": [".default.username", "colorString", "compact"]},
"ModalLayer": {"class": "layermodal"},
"ModalLayer": {"class": "modal"},
"Note": {"class": "usernotetextarea"},
"PeoplePageList": {"strings": ["FriendsSections", "emptyStateContainer"]},
"PopoutContainer": {"class": "popout"},
@ -1253,7 +1252,6 @@
"Item": {"props": ["item", "side", "header"]},
"ItemRole": {"props": ["role", "dragged"]},
"ItemLayerContainer": {"props": ["layer", "layerContainer"]},
"LayerModal": {"props": ["root", "small", "medium"]},
"Layers": {"props": ["layer", "layers"]},
"LiveTag": {"props": ["liveLarge", "live"]},
"LoadingScreen": {"props": ["container", "problemsText", "problems"]},
@ -1290,11 +1288,11 @@
"MessageSystemAccessories": {"props": ["name", "spine", "cta"]},
"MessageToolbar": {"props": ["container", "icon", "isHeader"]},
"MessageToolbarItems": {"props": ["wrapper", "button", "separator"]},
"Modal": {"props": ["modal", "sizeLarge"]},
"Modal": {"props": ["root", "small", "medium"]},
"ModalDivider": {"props": ["divider"], "length": 1},
"ModalItems": {"props": ["guildName", "checkboxContainer"]},
"ModalMiniContent": {"props": ["modal", "content"], "length": 2},
"ModalWrap": {"props": ["modal", "inner"], "length": 2},
"ModalSub": {"props": ["modal", "sizeLarge"]},
"NameContainer": {"props": ["nameAndDecorators", "name"]},
"NameTag": {"props": ["bot", "nameTag"]},
"NitroStore": {"props": ["applicationStore", "marketingHeader"]},
@ -2337,10 +2335,6 @@
"invitestatusonline": ["GuildInvite", "statusOnline"],
"inviteuserselectnone": ["GuildInvite", "userSelectNone"],
"italics": ["TextStyle", "italics"],
"layermodal": ["LayerModal", "root"],
"layermodallarge": ["LayerModal", "large"],
"layermodalmedium": ["LayerModal", "medium"],
"layermodalsmall": ["LayerModal", "small"],
"layer": ["Layers", "layer"],
"layerbase": ["Layers", "baseLayer"],
"layers": ["Layers", "layers"],
@ -2598,28 +2592,30 @@
"messageusername": ["MessageBody", "username"],
"messagewrapper": ["MessageBody", "wrapper"],
"messagezalgo": ["MessageBody", "zalgo"],
"modal": ["ModalWrap", "modal"],
"modal": ["Modal", "root"],
"modalcancelbutton": ["CustomStatusModal", "cancelButton"],
"modalclose": ["LayerModal", "close"],
"modalclose": ["Modal", "close"],
"modalchangelogmodal": ["BDFDB", "changeLogModal"],
"modalconfirmmodal": ["BDFDB", "confirmModal"],
"modalcontent": ["LayerModal", "content"],
"modalfooter": ["LayerModal", "footer"],
"modalcontent": ["Modal", "content"],
"modalfooter": ["Modal", "footer"],
"modalguildname": ["ModalItems", "guildName"],
"modalheader": ["LayerModal", "header"],
"modalheader": ["Modal", "header"],
"modalheaderhassibling": ["BDFDB", "modalHeaderHasSibling"],
"modalheadershade": ["BDFDB", "modalHeaderShade"],
"modalinner": ["ModalWrap", "inner"],
"modallarge": ["Modal", "large"],
"modalmedium": ["Modal", "medium"],
"modalmini": ["ModalMiniContent", "modal"],
"modalminicontent": ["ModalMiniContent", "content"],
"modalminitext": ["HeaderBarTopic", "content"],
"modalnoscroller": ["BDFDB", "modalNoScroller"],
"modalseparator": ["LayerModal", "separator"],
"modalseparator": ["Modal", "separator"],
"modalsidebar": ["BDFDB", "modalSidebar"],
"modalsizelarge": ["Modal", "sizeLarge"],
"modalsizemedium": ["Modal", "sizeMedium"],
"modalsizesmall": ["Modal", "sizeSmall"],
"modalsub": ["Modal", "modal"],
"modalsmall": ["Modal", "small"],
"modalsub": ["ModalSub", "modal"],
"modalsublarge": ["ModalSub", "sizeLarge"],
"modalsubmedium": ["ModalSub", "sizeMedium"],
"modalsubsmall": ["ModalSub", "sizeSmall"],
"modalsubinner": ["BDFDB", "modalSubInner"],
"modaltabcontent": ["BDFDB", "modalTabContent"],
"modaltabcontentopen": ["BDFDB", "modalTabContentOpen"],

View File

@ -2,7 +2,7 @@
* @name SpellCheck
* @author DevilBro
* @authorId 278543574059057154
* @version 1.5.7
* @version 1.5.8
* @description Adds a Spell Check to all Message Inputs. Select a Word and Right Click it to add it to your Dictionary
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -17,7 +17,7 @@ module.exports = (_ => {
"info": {
"name": "SpellCheck",
"author": "DevilBro",
"version": "1.5.7",
"version": "1.5.8",
"description": "Adds a Spell Check to all Message Inputs. Select a Word and Right Click it to add it to your Dictionary"
}
};
@ -104,19 +104,11 @@ module.exports = (_ => {
}
onStart () {
// REMOVE 28.05.2021
let oldData = BDFDB.DataUtils.load(this);
if (oldData.settings) {
this.settings.general = oldData.settings;
BDFDB.DataUtils.save(this.settings.general, this, "general");
BDFDB.DataUtils.remove(this, "settings");
}
BDFDB.LibraryRequires.request("https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpellCheck/dic", (error, response, body) => {
let dictionaryLanguageIds = Array.from(BDFDB.DOMUtils.create(body).querySelectorAll(`[href*="/mwittrien/BetterDiscordAddons/blob/master/Plugins/SpellCheck/dic/"]`)).map(n => n.innerText.split(".")[0]).filter(n => n);
languages = BDFDB.ObjectUtils.filter(BDFDB.LanguageUtils.languages, langId => dictionaryLanguageIds.includes(langId), true);
if (BDFDB.LibraryModules.SpellCheckStore && BDFDB.LibraryModules.SpellCheckStore.isEnabled()) BDFDB.LibraryModules.SpellCheckUtils.toggleSpellcheck();
if (BDFDB.LibraryModules.SpellCheckStore && BDFDB.LibraryModules.SpellCheckStore.isEnabled()) BDFDB.LibraryModules.DispatchApiUtils.dispatch({type: BDFDB.DiscordConstants.ActionTypes.SPELLCHECK_TOGGLE});
BDFDB.PatchUtils.forceAllUpdates(this);