This commit is contained in:
Mirco Wittrien 2021-02-09 13:05:30 +01:00
parent 85afa30efa
commit a65cf63523
3 changed files with 31 additions and 27 deletions

View File

@ -211,7 +211,7 @@ module.exports = (_ => {
if (i > 1000) result = null;
else {
if (typeof a !== typeof b) result = false;
else if (typeof a === "function") result = a.toString() == b.toString();
else if (typeof a == "function") result = a.toString() == b.toString();
else if (typeof a === "undefined") result = true;
else if (typeof a === "symbol") result = true;
else if (typeof a === "boolean") result = a == b;
@ -573,7 +573,7 @@ module.exports = (_ => {
};
BDFDB.PluginUtils.translate = function (plugin) {
plugin.labels = {};
if (typeof plugin.setLabelsByLanguage === "function" || typeof plugin.changeLanguageStrings === "function") {
if (typeof plugin.setLabelsByLanguage == "function" || typeof plugin.changeLanguageStrings == "function") {
if (LibraryModules.LanguageStore.chosenLocale) translate();
else BDFDB.TimeUtils.interval(interval => {
if (LibraryModules.LanguageStore.chosenLocale) {
@ -583,9 +583,8 @@ module.exports = (_ => {
}, 100);
function translate() {
let language = BDFDB.LanguageUtils.getLanguage();
if (typeof plugin.setLabelsByLanguage === "function") plugin.labels = plugin.setLabelsByLanguage(language.id);
if (typeof plugin.changeLanguageStrings === "function") plugin.changeLanguageStrings();
BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_translated", language.ownlang), plugin.name);
if (typeof plugin.setLabelsByLanguage == "function") plugin.labels = plugin.setLabelsByLanguage(language.id);
if (typeof plugin.changeLanguageStrings == "function") plugin.changeLanguageStrings();
}
}
};
@ -920,7 +919,7 @@ module.exports = (_ => {
InternalBDFDB.addSpecialListeners = function (plugin) {
plugin = plugin == BDFDB && InternalBDFDB || plugin;
if (BDFDB.ObjectUtils.is(plugin)) {
if (typeof plugin.onSwitch === "function") {
if (typeof plugin.onSwitch == "function") {
let spacer = document.querySelector(`${BDFDB.dotCN.guildswrapper} ~ * > ${BDFDB.dotCN.chatspacer}`);
if (spacer) {
let noChannelObserver = new MutationObserver(changes => {changes.forEach(change => {
@ -2403,7 +2402,7 @@ module.exports = (_ => {
let keys = Object.getOwnPropertyNames(instance);
for (let i = 0; result === undefined && i < keys.length; i++) {
let key = keys[i];
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] === "function")) result = getConstructor(instance[key]);
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] == "function")) result = getConstructor(instance[key]);
}
}
}
@ -2483,7 +2482,7 @@ module.exports = (_ => {
let keys = Object.getOwnPropertyNames(instance);
for (let i = 0; result === undefined && i < keys.length; i++) {
let key = keys[i];
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] === "function")) result = getOwner(instance[key]);
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] == "function")) result = getOwner(instance[key]);
}
}
}
@ -2586,7 +2585,7 @@ module.exports = (_ => {
let keys = Object.getOwnPropertyNames(instance);
for (let i = 0; result === undefined && i < keys.length; i++) {
let key = keys[i];
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] === "function")) result = findProps(instance[key]);
if (key && whitelist[key] && (typeof instance[key] === "object" || typeof instance[key] == "function")) result = findProps(instance[key]);
}
}
}
@ -2650,7 +2649,7 @@ module.exports = (_ => {
}
}
}
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);
}
}
}
@ -7255,15 +7254,14 @@ module.exports = (_ => {
else for (let control of controls) checkbox.parentElement.insertBefore(control, checkbox.parentElement.firstElementChild);
}
};
const cardObserver = (new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) InternalBDFDB.appendCustomControls(node);
if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
});}});}));
BDFDB.ObserverUtils.connect(BDFDB, document.querySelector(`${BDFDB.dotCN.layer}[aria-label="${BDFDB.DiscordConstants.Layers.USER_SETTINGS}"]`), {name: "cardObserver", instance: cardObserver}, {childList: true, subtree: true});
BDFDB.ObserverUtils.connect(BDFDB, BDFDB.dotCN.applayers, {name: "appLayerObserver", instance: (new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
if (node.nodeType != Node.TEXT_NODE && node.getAttribute("aria-label") == BDFDB.DiscordConstants.Layers.USER_SETTINGS) BDFDB.ObserverUtils.connect(BDFDB, node, {name: "cardObserver", instance: cardObserver}, {childList: true, subtree: true});
});}});}))}, {childList: true});
for (let child of document.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
InternalBDFDB.addListObserver = function (layer) {
if (!layer) return;
BDFDB.ObserverUtils.connect(BDFDB, layer, {name: "cardObserver", instance: new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) InternalBDFDB.appendCustomControls(node);
if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
});}});})}, {childList: true, subtree: true});
for (let child of layer.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
}
const keyDownTimeouts = {};
BDFDB.ListenerUtils.add(BDFDB, document, "keydown.BDFDBPressedKeys", e => {
@ -7299,10 +7297,16 @@ module.exports = (_ => {
PrivateChannel: ["componentDidMount", "componentDidUpdate"],
UserPopout: ["componentDidMount", "componentDidUpdate"],
UserProfile: ["componentDidMount", "componentDidUpdate"],
SettingsView: "componentDidMount",
Shakeable: "render"
}
};
InternalBDFDB.processSettingsView = function (e) {
if (e.node && e.node.parentElement && e.node.parentElement.getAttribute("aria-label") == BDFDB.DiscordConstants.Layers.USER_SETTINGS) InternalBDFDB.addListObserver(e.node.parentElement);
}
let AppViewExport = BDFDB.ModuleUtils.findByName("AppView", false);
if (AppViewExport) InternalBDFDB.processShakeable = function (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "AppView"});
@ -7442,7 +7446,7 @@ module.exports = (_ => {
const QueuedComponents = BDFDB.ArrayUtils.removeCopies([].concat(ContextMenuTypes.map(n => n + "ContextMenu"), ["GuildHeaderContextMenu", "MessageOptionContextMenu", "MessageOptionToolbar"]));
InternalBDFDB.addContextListeners = function (plugin) {
plugin = plugin == BDFDB && InternalBDFDB || plugin;
for (let type of QueuedComponents) if (typeof plugin[`on${type}`] === "function") {
for (let type of QueuedComponents) if (typeof plugin[`on${type}`] == "function") {
PluginStores.patchQueues[type].query.push(plugin);
PluginStores.patchQueues[type].query = BDFDB.ArrayUtils.removeCopies(PluginStores.patchQueues[type].query);
PluginStores.patchQueues[type].query.sort((x, y) => x.name < y.name ? -1 : x.name > y.name ? 1 : 0);
@ -7452,12 +7456,12 @@ module.exports = (_ => {
InternalBDFDB.patchContextMenuForPlugin = function (plugin, type, module) {
plugin = plugin == BDFDB && InternalBDFDB || plugin;
if (module && module.exports && module.exports.default) BDFDB.PatchUtils.patch(plugin, module.exports, "default", {after: e => {
if (e.returnValue && typeof plugin[`on${type}`] === "function") plugin[`on${type}`]({instance: {props: e.methodArguments[0]}, returnvalue: e.returnValue, methodname: "default", type: module.exports.default.displayName});
if (e.returnValue && typeof plugin[`on${type}`] == "function") plugin[`on${type}`]({instance: {props: e.methodArguments[0]}, returnvalue: e.returnValue, methodname: "default", type: module.exports.default.displayName});
}});
};
InternalBDFDB.executeExtraPatchedPatches = function (type, e) {
if (e.returnvalue && BDFDB.ObjectUtils.is(PluginStores.patchQueues[type]) && BDFDB.ArrayUtils.is(PluginStores.patchQueues[type].query)) {
for (let plugin of PluginStores.patchQueues[type].query) if(typeof plugin[`on${type}`] === "function") plugin[`on${type}`](e);
for (let plugin of PluginStores.patchQueues[type].query) if(typeof plugin[`on${type}`] == "function") plugin[`on${type}`](e);
}
};

View File

@ -553,7 +553,7 @@ module.exports = (_ => {
})
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
BDFDB.LibraryRequires.electron && BDFDB.LibraryRequires.electron.remote && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Switch, {
value: list && list.props.currentTheme && list.props.currentTheme.url == this.props.theme.url,
onChange: (value, instance) => {
if (!list) return;
@ -1067,7 +1067,7 @@ module.exports = (_ => {
BDFDB.NotificationUtils.notice(this.labels.notice_outdated_themes.replace("{{var0}}", outdated), {
type: "danger",
className: BDFDB.disCNS._themereponotice + BDFDB.disCN._themerepooutdatednotice,
customIcon: themeRepoIcon.replace(/COLOR_1/gi, "#fff").replace(/COLOR_2/gi, "#b9bbbe"),
customIcon: themeRepoIcon.replace(/COLOR_[0-9]+/gi, "currentColor"),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
close: true,
@ -1085,7 +1085,7 @@ module.exports = (_ => {
BDFDB.NotificationUtils.notice(this.labels.notice_new_themes.replace("{{var0}}", newEntries), {
type: "success",
className: BDFDB.disCNS._themereponotice + BDFDB.disCN._themereponewentriesnotice,
customIcon: themeRepoIcon.replace(/COLOR_1/gi, "#fff").replace(/COLOR_2/gi, "#b9bbbe"),
customIcon: themeRepoIcon.replace(/COLOR_[0-9]+/gi, "currentColor"),
buttons: [{
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
close: true,
@ -1107,7 +1107,7 @@ module.exports = (_ => {
BDFDB.NotificationUtils.notice(this.labels.notice_failed_themes.replace("{{var0}}", wrongUrls.length), {
type: "danger",
className: BDFDB.disCNS._themereponotice + BDFDB.disCN._themerepofailnotice,
customIcon: themeRepoIcon.replace(/COLOR_1/gi, "#fff").replace(/COLOR_2/gi, "#b9bbbe"),
customIcon: themeRepoIcon.replace(/COLOR_[0-9]+/gi, "currentColor"),
buttons: [{
contents: this.labels.list,
onClick: _ => {

View File

@ -89,7 +89,7 @@ https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Themes/Fu
https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Themes/ServerColumns/ServerColumns.theme.css
https://raw.githubusercontent.com/Mylan719/Discord-light-theme/master/Discord Light-Blue.theme.css
https://raw.githubusercontent.com/nirewen/Discordify/master/Discordify.theme.css
https://raw.githubusercontent.com/NYRI4/Comfy-theme/main/BetterDiscord/comfy.theme.css
https://raw.githubusercontent.com/NYRI4/Comfy/master/comfy.theme.css
https://raw.githubusercontent.com/ObserverOfTime/DiscordThemes/master/NewNihilism/dist/NewNihilism.theme.css
https://raw.githubusercontent.com/orblazer/discord-nordic/master/nordic.theme.css
https://raw.githubusercontent.com/Pierce01/Opacity/master/OpacityMaxBun.theme.css