This commit is contained in:
Mirco Wittrien 2019-10-21 12:11:46 +02:00
parent 1012d66226
commit 5a981d44f6
5 changed files with 184 additions and 150 deletions

View File

@ -981,6 +981,59 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
var node = LibraryModules.ReactDOM.findDOMNode(instance) || BDFDB.ReactUtils.getValue(instance, "child.stateNode");
return Node.prototype.isPrototypeOf(node) ? node : null;
};
BDFDB.ReactUtils.findOwner = function (nodeOrInstance, config) {
if (!nodeOrInstance || !BDFDB.ObjectUtils.is(config) || !config.name && !config.props) return null;
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
if (!BDFDB.ObjectUtils.is(instance)) return null;
config.name = config.name && !BDFDB.ArrayUtils.is(config.name) ? Array.of(config.name) : config.name;
config.props = config.props && !BDFDB.ArrayUtils.is(config.props) ? Array.of(config.props) : config.props;
var depth = -1;
var maxdepth = config.depth === undefined ? 15 : config.depth;
var start = performance.now();
var maxtime = config.time === undefined ? 150 : config.time;
var whitelist = config.up ? {return:true, sibling:true, _reactInternalFiber:true} : {child:true, sibling:true, _reactInternalFiber:true};
var foundinstances = {};
var singleinstance = getOwner(instance);
if (config.all) {
for (let type in foundinstances) {
if (config.group) for (let instance in foundinstances[type]) delete foundinstances[type][instance].BDFDBreactSearch;
else delete foundinstances[type].BDFDBreactSearch;
}
return foundinstances;
}
else return singleinstance;
function getOwner (instance) {
depth++;
var result = null;
if (instance && !Node.prototype.isPrototypeOf(instance) && !BDFDB.ReactUtils.getInstance(instance) && depth < maxdepth && performance.now() - start < maxtime) for (let key of Object.getOwnPropertyNames(instance)) if (key) {
var value = instance[key];
if (instance.stateNode && !Node.prototype.isPrototypeOf(instance.stateNode) && (instance.type && config.name && config.name.some(name => instance.type.displayName === name.split(" _ _ ")[0] || instance.type.name === name.split(" _ _ ")[0]) || config.props && config.props.every(prop => BDFDB.ArrayUtils.is(prop) ? BDFDB.equals(instance.stateNode.props[prop[0]], prop[1]) : instance.stateNode.props[prop] !== undefined))) {
if (config.all === undefined || !config.all) result = instance.stateNode;
else if (config.all) {
if (config.noCopies === undefined || !config.noCopies || config.noCopies && !instance.stateNode.BDFDBreactSearch) {
instance.stateNode.BDFDBreactSearch = true;
if (config.group) {
if (config.name && instance.type && (instance.type.displayName || instance.type.name)) {
var group = "Default";
for (let name of config.name) if (instance.type.displayName === name.split(" _ _ ")[0] || instance.type.name === name.split(" _ _ ")[0]) {
group = name;
break;
}
if (typeof foundinstances[group] == "undefined") foundinstances[group] = {};
BDFDB.ObjectUtils.push(foundinstances[group], instance.stateNode);
}
}
else BDFDB.ObjectUtils.push(foundinstances, instance.stateNode);
}
}
}
else if ((typeof value === "object" || typeof value === "function") && whitelist[key]) result = getOwner(value);
}
depth--;
return result;
}
};
BDFDB.ReactUtils.findValue = function (nodeOrInstance, searchkey, config = {}) {
if (!nodeOrInstance || typeof searchkey != "string") return null;
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
@ -1017,31 +1070,24 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
else return singlekey;
function getKey(instance) {
depth++;
if (!instance || Node.prototype.isPrototypeOf(instance) || BDFDB.ReactUtils.getInstance(instance) || depth > maxdepth || performance.now() - start > maxtime) result = null;
else {
var keys = Object.getOwnPropertyNames(instance);
var result = null;
for (let i = 0; result == null && i < keys.length; i++) {
var key = keys[i];
if (key && !blacklist[key]) {
var value = instance[key];
if (searchkey === key && (config.value === undefined || config.value === value)) {
if (config.all === undefined || !config.all) result = value;
else if (config.all) {
if (config.noCopies === undefined || !config.noCopies) foundkeys.push(value);
else if (config.noCopies) {
var copy = false;
for (let foundkey of foundkeys) if (BDFDB.equals(value, foundkey)) {
copy = true;
break;
}
if (!copy) foundkeys.push(value);
}
var result = null;
if (instance && !Node.prototype.isPrototypeOf(instance) && !BDFDB.ReactUtils.getInstance(instance) && depth < maxdepth && performance.now() - start < maxtime) for (let key of Object.getOwnPropertyNames(instance)) if (key && !blacklist[key]) {
var value = instance[key];
if (searchkey === key && (config.value === undefined || BDFDB.equals(config.value, value))) {
if (config.all === undefined || !config.all) result = value;
else if (config.all) {
if (config.noCopies === undefined || !config.noCopies) foundkeys.push(value);
else if (config.noCopies) {
var copy = false;
for (let foundkey of foundkeys) if (BDFDB.equals(value, foundkey)) {
copy = true;
break;
}
if (!copy) foundkeys.push(value);
}
else if ((typeof value === "object" || typeof value === "function") && (whitelist[key] || key[0] == "." || !isNaN(key[0]))) result = getKey(value);
}
}
else if ((typeof value === "object" || typeof value === "function") && (whitelist[key] || key[0] == "." || !isNaN(key[0]))) result = getKey(value);
}
depth--;
return result;
@ -1054,66 +1100,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
if (!BDFDB.ObjectUtils.is(node)) return null;
return node[Object.keys(node).find(key => key.startsWith("__reactInternalInstance"))];
};
BDFDB.ReactUtils.getOwner = function (nodeOrInstance, config) {
if (!nodeOrInstance || !BDFDB.ObjectUtils.is(config) || !config.name && !config.props) return null;
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
if (!BDFDB.ObjectUtils.is(instance)) return null;
config.name = config.name && !BDFDB.ArrayUtils.is(config.name) ? Array.of(config.name) : config.name;
config.props = config.props && !BDFDB.ArrayUtils.is(config.props) ? Array.of(config.props) : config.props;
var depth = -1;
var maxdepth = config.depth === undefined ? 15 : config.depth;
var up = config.up === undefined ? false : config.up;
var start = performance.now();
var maxtime = config.time === undefined ? 150 : config.time;
var whitelist = up ? {return:true, sibling:true, _reactInternalFiber:true} : {child:true, sibling:true, _reactInternalFiber:true};
var foundinstances = {};
var singleinstance = getInstance(instance);
if (config.all) {
for (let type in foundinstances) {
if (config.group) for (let instance in foundinstances[type]) delete foundinstances[type][instance].BDFDBreactSearch;
else delete foundinstances[type].BDFDBreactSearch;
}
return foundinstances;
}
else return singleinstance;
function getInstance (instance) {
depth++;
if (!instance || Node.prototype.isPrototypeOf(instance) || BDFDB.ReactUtils.getInstance(instance) || depth > maxdepth || performance.now() - start > maxtime) return null;
else {
var keys = Object.getOwnPropertyNames(instance);
var result = null;
for (let i = 0; result == null && i < keys.length; i++) {
var key = keys[i];
var value = instance[key];
var statenode = instance.stateNode ? instance.stateNode : (instance.return ? instance.return.stateNode : null);
if (statenode && !Node.prototype.isPrototypeOf(statenode) && (instance.type && config.name && config.name.some(name => instance.type.displayName === name.split(" _ _ ")[0] || instance.type.name === name.split(" _ _ ")[0]) || config.props && config.props.every(prop => statenode[prop] !== undefined) || config.defaultProps && config.defaultProps.every(prop => statenode[prop] !== undefined))) {
if (config.all === undefined || !config.all) result = statenode;
else if (config.all) {
if (config.noCopies === undefined || !config.noCopies || config.noCopies && !statenode.BDFDBreactSearch) {
statenode.BDFDBreactSearch = true;
if (config.group) {
if (config.name && instance.type && (instance.type.displayName || instance.type.name)) {
var group = "Default";
for (let name of config.name) if (instance.type.displayName === name.split(" _ _ ")[0] || instance.type.name === name.split(" _ _ ")[0]) {
group = name;
break;
}
if (typeof foundinstances[group] == "undefined") foundinstances[group] = {};
BDFDB.ObjectUtils.push(foundinstances[group], statenode);
}
}
else BDFDB.ObjectUtils.push(foundinstances, statenode);
}
}
}
if (result == null && (typeof value === "object" || typeof value === "function") && whitelist[key]) result = getInstance(value);
}
}
depth--;
return result;
}
};
BDFDB.ReactUtils.getValue = function (nodeOrInstance, valuepath) {
if (!nodeOrInstance || !valuepath) return null;
var instance = Node.prototype.isPrototypeOf(nodeOrInstance) ? BDFDB.ReactUtils.getInstance(nodeOrInstance) : nodeOrInstance;
@ -1263,10 +1249,10 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
filteredmodules = selectedtype ? filteredmodules.filter(type => type == selectedtype) : filteredmodules;
if (filteredmodules.length) {
try {
const appins = BDFDB.ReactUtils.getOwner(app, {name:filteredmodules, all:true, noCopies:true, group:true, depth:99999999, time:99999999});
const appins = BDFDB.ReactUtils.findOwner(app, {name:filteredmodules, all:true, noCopies:true, group:true, depth:99999999, time:99999999});
for (let type in appins) for (let i in appins[type]) InternalBDFDB.forceInitiateProcess(plugin, appins[type][i], type);
if (bdsettings) {
const bdsettingsins = BDFDB.ReactUtils.getOwner(bdsettings, {name:filteredmodules, all:true, noCopies:true, group:true, depth:99999999, time:99999999});
const bdsettingsins = BDFDB.ReactUtils.findOwner(bdsettings, {name:filteredmodules, all:true, noCopies:true, group:true, depth:99999999, time:99999999});
for (let type in bdsettingsins) for (let i in bdsettingsins[type]) InternalBDFDB.forceInitiateProcess(plugin, bdsettingsins[type][i], type);
}
}
@ -1300,7 +1286,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
if (instance) {
var name = type.split(" _ _ ")[0];
instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance;
instance = instance.displayName == name ? instance : BDFDB.ReactUtils.getOwner(instance, {name, up:true});
instance = instance.displayName == name ? instance : BDFDB.ReactUtils.findOwner(instance, {name, up:true});
if (instance) {
instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance;
BDFDB.ModuleUtils.patch(plugin, instance.prototype, plugin.patchModules[type], {after: e => {
@ -1313,14 +1299,14 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
const app = document.querySelector(BDFDB.dotCN.app), bdsettings = document.querySelector("#bd-settingspane-container " + BDFDB.dotCN.scrollerwrap);
var instancefound = false;
if (app) {
var appins = BDFDB.ReactUtils.getOwner(app, {name:type, depth:99999999, time:99999999});
var appins = BDFDB.ReactUtils.findOwner(app, {name:type, depth:99999999, time:99999999});
if (appins) {
instancefound = true;
patchInstance(appins, type);
}
}
if (!instancefound && bdsettings) {
var bdsettingsins = BDFDB.ReactUtils.getOwner(bdsettings, {name:type, depth:99999999, time:99999999});
var bdsettingsins = BDFDB.ReactUtils.findOwner(bdsettings, {name:type, depth:99999999, time:99999999});
if (bdsettingsins) {
instancefound = true;
patchInstance(bdsettingsins, type);
@ -1347,7 +1333,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
function isCorrectInstance(instance, type) {
if (!instance) return false;
instance = instance._reactInternalFiber && instance._reactInternalFiber.type ? instance._reactInternalFiber.type : instance;
instance = instance.displayName == type ? instance : BDFDB.ReactUtils.getOwner(instance, {name:type, up:true});
instance = instance.displayName == type ? instance : BDFDB.ReactUtils.findOwner(instance, {name:type, up:true});
return instance && (type != "V2C_PluginCard" && type != "V2C_ThemeCard" || type == "V2C_PluginCard" && BDFDB.checkWhichRepoPage() == "plugins" || type == "V2C_ThemeCard" && BDFDB.checkWhichRepoPage() == "themes");
}
}
@ -1457,7 +1443,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
if (e.thisObject.props.message && !e.thisObject.props.target) {
const messageswrap = document.querySelector(BDFDB.dotCN.messages);
if (messageswrap) {
var messages = BDFDB.ReactUtils.getOwner(messageswrap, {name:"Message", all:true, noCopies:true, depth:99999999, time:99999999});
var messages = BDFDB.ReactUtils.findOwner(messageswrap, {name:"Message", all:true, noCopies:true, depth:99999999, time:99999999});
for (let i in messages) if (e.thisObject.props.message.id == messages[i].props.message.id) {
target = BDFDB.ReactUtils.findDOMNode(messages[i]);
if (target) e.thisObject.props.target = target
@ -1568,7 +1554,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
};
BDFDB.readServerList = function () {
var found = [], ins = BDFDB.ReactUtils.getOwner(document.querySelector(BDFDB.dotCN.guilds), {name:["Guild","GuildIcon"], all:true, noCopies:true, depth:99999999, time:99999999});
var found = [], ins = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:["Guild","GuildIcon"], all:true, noCopies:true, depth:99999999, time:99999999});
for (let info in ins) if (ins[info].props && ins[info].props.guild) found.push(Object.assign(new ins[info].props.guild.constructor(ins[info].props.guild), {div:ins[info].handleContextMenu ? BDFDB.ReactUtils.findDOMNode(ins[info]) : BDFDB.createServerDivCopy(ins[info].props.guild), instance:ins[info]}));
return found;
};
@ -1584,6 +1570,17 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
return found;
};
BDFDB.readPingedServerList = function (servers) {
var found = [];
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.readServerList() : servers) {
if (!eleOrInfoOrId) return null;
let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.getServerID(eleOrInfoOrId) : typeof eleOrInfoOrId == "object" ? eleOrInfoOrId.id : eleOrInfoOrId;
id = typeof id == "number" ? id.toFixed() : id;
if (id && LibraryModules.MentionUtils.getMentionCount(id) > 0) found.push(eleOrInfoOrId);
}
return found;
};
BDFDB.readMutedServerList = function (servers) {
var found = [];
for (let eleOrInfoOrId of servers === undefined || !BDFDB.ArrayUtils.is(servers) ? BDFDB.readServerList() : servers) {
@ -1734,7 +1731,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
};
BDFDB.readFolderList = function () {
var found = [], ins = BDFDB.ReactUtils.getOwner(document.querySelector(BDFDB.dotCN.guildswrapper), {name:"GuildFolder", all:true, noCopies:true, depth:99999999, time:99999999});
var found = [], ins = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guildswrapper), {name:"GuildFolder", all:true, noCopies:true, depth:99999999, time:99999999});
for (let info in ins) if (ins[info].props && ins[info].props.folderId) {
found.push(Object.assign({}, ins[info].props, {div:BDFDB.ReactUtils.findDOMNode(ins[info]), instance:ins[info]}));
}
@ -1763,7 +1760,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
};
BDFDB.readChannelList = function () {
var found = [], ins = BDFDB.ReactUtils.getOwner(document.querySelector(BDFDB.dotCN.channels), {name: ["ChannelCategoryItem", "ChannelItem", "PrivateChannel"], all:true, noCopies:true, depth:99999999, time:99999999});
var found = [], ins = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.channels), {name: ["ChannelCategoryItem", "ChannelItem", "PrivateChannel"], all:true, noCopies:true, depth:99999999, time:99999999});
for (let info in ins) if (ins[info].props && !ins[info].props.ispin && ins[info].props.channel && ins[info]._reactInternalFiber.return) {
var div = BDFDB.ReactUtils.findDOMNode(ins[info]);
div = div && BDFDB.containsClass(div.parentElement, BDFDB.disCN.categorycontainerdefault, BDFDB.disCN.channelcontainerdefault, false) ? div.parentElement : div;
@ -1821,7 +1818,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
};
BDFDB.readDmList = function () {
var found = [], ins = BDFDB.ReactUtils.getOwner(document.querySelector(BDFDB.dotCN.guilds), {name:"DirectMessage", all:true, noCopies:true, depth:99999999, time:99999999});
var found = [], ins = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.guilds), {name:"DirectMessage", all:true, noCopies:true, depth:99999999, time:99999999});
for (let info in ins) if (ins[info].props && ins[info].props.channel && ins[info]._reactInternalFiber.child) found.push(Object.assign(new ins[info].props.channel.constructor(ins[info].props.channel), {div:BDFDB.ReactUtils.findDOMNode(ins[info]), instance:ins[info]}));
return found;
};
@ -2873,7 +2870,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
BDFDB.appendModal = function (modalwrapper) {
if (!Node.prototype.isPrototypeOf(modalwrapper)) return;
if (!BDFDB.appendModal.modals || !document.contains(BDFDB.appendModal.modals)) BDFDB.appendModal.modals = BDFDB.ReactUtils.findDOMNode(BDFDB.ReactUtils.getOwner(document.querySelector(BDFDB.dotCN.app), {name:"Modals", depth:99999999, time:99999999}));
if (!BDFDB.appendModal.modals || !document.contains(BDFDB.appendModal.modals)) BDFDB.appendModal.modals = BDFDB.ReactUtils.findDOMNode(BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Modals", depth:99999999, time:99999999}));
if (!BDFDB.appendModal.modals) return;
var modal = BDFDB.containsClass(modalwrapper, BDFDB.disCN.modal) ? modalwrapper : modalwrapper.querySelector(BDFDB.dotCN.modal);
@ -3224,7 +3221,7 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
BDFDB.closeContextMenu = function (nodeOrInstance) {
if (!BDFDB.ObjectUtils.is(nodeOrInstance)) return;
var instance = BDFDB.ReactUtils.getOwner(nodeOrInstance, {name:"ContextMenu", up:true});
var instance = BDFDB.ReactUtils.findOwner(nodeOrInstance, {name:"ContextMenu", up:true});
if (BDFDB.ObjectUtils.is(instance) && instance.props && typeof instance.props.closeContextMenu == "function") instance.props.closeContextMenu();
};
@ -5616,15 +5613,21 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
return this.props.children ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
children: [
BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom8
}),
typeof this.props.title == "string" ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
className: BDFDB.disCN.marginbottom8,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H1,
className: BDFDB.disCN.marginbottom4,
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H3,
children: this.props.title
}) : null,
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: "BDFDB-settings-inner-list",
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
children: this.props.children
}),
BDFDB.ReactUtils.createElement(LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom20
})
]
}) : null;
@ -7247,9 +7250,11 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
BDFDB.deepAssign = BDFDB.ObjectUtils.deepAssign;
BDFDB.isObjectEmpty = BDFDB.ObjectUtils.isEmpty;
BDFDB.React = Object.assign({}, BDFDB.ReactUtils);
BDFDB.getKeyInformation = (config) => {return BDFDB.ReactUtils.findValue(config.node || config.instance, config.key, config);};
BDFDB.getReactInstance = BDFDB.ReactUtils.getInstance;
BDFDB.getOwnerInstance = (config) => {return BDFDB.ReactUtils.getOwner(config.node || config.instance, config);};
BDFDB.getOwnerInstance = (config) => {return BDFDB.ReactUtils.findOwner(config.node || config.instance, config);};
BDFDB.ReactUtils.getOwner = BDFDB.ReactUtils.findOwner;
BDFDB.getReactValue = BDFDB.ReactUtils.getValue;
BDFDB.WebModules = Object.assign({}, BDFDB.ModuleUtils);
@ -7280,8 +7285,6 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins || {}, BDv2Api: BDFDB && BDFDB.
BDFDB.getTheme = BDFDB.BdUtils.getTheme;
BDFDB.isRestartNoMoreEnabled = BDFDB.BdUtils.isAutoLoadEnabled;
BDFDB.React = Object.assign({}, BDFDB.ReactUtils);
BDFDB.languages = BDFDB.LanguageUtils.languages;
BDFDB.getDiscordLanguage = BDFDB.LanguageUtils.getLanguage;
BDFDB.LanguageStrings = BDFDB.LanguageUtils.LanguageStrings;

File diff suppressed because one or more lines are too long

View File

@ -53,7 +53,7 @@ class EditServers {
children: inneritems
}));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "BUTTON",
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Reset all Servers",

