This commit is contained in:
Mirco Wittrien 2021-05-12 19:44:23 +02:00
parent b2db723edb
commit bb7b1f9a6f
2 changed files with 61 additions and 51 deletions

View File

@ -2,7 +2,7 @@
* @name PluginRepo * @name PluginRepo
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.2.2 * @version 2.2.3
* @description Allows you to download all Plugins from BD's Website within Discord * @description Allows you to download all Plugins from BD's Website within Discord
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,15 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "PluginRepo", "name": "PluginRepo",
"author": "DevilBro", "author": "DevilBro",
"version": "2.2.2", "version": "2.2.3",
"description": "Allows you to download all Plugins from BD's Website within Discord" "description": "Allows you to download all Plugins from BD's Website within Discord"
}, },
"changeLog": { "changeLog": {
"improved": { "progress": {
"Thumbnail Conversion": "Moved Thumbnail Conversion to Card Component to reduce stress on BD Website" "Changed Api": "Preparing Plugin for API Changes"
},
"fixed": {
"Settings": "No longer get reset"
} }
} }
}; };
@ -103,18 +100,18 @@ module.exports = (_ => {
} }
}; };
const reverseSorts = [ const reverseSorts = [
"DOWNLOADS", "LIKES", "FAV", "NEW" "RELEASEDATE", "DOWNLOADS", "LIKES", "FAV"
]; ];
const sortKeys = { const sortKeys = {
NAME: "Name", NAME: "Name",
AUTHOR: "Author", AUTHORNAME: "Author",
VERSION: "Version", VERSION: "Version",
DESCRIPTION: "Description", DESCRIPTION: "Description",
RELEASEDATE: "Release Date",
STATE: "Update State", STATE: "Update State",
DOWNLOADS: "Downloads", DOWNLOADS: "Downloads",
LIKES: "Likes", LIKES: "Likes",
FAV: "Favorites", FAV: "Favorites"
NEW: "New Plugins"
}; };
const orderKeys = { const orderKeys = {
ASC: "ascending", ASC: "ascending",
@ -140,7 +137,7 @@ module.exports = (_ => {
const installedPlugin = _this.getInstalledPlugin(plugin); const installedPlugin = _this.getInstalledPlugin(plugin);
const state = installedPlugin ? (plugin.version && BDFDB.NumberUtils.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE; const state = installedPlugin ? (plugin.version && BDFDB.NumberUtils.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE;
return Object.assign(plugin, { return Object.assign(plugin, {
search: [plugin.name, plugin.version, plugin.author, plugin.description, plugin.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(), search: [plugin.name, plugin.version, plugin.authorname, plugin.description, plugin.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(),
description: plugin.description || "No Description found", description: plugin.description || "No Description found",
fav: favorites.includes(plugin.id) && 1, fav: favorites.includes(plugin.id) && 1,
new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1, new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1,
@ -155,10 +152,9 @@ module.exports = (_ => {
plugins = plugins.filter(plugin => plugin.search.indexOf(usedSearchString) > -1); plugins = plugins.filter(plugin => plugin.search.indexOf(usedSearchString) > -1);
} }
const sortKey = !this.props.sortKey || this.props.sortKey == "NEW" && !plugins.some(plugin => plugin.new) ? Object.keys(sortKeys)[0] : this.props.sortKey; BDFDB.ArrayUtils.keySort(plugins, this.props.sortKey.toLowerCase());
BDFDB.ArrayUtils.keySort(plugins, sortKey.toLowerCase());
if (this.props.orderKey == "DESC") plugins.reverse(); if (this.props.orderKey == "DESC") plugins.reverse();
if (reverseSorts.includes(sortKey)) plugins.reverse(); if (reverseSorts.includes(this.props.sortKey)) plugins.reverse();
return plugins; return plugins;
} }
render() { render() {
@ -326,7 +322,10 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardiconwrapper, className: BDFDB.disCN.discoverycardiconwrapper,
children: BDFDB.ReactUtils.createElement("div", { children: this.props.data.author && this.props.data.author.discord_avatar_hash && this.props.data.author.discord_snowflake ? BDFDB.ReactUtils.createElement("img", {
className: BDFDB.disCN.discoverycardicon,
src: `https://cdn.discordapp.com/avatars/${this.props.data.author.discord_snowflake}/${this.props.data.author.discord_avatar_hash}.webp?size=128`
}) : BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardicon, className: BDFDB.disCN.discoverycardicon,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
nativeClass: true, nativeClass: true,
@ -360,7 +359,7 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardauthor, className: BDFDB.disCN.discoverycardauthor,
children: `by ${this.props.data.author}` children: `by ${this.props.data.authorname}`
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, {
className: BDFDB.disCN.discoverycarddescription, className: BDFDB.disCN.discoverycarddescription,
@ -559,7 +558,7 @@ module.exports = (_ => {
label: sortKeys[this.props.sortKey], label: sortKeys[this.props.sortKey],
value: this.props.sortKey value: this.props.sortKey
}, },
options: Object.keys(sortKeys).filter(n => n != "NEW" || grabbedPlugins.some(p => !cachedPlugins.includes(p.id))).map(key => ({ options: Object.keys(sortKeys).map(key => ({
label: sortKeys[key], label: sortKeys[key],
value: key value: key
})), })),
@ -726,7 +725,7 @@ module.exports = (_ => {
const checkPlugin = _ => { const checkPlugin = _ => {
if (checksRunning > 20) return; if (checksRunning > 20) return;
else if (grabbedPlugins.every(p => p.loaded || !p.latestSourceUrl) || !this.started || !loading.is) { else if (grabbedPlugins.every(p => p.loaded || (!p.latestSourceUrl && !p.latest_source_url)) || !this.started || !loading.is) {
if (!callbackCalled) { if (!callbackCalled) {
callbackCalled = true; callbackCalled = true;
if (!this.started) return BDFDB.TimeUtils.clear(loading.timeout); if (!this.started) return BDFDB.TimeUtils.clear(loading.timeout);
@ -766,7 +765,7 @@ module.exports = (_ => {
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN, contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
close: true, close: true,
onClick: _ => { onClick: _ => {
forcedSort = "NEW"; forcedSort = "RELEASEDATE";
forcedOrder = "ASC"; forcedOrder = "ASC";
BDFDB.LibraryModules.UserSettingsUtils.open("pluginrepo"); BDFDB.LibraryModules.UserSettingsUtils.open("pluginrepo");
} }
@ -779,15 +778,21 @@ module.exports = (_ => {
else if (checkIndex > grabbedPlugins.length) return; else if (checkIndex > grabbedPlugins.length) return;
const plugin = grabbedPlugins[checkIndex++]; const plugin = grabbedPlugins[checkIndex++];
if (!plugin || !plugin.latestSourceUrl) checkPlugin(); if (!plugin || (!plugin.latestSourceUrl && !plugin.latest_source_url)) checkPlugin();
else { else {
checksRunning++; checksRunning++;
plugin.releasedate = new Date(plugin.releaseDate || plugin.release_date || 0).getTime();
plugin.latestSourceUrl = plugin.latestSourceUrl || plugin.latest_source_url;
plugin.rawSourceUrl = plugin.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1"); plugin.rawSourceUrl = plugin.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1");
plugin.thumbnailUrl = plugin.thumbnailUrl || plugin.thumbnail_url;
plugin.thumbnailUrl = plugin.thumbnailUrl ? (plugin.thumbnailUrl.startsWith("https://") ? plugin.thumbnailUrl : `https://betterdiscord.app${plugin.thumbnailUrl}`) : ""; plugin.thumbnailUrl = plugin.thumbnailUrl ? (plugin.thumbnailUrl.startsWith("https://") ? plugin.thumbnailUrl : `https://betterdiscord.app${plugin.thumbnailUrl}`) : "";
delete plugin.release_date;
delete plugin.latest_source_url;
delete plugin.thumbnail_url;
BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => { BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => {
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
plugin.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || ""); plugin.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || "");
plugin.author = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.author; plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author;
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1]; const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1];
if (version) { if (version) {
plugin.version = version; plugin.version = version;
@ -856,12 +861,12 @@ module.exports = (_ => {
} }
getInstalledPlugin (plugin) { getInstalledPlugin (plugin) {
if (!plugin || typeof plugin.author != "string") return; if (!plugin || typeof plugin.authorname != "string") return;
const iPlugin = BDFDB.BDUtils.getPlugin(plugin.name, false, true); const iPlugin = BDFDB.BDUtils.getPlugin(plugin.name, false, true);
if (iPlugin && plugin.author.toUpperCase() == this.getString(iPlugin.author).toUpperCase()) return iPlugin; if (iPlugin && plugin.authorname.toUpperCase() == this.getString(iPlugin.author).toUpperCase()) return iPlugin;
else if (plugin.rawSourceUrl && window.BdApi && BdApi.Plugins && typeof BdApi.Plugins.getAll == "function") { else if (plugin.rawSourceUrl && window.BdApi && BdApi.Plugins && typeof BdApi.Plugins.getAll == "function") {
const filename = plugin.rawSourceUrl.split("/").pop(); const filename = plugin.rawSourceUrl.split("/").pop();
for (let p of BdApi.Plugins.getAll()) if (p.filename == filename && plugin.author.toUpperCase() == this.getString(p.author).toUpperCase()) return p; for (let p of BdApi.Plugins.getAll()) if (p.filename == filename && plugin.authorname.toUpperCase() == this.getString(p.author).toUpperCase()) return p;
} }
} }

View File

@ -2,7 +2,7 @@
* @name ThemeRepo * @name ThemeRepo
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.2.2 * @version 2.2.3
* @description Allows you to download all Themes from BD's Website within Discord * @description Allows you to download all Themes from BD's Website within Discord
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,15 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "ThemeRepo", "name": "ThemeRepo",
"author": "DevilBro", "author": "DevilBro",
"version": "2.2.2", "version": "2.2.3",
"description": "Allows you to download all Themes from BD's Website within Discord" "description": "Allows you to download all Themes from BD's Website within Discord"
}, },
"changeLog": { "changeLog": {
"improved": { "progress": {
"Thumbnail Conversion": "Moved Thumbnail Conversion to Card Component to reduce stress on BD Website" "Changed Api": "Preparing Plugin for API Changes"
},
"fixed": {
"Settings": "No longer get reset"
} }
} }
}; };
@ -104,18 +101,18 @@ module.exports = (_ => {
} }
}; };
const reverseSorts = [ const reverseSorts = [
"DOWNLOADS", "LIKES", "FAV", "NEW" "RELEASEDATE", "DOWNLOADS", "LIKES", "FAV"
]; ];
const sortKeys = { const sortKeys = {
NAME: "Name", NAME: "Name",
AUTHOR: "Author", AUTHORNAME: "Author",
VERSION: "Version", VERSION: "Version",
DESCRIPTION: "Description", DESCRIPTION: "Description",
RELEASEDATE: "Release Date",
STATE: "Update State", STATE: "Update State",
DOWNLOADS: "Downloads", DOWNLOADS: "Downloads",
LIKES: "Likes", LIKES: "Likes",
FAV: "Favorites", FAV: "Favorites"
NEW: "New Themes"
}; };
const orderKeys = { const orderKeys = {
ASC: "ascending", ASC: "ascending",
@ -142,7 +139,7 @@ module.exports = (_ => {
const installedTheme = _this.getInstalledTheme(theme); const installedTheme = _this.getInstalledTheme(theme);
const state = installedTheme ? (theme.version && BDFDB.NumberUtils.compareVersions(theme.version, _this.getString(installedTheme.version)) ? themeStates.OUTDATED : themeStates.INSTALLED) : themeStates.DOWNLOADABLE; const state = installedTheme ? (theme.version && BDFDB.NumberUtils.compareVersions(theme.version, _this.getString(installedTheme.version)) ? themeStates.OUTDATED : themeStates.INSTALLED) : themeStates.DOWNLOADABLE;
return Object.assign(theme, { return Object.assign(theme, {
search: [theme.name, theme.version, theme.author, theme.description, theme.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(), search: [theme.name, theme.version, theme.authorname, theme.description, theme.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(),
description: theme.description || "No Description found", description: theme.description || "No Description found",
fav: favorites.includes(theme.id) && 1, fav: favorites.includes(theme.id) && 1,
new: state == themeStates.DOWNLOADABLE && !cachedThemes.includes(theme.id) && 1, new: state == themeStates.DOWNLOADABLE && !cachedThemes.includes(theme.id) && 1,
@ -157,10 +154,9 @@ module.exports = (_ => {
themes = themes.filter(theme => theme.search.indexOf(usedSearchString) > -1); themes = themes.filter(theme => theme.search.indexOf(usedSearchString) > -1);
} }
const sortKey = !this.props.sortKey || this.props.sortKey == "NEW" && !themes.some(theme => theme.new) ? Object.keys(sortKeys)[0] : this.props.sortKey; BDFDB.ArrayUtils.keySort(themes, this.props.sortKey.toLowerCase());
BDFDB.ArrayUtils.keySort(themes, sortKey.toLowerCase());
if (this.props.orderKey == "DESC") themes.reverse(); if (this.props.orderKey == "DESC") themes.reverse();
if (reverseSorts.includes(sortKey)) themes.reverse(); if (reverseSorts.includes(this.props.sortKey)) themes.reverse();
return themes; return themes;
} }
openPreview() { openPreview() {
@ -523,7 +519,7 @@ module.exports = (_ => {
mode: childMode, mode: childMode,
filter: childType == "file" && "image" filter: childType == "file" && "image"
}, },
label: varName[0].toUpperCase() + varName.slice(1), label: varName.split("-").map(BDFDB.LibraryModules.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription, note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%", basis: "70%",
value: oldValue, value: oldValue,
@ -731,7 +727,10 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardiconwrapper, className: BDFDB.disCN.discoverycardiconwrapper,
children: BDFDB.ReactUtils.createElement("div", { children: this.props.data.author && this.props.data.author.discord_avatar_hash && this.props.data.author.discord_snowflake ? BDFDB.ReactUtils.createElement("img", {
className: BDFDB.disCN.discoverycardicon,
src: `https://cdn.discordapp.com/avatars/${this.props.data.author.discord_snowflake}/${this.props.data.author.discord_avatar_hash}.webp?size=128`
}) : BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardicon, className: BDFDB.disCN.discoverycardicon,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, { children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
nativeClass: true, nativeClass: true,
@ -793,7 +792,7 @@ module.exports = (_ => {
}), }),
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardauthor, className: BDFDB.disCN.discoverycardauthor,
children: `by ${this.props.data.author}` children: `by ${this.props.data.authorname}`
}), }),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, { BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, {
className: BDFDB.disCN.discoverycarddescription, className: BDFDB.disCN.discoverycarddescription,
@ -978,7 +977,7 @@ module.exports = (_ => {
label: sortKeys[this.props.sortKey], label: sortKeys[this.props.sortKey],
value: this.props.sortKey value: this.props.sortKey
}, },
options: Object.keys(sortKeys).filter(n => n != "NEW" || grabbedThemes.some(t => !cachedThemes.includes(t.id))).map(key => ({ options: Object.keys(sortKeys).map(key => ({
label: sortKeys[key], label: sortKeys[key],
value: key value: key
})), })),
@ -1243,7 +1242,7 @@ module.exports = (_ => {
const checkTheme = _ => { const checkTheme = _ => {
if (checksRunning > 20) return; if (checksRunning > 20) return;
else if (grabbedThemes.every(t => t.loaded || !t.latestSourceUrl) || !this.started || !loading.is) { else if (grabbedThemes.every(t => t.loaded || (!t.latestSourceUrl && !t.latest_source_url)) || !this.started || !loading.is) {
if (!callbackCalled) { if (!callbackCalled) {
callbackCalled = true; callbackCalled = true;
if (!this.started) return BDFDB.TimeUtils.clear(loading.timeout); if (!this.started) return BDFDB.TimeUtils.clear(loading.timeout);
@ -1283,7 +1282,7 @@ module.exports = (_ => {
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN, contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
close: true, close: true,
onClick: _ => { onClick: _ => {
forcedSort = "NEW"; forcedSort = "RELEASEDATE";
forcedOrder = "ASC"; forcedOrder = "ASC";
BDFDB.LibraryModules.UserSettingsUtils.open("themerepo"); BDFDB.LibraryModules.UserSettingsUtils.open("themerepo");
} }
@ -1313,15 +1312,21 @@ module.exports = (_ => {
else if (checkIndex > grabbedThemes.length) return; else if (checkIndex > grabbedThemes.length) return;
const theme = grabbedThemes[checkIndex++]; const theme = grabbedThemes[checkIndex++];
if (!theme || !theme.latestSourceUrl) checkTheme(); if (!theme || (!theme.latestSourceUrl && !theme.latest_source_url)) checkTheme();
else { else {
checksRunning++; checksRunning++;
theme.releasedate = new Date(theme.releaseDate || theme.release_date || 0).getTime();
theme.latestSourceUrl = theme.latestSourceUrl || theme.latest_source_url;
theme.rawSourceUrl = theme.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1"); theme.rawSourceUrl = theme.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1");
theme.thumbnailUrl = theme.thumbnailUrl || theme.thumbnail_url;
theme.thumbnailUrl = theme.thumbnailUrl ? (theme.thumbnailUrl.startsWith("https://") ? theme.thumbnailUrl : `https://betterdiscord.app${theme.thumbnailUrl}`) : ""; theme.thumbnailUrl = theme.thumbnailUrl ? (theme.thumbnailUrl.startsWith("https://") ? theme.thumbnailUrl : `https://betterdiscord.app${theme.thumbnailUrl}`) : "";
delete theme.release_date;
delete theme.latest_source_url;
delete theme.thumbnail_url;
BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => { BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => {
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) { if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
theme.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.name || ""); theme.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.name || "");
theme.author = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.author; theme.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.author.display_name || theme.author;
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1]; const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1];
if (version) { if (version) {
theme.version = version; theme.version = version;
@ -1410,12 +1415,12 @@ module.exports = (_ => {
} }
getInstalledTheme (theme) { getInstalledTheme (theme) {
if (!theme || typeof theme.author != "string") return; if (!theme || typeof theme.authoName != "string") return;
const iTheme = BDFDB.BDUtils.getTheme(theme.name, false, true); const iTheme = BDFDB.BDUtils.getTheme(theme.name, false, true);
if (iTheme && theme.author.toUpperCase() == this.getString(iTheme.author).toUpperCase()) return iTheme; if (iTheme && theme.authorname.toUpperCase() == this.getString(iTheme.author).toUpperCase()) return iTheme;
else if (theme.rawSourceUrl && window.BdApi && BdApi.Themes && typeof BdApi.Themes.getAll == "function") { else if (theme.rawSourceUrl && window.BdApi && BdApi.Themes && typeof BdApi.Themes.getAll == "function") {
const filename = theme.rawSourceUrl.split("/").pop(); const filename = theme.rawSourceUrl.split("/").pop();
for (let t of BdApi.Themes.getAll()) if (t.filename == filename && theme.author.toUpperCase() == this.getString(t.author).toUpperCase()) return t; for (let t of BdApi.Themes.getAll()) if (t.filename == filename && theme.authorname.toUpperCase() == this.getString(t.author).toUpperCase()) return t;
} }
} }