View File

@ -74,27 +74,27 @@ class EditUsers {
this.defaults = {
settings: {
changeInChatTextarea: {value:true, description:"Chat Textarea"},
changeInChatWindow: {value:true, description:"Messages"},
changeInMentions: {value:true, description:"Mentions"},
changeInVoiceChat: {value:true, description:"Voice Channels"},
changeInMemberList: {value:true, description:"Member List"},
changeInRecentDms: {value:true, description:"Direct Message Notifications"},
changeInDmsList: {value:true, description:"Direct Message List"},
changeInDmHeader: {value:true, description:"Direct Message Header"},
changeInDmCalls: {value:true, description:"Calls/ScreenShares"},
changeInTyping: {value:true, description:"Typing List"},
changeInFriendList: {value:true, description:"Friend List"},
changeInInviteList: {value:true, description:"Invite List"},
changeInActivity: {value:true, description:"Activity Page"},
changeInUserPopout: {value:true, description:"User Popouts"},
changeInUserProfil: {value:true, description:"User Profile Modal"},
changeInAutoComplete: {value:true, description:"Autocomplete Menu"},
changeInAuditLog: {value:true, description:"Audit Log"},
changeInMemberLog: {value:true, description:"Member Log"},
changeInSearchPopout: {value:true, description:"Search Popout"},
changeInUserAccount: {value:true, description:"Your Account Information"},
changeInAppTitle: {value:true, description:"Discord App Title (DMs)"}
changeInChatTextarea: {value:true, inner:true, description:"Chat Textarea"},
changeInChatWindow: {value:true, inner:true, description:"Messages"},
changeInMentions: {value:true, inner:true, description:"Mentions"},
changeInVoiceChat: {value:true, inner:true, description:"Voice Channels"},
changeInMemberList: {value:true, inner:true, description:"Member List"},
changeInRecentDms: {value:true, inner:true, description:"Direct Message Notifications"},
changeInDmsList: {value:true, inner:true, description:"Direct Message List"},
changeInDmHeader: {value:true, inner:true, description:"Direct Message Header"},
changeInDmCalls: {value:true, inner:true, description:"Calls/ScreenShares"},
changeInTyping: {value:true, inner:true, description:"Typing List"},
changeInFriendList: {value:true, inner:true, description:"Friend List"},
changeInInviteList: {value:true, inner:true, description:"Invite List"},
changeInActivity: {value:true, inner:true, description:"Activity Page"},
changeInUserPopout: {value:true, inner:true, description:"User Popouts"},
changeInUserProfil: {value:true, inner:true, description:"User Profile Modal"},
changeInAutoComplete: {value:true, inner:true, description:"Autocomplete Menu"},
changeInAuditLog: {value:true, inner:true, description:"Audit Log"},
changeInMemberLog: {value:true, inner:true, description:"Member Log"},
changeInSearchPopout: {value:true, inner:true, description:"Search Popout"},
changeInUserAccount: {value:true, inner:true, description:"Your Account Information"},
changeInAppTitle: {value:true, inner:true, description:"Discord App Title (DMs)"}
}
};
}
@ -116,7 +116,7 @@ class EditUsers {
children: inneritems
}));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "BUTTON",
type: "Button",
className: BDFDB.disCN.marginbottom8,
color: BDFDB.LibraryComponents.Button.Colors.RED,
label: "Reset all Users",
@ -290,7 +290,7 @@ class EditUsers {
if (avatarinputins) {
avatarinputins.props.inputClassName = null;
avatarinputins.props.disabled = value;
avatarinputins.forceUpdate();
BDFDB.ReactUtils.forceUpdate(avatarinputins);
}
}
})

View File

@ -3,7 +3,7 @@
class ReadAllNotificationsButton {
getName () {return "ReadAllNotificationsButton";}
getVersion () {return "1.5.0";}
getVersion () {return "1.5.1";}
getAuthor () {return "DevilBro";}
@ -11,7 +11,7 @@ class ReadAllNotificationsButton {
constructor () {
this.changelog = {
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
"added":[["Pinged servers","Added the contextmenu item to only clear unread notifications on pinged servers"]]
};
this.patchModules = {
@ -59,28 +59,30 @@ class ReadAllNotificationsButton {
getSettingsPanel () {
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
var settings = BDFDB.getAllData(this, "settings");
var settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
for (let key in settings) {
if (!this.defaults.settings[key].inner) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">When left clicking the button mark following elements as unread:</h3></div><div class="BDFDB-settings-inner-list">`;
for (let key in settings) {
if (this.defaults.settings[key].inner) settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
}
settingshtml += `</div>`;
settingshtml += `</div></div>`;
let settingspanel = BDFDB.htmlToElement(settingshtml);
BDFDB.initElements(settingspanel, this);
let mutedinput = settingspanel.querySelector(".settings-switch[value='settings includeMuted']").parentElement.parentElement;
BDFDB.toggleEles(mutedinput, settings.includeGuilds);
BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch[value='settings includeGuilds']", e => {
BDFDB.toggleEles(mutedinput, e.currentTarget.checked);
});
return settingspanel;
var settingsitems = [], inneritems = [];
for (let key in settings) (!this.defaults.settings[key].inner ? settingsitems : inneritems).push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsSwitch, {
className: BDFDB.disCN.marginbottom8,
plugin: this,
keys: ["settings", key],
label: this.defaults.settings[key].description,
value: settings[key],
disabled: key == "includeMuted" && !settings.includeGuilds,
onChange: (value, instance) => {
if (key != "includeGuilds") return;
let mutedSwitchIns = BDFDB.ReactUtils.findOwner(instance, {props:[["keys",["settings", "includeMuted"]]]});
if (mutedSwitchIns) {
mutedSwitchIns.props.disabled = !value;
BDFDB.ReactUtils.forceUpdate(mutedSwitchIns);
}
}
}));
settingsitems.push(BDFDB.React.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
title: "When left clicking the 'read all' button mark following Elements as read:",
children: inneritems
}));
return BDFDB.createSettingsPanel(this, settingsitems);
}
//legacy
@ -151,6 +153,14 @@ class ReadAllNotificationsButton {
BDFDB.markGuildAsRead(BDFDB.readUnreadServerList());
}
}),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_pingedguilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pingedguilds-contextMenuItem`,
action: e => {
BDFDB.closeContextMenu(BDFDB.getParentEle(BDFDB.dotCN.contextmenu, e.target));
BDFDB.markGuildAsRead(BDFDB.readPingedServerList());
}
}),
BDFDB.React.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
label: this.labels.context_mutedguilds_text,
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-mutedguilds-contextMenuItem`,
@ -228,7 +238,8 @@ class ReadAllNotificationsButton {
switch (BDFDB.getDiscordLanguage().id) {
case "hr": //croatian
return {
context_unreadguilds_text: "Nepročitani poslužitelji",
context_unreadguilds_text: "Nepročitani poslužitelje",
context_pingedguilds_text: "Zvižduci poslužitelje",
context_mutedguilds_text: "Prigušeni poslužitelje",
context_guilds_text: "Sve poslužitelje",
context_dms_text: "Prikvacene izravne"
@ -236,6 +247,7 @@ class ReadAllNotificationsButton {
case "da": //danish
return {
context_unreadguilds_text: "Ulæste servere",
context_pingedguilds_text: "Pinget servere",
context_mutedguilds_text: "Dæmpede servere",
context_guilds_text: "Alle servere",
context_dms_text: "Private beskeder"
@ -243,6 +255,7 @@ class ReadAllNotificationsButton {
case "de": //german
return {
context_unreadguilds_text: "Ungelesene Server",
context_pingedguilds_text: "Gepingte Server",
context_mutedguilds_text: "Stummgeschaltene Server",
context_guilds_text: "Alle Server",
context_dms_text: "Direktnachrichten"
@ -250,6 +263,7 @@ class ReadAllNotificationsButton {
case "es": //spanish
return {
context_unreadguilds_text: "Servidores no leídos",
context_pingedguilds_text: "Servidores mencionados",
context_mutedguilds_text: "Servidores silenciados",
context_guilds_text: "Todos los servidores",
context_dms_text: "Mensajes directos"
@ -257,6 +271,7 @@ class ReadAllNotificationsButton {
case "fr": //french
return {
context_unreadguilds_text: "Serveurs non lus",
context_pingedguilds_text: "Serveurs mentionnés",
context_mutedguilds_text: "Serveurs en sourdine",
context_guilds_text: "Tous les serveurs",
context_dms_text: "Messages privés"
@ -264,6 +279,7 @@ class ReadAllNotificationsButton {
case "it": //italian
return {
context_unreadguilds_text: "Server non letti",
context_pingedguilds_text: "Server pingato",
context_mutedguilds_text: "Server mutate",
context_guilds_text: "Tutti i server",
context_dms_text: "Messaggi diretti"
@ -271,6 +287,7 @@ class ReadAllNotificationsButton {
case "nl": //dutch
return {
context_unreadguilds_text: "Ongelezen servers",
context_pingedguilds_text: "Gepingde servers",
context_mutedguilds_text: "Gedempte servers",
context_guilds_text: "Alle servers",
context_dms_text: "Prive berichten"
@ -278,6 +295,7 @@ class ReadAllNotificationsButton {
case "no": //norwegian
return {
context_unreadguilds_text: "Uleste servere",
context_pingedguilds_text: "Pinget servere",
context_mutedguilds_text: "Dempet servere",
context_guilds_text: "Alle servere",
context_dms_text: "Direktemeldinger"
@ -285,6 +303,7 @@ class ReadAllNotificationsButton {
case "pl": //polish
return {
context_unreadguilds_text: "Nieprzeczytane serwery",
context_pingedguilds_text: "Pingowany serwery",
context_mutedguilds_text: "Wyciszone serwery",
context_guilds_text: "Wszystkie serwery",
context_dms_text: "Prywatne wiadomości"
@ -292,6 +311,7 @@ class ReadAllNotificationsButton {
case "pt-BR": //portuguese (brazil)
return {
context_unreadguilds_text: "Servidores não lidos",
context_pingedguilds_text: "Servidores com ping",
context_mutedguilds_text: "Servidores silenciosos",
context_guilds_text: "Todos os servidores",
context_dms_text: "Mensagens diretas"
@ -299,6 +319,7 @@ class ReadAllNotificationsButton {
case "fi": //finnish
return {
context_unreadguilds_text: "Lukemattomia palvelimet",
context_pingedguilds_text: "Tapitut palvelimet",
context_mutedguilds_text: "Mykistetyt palvelimet",
context_guilds_text: "Kaikki palvelimet",
context_dms_text: "Yksityisviestit"
@ -306,6 +327,7 @@ class ReadAllNotificationsButton {
case "sv": //swedish
return {
context_unreadguilds_text: "Olästa servrar",
context_pingedguilds_text: "Pingade servrar",
context_mutedguilds_text: "Dämpade servrar",
context_guilds_text: "Alla servrar",
context_dms_text: "Direktmeddelanden"
@ -313,6 +335,7 @@ class ReadAllNotificationsButton {
case "tr": //turkish
return {
context_unreadguilds_text: "Okunmamış sunucular",
context_pingedguilds_text: "Ping sunucular",
context_mutedguilds_text: "Sessiz sunucular",
context_guilds_text: "Tüm sunucular",
context_dms_text: "Özel mesajlar"
@ -320,6 +343,7 @@ class ReadAllNotificationsButton {
case "cs": //czech
return {
context_unreadguilds_text: "Nepřečtené servery",
context_pingedguilds_text: "Pinged servery",
context_mutedguilds_text: "Tlumené servery",
context_guilds_text: "Všechny servery",
context_dms_text: "Přímé zpráva"
@ -327,6 +351,7 @@ class ReadAllNotificationsButton {
case "bg": //bulgarian
return {
context_unreadguilds_text: "Непрочетени сървъри",
context_pingedguilds_text: "Споменатите сървъри",
context_mutedguilds_text: "Приглушени сървъри",
context_guilds_text: "Всички сървъри",
context_dms_text: "Директно съобщение"
@ -334,13 +359,15 @@ class ReadAllNotificationsButton {
case "ru": //russian
return {
context_unreadguilds_text: "Непрочитанные серверы",
context_pingedguilds_text: "Проверенные серверы",
context_mutedguilds_text: "Отключенные серверы",
context_guilds_text: "Все серверы",
context_dms_text: "Прямые сообщения"
};
case "uk": //ukrainian
return {
context_unreadguilds_text: "Непрочитаних серверів",
context_unreadguilds_text: "Непрочитаних сервери",
context_pingedguilds_text: "Згадані сервери",
context_mutedguilds_text: "Приглушені сервери",
context_guilds_text: "Всі сервери",
context_dms_text: "Прямі Повідомлення"
@ -348,6 +375,7 @@ class ReadAllNotificationsButton {
case "ja": //japanese
return {
context_unreadguilds_text: "未読サーバー",
context_pingedguilds_text: "",
context_mutedguilds_text: "ミュートサーバー",
context_guilds_text: "すべてのサーバー",
context_dms_text: "ダイレクトメッセージ"
@ -355,6 +383,7 @@ class ReadAllNotificationsButton {
case "zh-TW": //chinese (traditional)
return {
context_unreadguilds_text: "未讀服務器",
context_pingedguilds_text: "言及されたサーバー",
context_mutedguilds_text: "靜音服務器",
context_guilds_text: "所有服務器",
context_dms_text: "直接消息",
@ -362,6 +391,7 @@ class ReadAllNotificationsButton {
case "ko": //korean
return {
context_unreadguilds_text: "읽지 않은 서버",
context_pingedguilds_text: "언급 된 서버",
context_mutedguilds_text: "음소거 된 서버",
context_guilds_text: "모든 서버",
context_dms_text: "직접 메시지"
@ -369,6 +399,7 @@ class ReadAllNotificationsButton {
default: //default: english
return {
context_unreadguilds_text: "Unread Servers",
context_pingedguilds_text: "Pinged Servers",
context_mutedguilds_text: "Muted Servers",
context_guilds_text: "All Servers",
context_dms_text: "Direct Messages"