BetterDiscordAddons/Plugins/ThemeRepo/ThemeRepo.plugin.js

1262 lines
61 KiB
JavaScript
Raw Permalink Normal View History

2020-10-20 23:25:34 +02:00
/**
* @name ThemeRepo
2021-03-05 13:26:41 +01:00
* @author DevilBro
2020-10-20 23:25:34 +02:00
* @authorId 278543574059057154
2024-04-04 18:39:12 +02:00
* @version 2.5.6
2021-05-03 07:49:46 +02:00
* @description Allows you to download all Themes from BD's Website within Discord
2020-10-20 23:25:34 +02:00
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
* @patreon https://www.patreon.com/MircoWittrien
2021-03-09 15:10:55 +01:00
* @website https://mwittrien.github.io/
* @source https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ThemeRepo/
2021-03-10 09:17:37 +01:00
* @updateUrl https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/ThemeRepo.plugin.js
2020-10-20 23:25:34 +02:00
*/
2020-08-15 09:37:12 +02:00
2020-09-19 20:31:49 +02:00
module.exports = (_ => {
2022-09-01 14:40:11 +02:00
const changeLog = {
2022-10-27 14:45:51 +02:00
2020-08-15 09:37:12 +02:00
};
2020-11-13 19:47:44 +01:00
2022-02-05 21:14:17 +01:00
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
2022-09-01 14:55:22 +02:00
constructor (meta) {for (let key in meta) this[key] = meta[key];}
getName () {return this.name;}
getAuthor () {return this.author;}
getVersion () {return this.version;}
getDescription () {return `The Library Plugin needed for ${this.name} is missing. Open the Plugin Settings to download it. \n\n${this.description}`;}
2021-02-01 17:13:13 +01:00
downloadLibrary () {
2023-11-18 18:31:04 +01:00
BdApi.Net.fetch("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js").then(r => {
if (!r || r.status != 200) throw new Error();
else return r.text();
}).then(b => {
if (!b) throw new Error();
else return require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0BDFDB.plugin.js"), b, _ => BdApi.showToast("Finished downloading BDFDB Library", {type: "success"}));
}).catch(error => {
BdApi.alert("Error", "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library");
2021-02-01 17:13:13 +01:00
});
}
2020-09-19 20:31:49 +02:00
2021-01-06 12:38:36 +01:00
load () {
2020-11-19 16:51:14 +01:00
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
2020-09-19 20:31:49 +02:00
if (!window.BDFDB_Global.downloadModal) {
window.BDFDB_Global.downloadModal = true;
2022-09-01 14:55:22 +02:00
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
2020-09-19 20:31:49 +02:00
confirmText: "Download Now",
cancelText: "Cancel",
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
2020-09-20 08:15:13 +02:00
onConfirm: _ => {
delete window.BDFDB_Global.downloadModal;
2021-02-01 17:13:13 +01:00
this.downloadLibrary();
2020-09-20 08:15:13 +02:00
}
2020-09-19 20:31:49 +02:00
});
2020-08-15 09:37:12 +02:00
}
2022-09-01 14:55:22 +02:00
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
2020-10-09 21:09:35 +02:00
}
2021-01-06 12:38:36 +01:00
start () {this.load();}
stop () {}
getSettingsPanel () {
2020-11-28 23:12:09 +01:00
let template = document.createElement("template");
2022-09-01 14:55:22 +02:00
template.innerHTML = `<div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${this.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
2021-02-01 17:13:13 +01:00
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
2020-11-28 23:12:09 +01:00
return template.content.firstElementChild;
}
2020-10-09 21:09:35 +02:00
} : (([Plugin, BDFDB]) => {
2020-09-19 20:31:49 +02:00
var _this;
2021-05-03 15:49:33 +02:00
2022-10-11 11:30:01 +02:00
var list;
2021-05-03 15:49:33 +02:00
2023-11-24 11:33:58 +01:00
var loading, cachedThemes, grabbedThemes, generatorThemes, updateInterval, errorState;
2021-05-03 19:20:03 +02:00
var searchString, searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
2021-05-03 15:49:33 +02:00
var updateGeneratorTimeout, forceRerenderGenerator, nativeCSS, nativeCSSvars;
var favorites = [];
2020-09-19 20:31:49 +02:00
const themeStates = {
2021-05-03 15:49:33 +02:00
INSTALLED: 0,
2020-09-19 20:31:49 +02:00
OUTDATED: 1,
DOWNLOADABLE: 2
};
const buttonData = {
2021-05-03 15:49:33 +02:00
INSTALLED: {
2022-12-11 17:41:43 +01:00
backgroundColor: "var(--status-positive)",
2020-11-12 17:48:14 +01:00
icon: "CHECKMARK",
2022-02-16 15:54:37 +01:00
text: "installed"
2020-09-19 20:31:49 +02:00
},
OUTDATED: {
2022-12-11 17:41:43 +01:00
backgroundColor: "var(--status-danger)",
2020-11-12 17:48:14 +01:00
icon: "CLOSE",
2021-01-22 21:01:58 +01:00
text: "outdated"
2020-09-19 20:31:49 +02:00
},
DOWNLOADABLE: {
2020-12-22 17:41:09 +01:00
backgroundColor: "var(--bdfdb-blurple)",
2020-11-12 17:48:14 +01:00
icon: "DOWNLOAD",
2021-01-22 21:01:58 +01:00
text: "download"
2020-08-15 09:37:12 +02:00
}
2020-09-19 20:31:49 +02:00
};
2021-05-03 15:49:33 +02:00
const reverseSorts = [
2021-05-12 19:44:23 +02:00
"RELEASEDATE", "DOWNLOADS", "LIKES", "FAV"
2021-05-03 15:49:33 +02:00
];
2020-09-19 20:31:49 +02:00
const sortKeys = {
NAME: "Name",
2021-05-12 19:44:23 +02:00
AUTHORNAME: "Author",
2020-09-19 20:31:49 +02:00
VERSION: "Version",
2023-11-24 11:33:58 +01:00
DESCRIPTION: "Description",
RELEASEDATE: "Release Date",
2020-09-19 20:31:49 +02:00
STATE: "Update State",
2021-05-03 15:49:33 +02:00
DOWNLOADS: "Downloads",
LIKES: "Likes",
2021-05-12 19:44:23 +02:00
FAV: "Favorites"
2020-09-19 20:31:49 +02:00
};
const orderKeys = {
ASC: "ascending",
DESC: "descending"
};
2021-02-05 23:24:38 +01:00
const themeRepoIcon = `<svg width="42" height="32" viewBox="0 0 42 32"><path fill="COLOR_1" d="M 0,0 V 7.671875 H 8.6211458 V 32 H 16.922769 V 7.672 l 8.621146,-1.25e-4 V 0 Z"/><path fill="COLOR_2" d="M 29.542969 0 L 29.542969 7.5488281 L 30.056641 7.5488281 C 35.246318 7.5488281 35.246318 14.869141 30.056641 14.869141 L 25.234375 14.869141 L 25.234375 11.671875 L 20.921875 11.671875 L 20.921875 32 L 25.234375 32 L 25.234375 21.830078 L 26.705078 21.830078 L 34.236328 32 L 42 32 L 42 28.931641 L 35.613281 21.017578 C 39.562947 19.797239 41.998047 16.452154 41.998047 10.53125 C 41.814341 3.0284252 36.625168 0 29.919922 0 L 29.542969 0 z"/></svg>`;
2020-09-19 20:31:49 +02:00
const RepoListComponent = class ThemeList extends BdApi.React.Component {
2021-01-20 16:00:29 +01:00
componentDidMount() {
2020-09-19 20:31:49 +02:00
list = this;
BDFDB.TimeUtils.timeout(_ => {
forcedSort = null;
forcedOrder = null;
showOnlyOutdated = false;
}, 5000);
}
2021-02-04 15:53:49 +01:00
componentWillUnmount() {
list = null;
2020-09-19 20:31:49 +02:00
}
2021-02-04 15:53:49 +01:00
filterThemes() {
2021-05-03 15:49:33 +02:00
let themes = grabbedThemes.map(theme => {
2022-12-07 11:31:44 +01:00
if (theme.failed) return;
2021-05-03 16:37:43 +02:00
const installedTheme = _this.getInstalledTheme(theme);
2022-06-07 08:06:07 +02:00
const state = installedTheme ? (theme.version && _this.compareVersions(theme.version, _this.getString(installedTheme.version)) ? themeStates.OUTDATED : themeStates.INSTALLED) : themeStates.DOWNLOADABLE;
2021-05-07 22:22:36 +02:00
return Object.assign(theme, {
2021-05-12 19:44:23 +02:00
search: [theme.name, theme.version, theme.authorname, theme.description, theme.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(),
2020-10-16 10:30:44 +02:00
description: theme.description || "No Description found",
2021-05-03 15:49:33 +02:00
fav: favorites.includes(theme.id) && 1,
new: state == themeStates.DOWNLOADABLE && !cachedThemes.includes(theme.id) && 1,
state: state
2021-05-07 22:22:36 +02:00
});
2022-12-07 11:31:44 +01:00
}).filter(n => n);
2023-11-24 11:33:58 +01:00
if (!this.props.updated) themes = themes.filter(theme => theme.state != themeStates.INSTALLED);
if (!this.props.outdated) themes = themes.filter(theme => theme.state != themeStates.OUTDATED);
if (!this.props.downloadable) themes = themes.filter(theme => theme.state != themeStates.DOWNLOADABLE);
if (searchString) {
2021-05-03 19:20:03 +02:00
let usedSearchString = searchString.toUpperCase();
2021-07-28 20:00:56 +02:00
let spacelessUsedSearchString = usedSearchString.replace(/\s/g, "");
2021-08-02 20:06:11 +02:00
themes = themes.filter(theme => theme.search.indexOf(usedSearchString) > -1 || theme.search.indexOf(spacelessUsedSearchString) > -1);
2020-08-15 09:37:12 +02:00
}
2021-05-03 15:49:33 +02:00
2021-05-12 19:44:23 +02:00
BDFDB.ArrayUtils.keySort(themes, this.props.sortKey.toLowerCase());
2020-09-19 20:31:49 +02:00
if (this.props.orderKey == "DESC") themes.reverse();
2021-05-12 19:44:23 +02:00
if (reverseSorts.includes(this.props.sortKey)) themes.reverse();
2020-09-19 20:31:49 +02:00
return themes;
}
2022-06-29 16:18:49 +02:00
createThemeFile(name, filename, body, autoloadKey) {
2021-05-03 15:49:33 +02:00
return new Promise(callback => BDFDB.LibraryRequires.fs.writeFile(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), filename), body, error => {
2022-04-29 14:52:56 +02:00
if (error) {
callback(true);
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_fail", `Theme "${name}"`), {type: "danger"});
}
2021-05-03 15:49:33 +02:00
else {
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("save_success", `Theme "${name}"`), {type: "success"});
2022-06-29 16:18:49 +02:00
if (_this.settings.general[autoloadKey]) BDFDB.TimeUtils.timeout(_ => {
2021-05-03 15:49:33 +02:00
if (BDFDB.BDUtils.isThemeEnabled(name) == false) {
BDFDB.BDUtils.enableTheme(name, false);
BDFDB.LogUtils.log(BDFDB.LanguageUtils.LibraryStringsFormat("toast_plugin_started", name), _this);
}
}, 3000);
callback();
}
}));
}
generateTheme(css) {
if (!css || !BDFDB.ObjectUtils.is(this.props.generatorValues)) return "";
for (let inputId in this.props.generatorValues) if (this.props.generatorValues[inputId].value && this.props.generatorValues[inputId].value.trim() && this.props.generatorValues[inputId].value != this.props.generatorValues[inputId].oldValue) css = css.replace(new RegExp(`--${BDFDB.StringUtils.regEscape(inputId)}(\\s*):(\\s*)${BDFDB.StringUtils.regEscape(this.props.generatorValues[inputId].oldValue)}`,"g"),`--${inputId}$1: $2${this.props.generatorValues[inputId].value}`);
return css;
}
createFixerCSS(body) {
let oldCSS = body.replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/\r/g, "\\r").split("REPLACE_CLASS_");
let newCSS = oldCSS.shift();
for (let str of oldCSS) {
let reg = /([A-z0-9_]+)(.*)/.exec(str);
newCSS += BDFDB.dotCN[reg[1]] + reg[2];
}
return newCSS.replace(/\\n/g, "\n").replace(/\\t/g, "\t").replace(/\\r/g, "\r");
}
2021-01-20 16:00:29 +01:00
render() {
2020-09-19 20:31:49 +02:00
if (!this.props.tab) this.props.tab = "Themes";
2021-05-03 15:49:33 +02:00
2022-10-12 11:12:24 +02:00
const entries = (!loading.is && grabbedThemes.length ? this.filterThemes() : []);
2020-09-19 20:31:49 +02:00
2023-11-24 11:33:58 +01:00
const emptyState = errorState ? {
lightSrc: "/assets/d6dfb89ab06b62044dbb.svg",
darkSrc: "/assets/8eeb59bba0a61cbffc41.svg",
text: "Could not load Theme Store due to an Issue with the BD Website"
} : !entries.length && !this.props.updated && !this.props.outdated && !this.props.downloadable ? {
text: `You disabled all Filter Options in the "${BDFDB.LanguageUtils.LanguageStrings.SETTINGS}" Tab`
} : !entries.length && searchString ? {
lightSrc: "/assets/75081bdaad2d359c1469.svg",
darkSrc: "/assets/45cd76fed34c8e398cc8.svg"
} : !entries.length ? {} : null;
2020-09-19 20:31:49 +02:00
if (forceRerenderGenerator && this.props.tab == "Generator") BDFDB.TimeUtils.timeout(_ => {
forceRerenderGenerator = false;
BDFDB.ReactUtils.forceUpdate(this);
});
2022-10-11 11:30:01 +02:00
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._repo,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCNS._repolistheader + BDFDB.disCN.settingswindowcontentcolumndefault,
2020-09-19 20:31:49 +02:00
children: [
2022-10-11 11:30:01 +02:00
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCN.marginbottom4,
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
grow: 1,
shrink: 0,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormTitle, {
2022-11-22 01:30:30 +01:00
tag: BDFDB.LibraryComponents.FormComponents.FormTags.H1,
2022-10-11 11:30:01 +02:00
className: BDFDB.disCN.marginreset,
2022-10-12 11:12:24 +02:00
children: `Theme Repo — ${loading.is ? 0 : entries.length || 0}/${loading.is ? 0 : grabbedThemes.length}`
2022-10-11 11:30:01 +02:00
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
autoFocus: true,
query: searchString,
onChange: value => {
if (loading.is) return;
BDFDB.TimeUtils.clear(searchTimeout);
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
searchString = value.replace(/[<|>]/g, "");
BDFDB.ReactUtils.forceUpdate(this);
}, 1000);
},
onClear: _ => {
if (loading.is) return;
searchString = "";
BDFDB.ReactUtils.forceUpdate(this);
}
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
size: BDFDB.LibraryComponents.Button.Sizes.TINY,
children: BDFDB.LanguageUtils.LibraryStrings.check_for_updates,
onClick: _ => {
if (loading.is) return;
loading = {is: false, timeout: null, amount: 0};
2023-04-15 17:03:37 +02:00
_this.loadThemes(true);
2022-10-11 11:30:01 +02:00
}
})
]
2020-09-19 20:31:49 +02:00
}),
2022-10-11 11:30:01 +02:00
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
className: BDFDB.disCNS.tabbarcontainer + BDFDB.disCN.tabbarcontainerbottom,
align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TabBar, {
className: BDFDB.disCN.tabbar,
itemClassName: BDFDB.disCN.tabbaritem,
type: BDFDB.LibraryComponents.TabBar.Types.TOP,
selectedItem: this.props.tab,
items: [{value: "Themes"}, {value: "Generator"}, {value: BDFDB.LanguageUtils.LanguageStrings.SETTINGS}],
onItemSelect: value => {
this.props.tab = value;
BDFDB.ReactUtils.forceUpdate(this);
}
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
label: BDFDB.LanguageUtils.LibraryStrings.sort_by + ":",
value: {
label: sortKeys[this.props.sortKey],
value: this.props.sortKey
},
options: Object.keys(sortKeys).map(key => ({
label: sortKeys[key],
value: key
})),
onChange: key => {
this.props.sortKey = key;
BDFDB.ReactUtils.forceUpdate(this);
}
})
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.QuickSelect, {
label: BDFDB.LanguageUtils.LibraryStrings.order + ":",
value: {
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[this.props.orderKey]],
value: this.props.orderKey
},
options: Object.keys(orderKeys).map(key => ({
label: BDFDB.LanguageUtils.LibraryStrings[orderKeys[key]],
value: key
})),
onChange: key => {
this.props.orderKey = key;
BDFDB.ReactUtils.forceUpdate(this);
}
})
})
]
2020-09-19 20:31:49 +02:00
})
]
2022-10-11 11:30:01 +02:00
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Auto, {
className: BDFDB.disCNS._repolistscroller + BDFDB.disCN.settingswindowcontentcolumndefault,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
tab: "Themes",
open: this.props.tab == "Themes",
render: false,
children: loading.is ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
justify: BDFDB.LibraryComponents.Flex.Justify.CENTER,
style: {marginTop: "50%"},
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SpinnerComponents.Spinner, {
type: BDFDB.LibraryComponents.SpinnerComponents.Types.WANDERING_CUBES
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
className: BDFDB.disCN.margintop20,
style: {textAlign: "center"},
children: `${BDFDB.LanguageUtils.LibraryStringsFormat("loading", "Theme Repo")} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`
})
]
2023-11-24 11:33:58 +01:00
}) : emptyState ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.EmptyStateImage, emptyState) : BDFDB.ReactUtils.createElement("div", {
2022-10-11 11:30:01 +02:00
className: BDFDB.disCN.discoverycards,
2022-10-12 11:12:24 +02:00
children: entries.map(theme => BDFDB.ReactUtils.createElement(RepoCardComponent, {
data: theme
})).filter(n => n)
2022-10-11 11:30:01 +02:00
})
2020-09-19 20:31:49 +02:00
}),
2022-10-11 11:30:01 +02:00
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
tab: "Generator",
open: this.props.tab == "Generator",
render: false,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
type: "Select",
margin: 20,
label: "Choose a Generator Theme",
basis: "60%",
value: this.props.currentGenerator || "-----",
options: [{value: "-----", label: "-----"}, nativeCSSvars && {value: "nativediscord", label: "Discord"}].concat(generatorThemes.map(t => ({value: t.id, label: t.name || "-----"})).sort((x, y) => (x.label < y.label ? -1 : x.label > y.label ? 1 : 0))).filter(n => n),
onChange: value => {
let generatorTheme = generatorThemes.find(t => t.id == value);
if (generatorTheme || value == "nativediscord") {
if (this.props.currentGenerator) forceRerenderGenerator = true;
this.props.currentGenerator = value;
this.props.currentGeneratorIsNative = value == "nativediscord";
this.props.generatorValues = {};
}
else {
delete this.props.currentGenerator;
delete this.props.currentGeneratorIsNative;
delete this.props.generatorValues;
2020-09-19 20:31:49 +02:00
}
2022-10-11 11:30:01 +02:00
delete this.props.currentTheme;
BDFDB.ReactUtils.forceUpdate(this);
2020-08-15 09:37:12 +02:00
}
2022-10-11 11:30:01 +02:00
}),
!this.props.currentGenerator ? null : (forceRerenderGenerator ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
direction: BDFDB.LibraryComponents.Flex.Direction.VERTICAL,
justify: BDFDB.LibraryComponents.Flex.Justify.CENTER,
style: {marginTop: "50%"},
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SpinnerComponents.Spinner, {
type: BDFDB.LibraryComponents.SpinnerComponents.Types.WANDERING_CUBES
})
}) : [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
className: BDFDB.disCN.marginbottom20,
type: "Button",
label: "Download generated Theme",
children: "Download",
onClick: _ => {
if (this.props.currentGeneratorIsNative) {
this.createThemeFile("Discord", "Discord.theme.css", `/**\n * @name Discord\n * @description Allow you to easily customize Discord's native Look \n * @author DevilBro\n * @version 1.0.0\n * @authorId 278543574059057154\n * @invite Jx3TjNS\n * @donate https://www.paypal.me/MircoWittrien\n * @patreon https://www.patreon.com/MircoWittrien\n */\n\n` + this.generateTheme(nativeCSSvars), "startDownloaded");
}
else {
let generatorTheme = generatorThemes.find(t => t.id == this.props.currentGenerator);
if (generatorTheme) this.createThemeFile(generatorTheme.name, generatorTheme.rawSourceUrl.split("/").pop(), this.generateTheme(generatorTheme.fullCSS), "startDownloaded");
}
}
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FormComponents.FormDivider, {
className: BDFDB.disCN.marginbottom20
}),
(_ => {
let generatorTheme = generatorThemes.find(t => t.id == this.props.currentGenerator);
let vars = this.props.currentGeneratorIsNative ? nativeCSSvars.split(".theme-dark, .theme-light") : ((generatorTheme || {}).fullCSS || "").split(":root");
if (vars.length < 2) return null;
vars = vars[1].replace(/\t\(/g, " (").replace(/\r|\t| {2,}/g, "").replace(/\/\*\n*((?!\/\*|\*\/).|\n)*\n+((?!\/\*|\*\/).|\n)*\n*\*\//g, "").replace(/\n\/\*.*?\*\//g, "").replace(/\n/g, "");
vars = vars.split("{");
vars.shift();
vars = vars.join("{").replace(/\s*(:|;|--|\*)\s*/g, "$1");
vars = vars.split("}")[0];
vars = (vars.endsWith(";") ? vars.slice(0, -1) : vars).slice(2).split(/;--|\*\/--/);
let inputRefs = [];
for (let varStr of vars) {
varStr = varStr.split(":");
let varName = varStr.shift().trim();
varStr = varStr.join(":").split(/;[^A-z0-9]|\/\*/);
let oldValue = varStr.shift().trim();
if (oldValue) {
let childType = "text", childMode = "";
let isColor = BDFDB.ColorUtils.getType(oldValue);
let isComp = !isColor && /^[0-9 ]+,[0-9 ]+,[0-9 ]+$/g.test(oldValue);
if (isColor || isComp) {
childType = "color";
childMode = isComp && "comp";
}
else {
let isUrlFile = /url\(.+\)/gi.test(oldValue);
let isFile = !isUrlFile && /(http(s)?):\/\/[(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/.test(oldValue);
if (isFile || isUrlFile) {
childType = "file";
childMode = isUrlFile && "url";
}
}
let varDescription = varStr.join("").replace(/\*\/|\/\*/g, "").replace(/:/g, ": ").replace(/: \//g, ":/").replace(/--/g, " --").replace(/\( --/g, "(--").trim();
this.props.generatorValues[varName] = {value: oldValue, oldValue};
inputRefs.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
dividerBottom: vars[vars.length-1] != varStr,
type: "TextInput",
childProps: {
type: childType,
mode: childMode,
filter: childType == "file" && "image"
},
label: varName.split("-").map(BDFDB.StringUtils.upperCaseFirstChar).join(" "),
note: varDescription && varDescription.indexOf("*") == 0 ? varDescription.slice(1) : varDescription,
basis: "70%",
value: oldValue,
placeholder: oldValue,
onChange: value => {
BDFDB.TimeUtils.clear(updateGeneratorTimeout);
updateGeneratorTimeout = BDFDB.TimeUtils.timeout(_ => this.props.generatorValues[varName] = {value, oldValue}, 1000);
}
}));
}
}
return inputRefs;
})()
])
].flat(10).filter(n => n)
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
tab: BDFDB.LanguageUtils.LanguageStrings.SETTINGS,
open: this.props.tab == BDFDB.LanguageUtils.LanguageStrings.SETTINGS,
render: false,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
2023-11-24 11:33:58 +01:00
title: "Shows following Themes",
2022-10-11 11:30:01 +02:00
children: Object.keys(_this.defaults.filters).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: _this,
keys: ["filters", key],
label: _this.defaults.filters[key].description,
value: _this.settings.filters[key],
2020-09-19 20:31:49 +02:00
onChange: value => {
2022-10-11 11:30:01 +02:00
this.props[key] = _this.settings.filters[key] = value;
BDFDB.ReactUtils.forceUpdate(this);
2020-09-19 20:31:49 +02:00
}
2022-10-11 11:30:01 +02:00
}))
}),
Object.keys(_this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
type: "Switch",
plugin: _this,
keys: ["general", key],
label: _this.defaults.general[key].description,
value: _this.settings.general[key],
onChange: value => {
_this.settings.general[key] = value;
BDFDB.ReactUtils.forceUpdate(this);
}
}))
].flat(10).filter(n => n)
})
]
})
]
});
2020-09-19 20:31:49 +02:00
}
};
const RepoCardComponent = class ThemeCard extends BdApi.React.Component {
2021-01-20 16:00:29 +01:00
render() {
2021-05-03 15:49:33 +02:00
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycard,
2022-10-12 11:12:24 +02:00
onMouseEnter: _ => {
this.props.hovered = true;
BDFDB.ReactUtils.forceUpdate(this);
},
2021-05-03 15:49:33 +02:00
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardheader,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardcoverwrapper,
children: [
2022-10-12 11:12:24 +02:00
this.props.data.thumbnailUrl && this.props.hovered && BDFDB.ReactUtils.createElement("img", {
2021-05-03 15:49:33 +02:00
className: BDFDB.disCN.discoverycardcover,
2021-05-03 19:20:03 +02:00
src: this.props.data.thumbnailUrl,
2021-05-03 15:49:33 +02:00
onClick: _ => {
2022-10-12 11:12:24 +02:00
const url = this.props.data.thumbnailUrl;
2021-05-03 19:20:03 +02:00
const img = document.createElement("img");
2021-05-03 15:49:33 +02:00
img.addEventListener("load", function() {
2022-10-12 11:12:24 +02:00
BDFDB.LibraryModules.ModalUtils.openModal(modalData => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalRoot, Object.assign({
className: BDFDB.disCN.imagemodal
}, modalData, {
size: BDFDB.LibraryComponents.ModalComponents.ModalSize.DYNAMIC,
"aria-label": BDFDB.LanguageUtils.LanguageStrings.IMAGE,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ImageModal, {
animated: false,
src: url,
original: url,
width: this.width,
height: this.height,
className: BDFDB.disCN.imagemodalimage,
shouldAnimate: true,
renderLinkComponent: props => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, props)
})
}), true));
2021-05-03 15:49:33 +02:00
});
2021-05-03 19:20:03 +02:00
img.src = url;
2021-05-03 15:49:33 +02:00
}
}),
this.props.data.new && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
className: BDFDB.disCN.discoverycardcoverbadge,
style: {
borderRadius: 3,
textTransform: "uppercase",
2023-02-22 15:34:45 +01:00
background: BDFDB.DiscordConstants.Colors.YELLOW
2021-05-03 15:49:33 +02:00
},
text: BDFDB.LanguageUtils.LanguageStrings.NEW
})
]
}),
2022-10-12 11:12:24 +02:00
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardiconwrapper,
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardicon,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
nativeClass: true,
iconSVG: `<svg width="100%" height="100%" viewBox="0 0 24 24"><path fill="currentColor" d="m 14.69524,1.9999881 c -0.17256,0 -0.34519,0.065 -0.47686,0.1969 L 8.8655531,7.5498683 16.449675,15.134198 21.802502,9.7812182 c 0.26333,-0.2633 0.26333,-0.6904 0,-0.9537 L 20.7902,7.8168183 c -0.22885,-0.2289 -0.58842,-0.2633 -0.85606,-0.081 l -2.127134,1.4452499 1.437076,-2.1418399 c 0.17949,-0.2675 0.14486,-0.6251001 -0.083,-0.8528001 l -2.195488,-2.19433 c -0.20264,-0.2026 -0.51169,-0.2562 -0.7698,-0.1318 l -0.37921,0.1839 0.18228,-0.4036001 c 0.11521,-0.2555 0.0599,-0.5553 -0.13834,-0.7535 l -0.68843,-0.6901 c -0.131639,-0.13172 -0.30429,-0.19701 -0.476854,-0.19701 z M 7.8695308,8.5459582 6.3201566,10.095378 c -0.126449,0.1264 -0.196927,0.298 -0.196927,0.4769 0,0.1788 0.07043,0.3505 0.196927,0.4769 l 1.469627,1.46967 c 0.283151,0.2832 0.421272,0.6744 0.377578,1.07255 -0.04365,0.3979 -0.264001,0.7495 -0.602173,0.9651 -4.3184212,2.75283 -4.720939,3.15533 -4.853187,3.28763 -0.9493352,0.9493 -0.9493352,2.494471 0,3.443871 0.9502793,0.9503 2.4954759,0.9484 3.4437772,0 0.132338,-0.1323 0.534965,-0.535 3.2875378,-4.853321 0.215049,-0.3374 0.5670574,-0.5568 0.9651044,-0.6006 0.399307,-0.044 0.790042,0.094 1.072518,0.376 l 1.469626,1.46967 c 0.26328,0.2633 0.69043,0.2633 0.95371,0 l 1.549374,-1.54942 z M 4.4762059,18.571608 c 0.243902,0 0.487705,0.092 0.673783,0.2783 0.3722,0.3722 0.3722,0.975401 0,1.347601 -0.3722,0.3722 -0.97541,0.3722 -1.3475649,0 -0.3722,-0.3722 -0.3722,-0.975401 0,-1.347601 0.1861,-0.1861 0.42988,-0.2783 0.6737819,-0.2783 z"/></svg>`
})
})
})
2021-05-03 15:49:33 +02:00
]
2020-11-12 17:48:14 +01:00
}),
2021-05-03 15:49:33 +02:00
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardinfo,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardtitle,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardname,
children: this.props.data.name
}),
2021-06-14 19:28:10 +02:00
this.props.data.latestSourceUrl &&
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: BDFDB.LanguageUtils.LanguageStrings.SCREENSHARE_SOURCE,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
className: BDFDB.disCN.discoverycardtitlebutton,
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
nativeClass: true,
width: 16,
height: 16,
name: BDFDB.LibraryComponents.SvgIcon.Names.GITHUB
})
}),
onClick: _ => BDFDB.DiscordUtils.openLink(this.props.data.latestSourceUrl)
}),
2021-05-03 15:49:33 +02:00
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FavButton, {
className: BDFDB.disCN.discoverycardtitlebutton,
isFavorite: this.props.data.fav,
onClick: value => {
this.props.data.fav = value && 1;
if (value) favorites.push(this.props.data.id);
else BDFDB.ArrayUtils.remove(favorites, this.props.data.id, true);
BDFDB.DataUtils.save(BDFDB.ArrayUtils.numSort(favorites).join(" "), _this, "favorites");
}
})
]
}),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardauthor,
2021-05-12 19:44:23 +02:00
children: `by ${this.props.data.authorname}`
2021-05-03 15:49:33 +02:00
}),
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Thin, {
className: BDFDB.disCN.discoverycarddescription,
children: this.props.data.description
}),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardfooter,
children: [
BDFDB.ArrayUtils.is(this.props.data.tags) && this.props.data.tags.length && BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardtags,
children: this.props.data.tags.map(tag => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
className: BDFDB.disCN.discoverycardtag,
style: {background: "var(--background-accent)"},
text: tag
}))
}),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardcontrols,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardstats,
children: [
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardstat,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.discoverycardstaticon,
name: BDFDB.LibraryComponents.SvgIcon.Names.DOWNLOAD
}),
this.props.data.downloads
]
}),
BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.discoverycardstat,
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.discoverycardstaticon,
name: BDFDB.LibraryComponents.SvgIcon.Names.HEART
}),
this.props.data.likes
]
})
]
}),
BDFDB.ReactUtils.createElement(RepoCardDownloadButtonComponent, {
...buttonData[(Object.entries(themeStates).find(n => n[1] == this.props.data.state) || [])[0]],
installed: this.props.data.state == themeStates.INSTALLED,
2021-06-15 14:06:15 +02:00
outdated: this.props.data.state == themeStates.OUTDATED,
2021-05-03 15:49:33 +02:00
onDownload: _ => {
2022-04-29 14:52:56 +02:00
if (!list || this.props.downloading) return;
this.props.downloading = true;
let loadingToast = BDFDB.NotificationUtils.toast(`${BDFDB.LanguageUtils.LibraryStringsFormat("loading", this.props.data.name)} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`, {timeout: 0, ellipsis: true});
2022-07-05 09:41:44 +02:00
let autoloadKey = this.props.data.state == themeStates ? "startUpdated" : "startDownloaded";
2023-11-04 10:33:32 +01:00
BDFDB.LibraryRequires.request(this.props.data.rawSourceUrl, (error, response, body) => {
if (error || !body) {
2022-04-29 14:52:56 +02:00
delete this.props.downloading;
loadingToast.close();
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("download_fail", `Theme "${this.props.data.name}"`), {type: "danger"});
}
2023-11-04 10:33:32 +01:00
else list.createThemeFile(this.props.data.name, this.props.data.rawSourceUrl.split("/").pop(), body, autoloadKey).then(error2 => {
2022-04-29 14:52:56 +02:00
delete this.props.downloading;
loadingToast.close();
if (!error2) {
this.props.data.state = themeStates.INSTALLED;
BDFDB.ReactUtils.forceUpdate(this);
}
2021-05-03 15:49:33 +02:00
});
});
},
onDelete: _ => {
2022-04-29 14:52:56 +02:00
if (this.props.deleting) return;
this.props.deleting = true;
2022-10-27 14:45:51 +02:00
BDFDB.LibraryRequires.fs.unlinkSync(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getThemesFolder(), this.props.data.rawSourceUrl.split("/").pop()));
delete this.props.deleting;
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_success", `Theme "${this.props.data.name}"`));
this.props.data.state = themeStates.DOWNLOADABLE;
BDFDB.ReactUtils.forceUpdate(this);
2021-05-03 15:49:33 +02:00
}
})
]
})
]
2020-08-15 09:37:12 +02:00
})
2021-05-03 15:49:33 +02:00
]
2020-09-19 20:31:49 +02:00
})
]
});
}
};
2021-05-03 15:49:33 +02:00
const RepoCardDownloadButtonComponent = class ThemeCardDownloadButton extends BdApi.React.Component {
render() {
2021-06-15 14:06:15 +02:00
const backgroundColor = this.props.doDelete ? buttonData.OUTDATED.backgroundColor : this.props.doUpdate ? buttonData.INSTALLED.backgroundColor : this.props.backgroundColor;
2021-05-03 15:49:33 +02:00
return BDFDB.ReactUtils.createElement("button", {
className: BDFDB.disCN.discoverycardbutton,
2021-06-15 14:06:15 +02:00
style: {backgroundColor: BDFDB.DiscordConstants.Colors[backgroundColor] || backgroundColor},
2021-05-03 15:49:33 +02:00
children: [
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.discoverycardstaticon,
width: 16,
height: 16,
2021-06-15 14:06:15 +02:00
name: this.props.doDelete ? BDFDB.LibraryComponents.SvgIcon.Names.TRASH : this.props.doUpdate ? BDFDB.LibraryComponents.SvgIcon.Names.DOWNLOAD : BDFDB.LibraryComponents.SvgIcon.Names[this.props.icon]
2021-05-03 15:49:33 +02:00
}),
2021-06-15 14:06:15 +02:00
this.props.doDelete ? BDFDB.LanguageUtils.LanguageStrings.APPLICATION_CONTEXT_MENU_UNINSTALL : this.props.doUpdate ? BDFDB.LanguageUtils.LanguageStrings.GAME_ACTION_BUTTON_UPDATE : (BDFDB.LanguageUtils.LibraryStringsCheck[this.props.text] ? BDFDB.LanguageUtils.LibraryStrings[this.props.text] : BDFDB.LanguageUtils.LanguageStrings[this.props.text])
2021-05-03 15:49:33 +02:00
],
onClick: _ => {
2021-06-15 14:06:15 +02:00
if (this.props.doDelete) typeof this.props.onDelete == "function" && this.props.onDelete();
2022-06-29 16:18:49 +02:00
else if (!this.props.installed) typeof this.props.onDownload == "function" && this.props.onDownload();
2021-05-03 15:49:33 +02:00
},
2021-06-15 14:06:15 +02:00
onMouseEnter: this.props.installed ? (_ => {
this.props.doDelete = true;
2021-05-03 15:49:33 +02:00
BDFDB.ReactUtils.forceUpdate(this);
2021-06-15 14:06:15 +02:00
}) : this.props.outdated ? (_ => {
this.props.doUpdate = true;
2021-05-03 15:49:33 +02:00
BDFDB.ReactUtils.forceUpdate(this);
2021-06-15 14:06:15 +02:00
}) : (_ => {}),
onMouseLeave: this.props.installed ? (_ => {
this.props.doDelete = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : this.props.outdated ? (_ => {
this.props.doUpdate = false;
BDFDB.ReactUtils.forceUpdate(this);
}) : (_ => {})
2021-05-03 15:49:33 +02:00
});
}
};
2020-10-09 21:09:35 +02:00
return class ThemeRepo extends Plugin {
2021-01-06 12:38:36 +01:00
onLoad () {
2020-09-19 20:31:49 +02:00
_this = this;
2020-11-19 16:51:14 +01:00
loading = {is: false, timeout: null, amount: 0};
2021-05-03 15:49:33 +02:00
2020-09-19 20:31:49 +02:00
cachedThemes = [];
grabbedThemes = [];
2021-05-03 19:20:03 +02:00
searchString = "";
2020-08-15 09:37:12 +02:00
2020-09-19 20:31:49 +02:00
this.defaults = {
2021-05-03 15:49:33 +02:00
general: {
2022-12-07 11:31:44 +01:00
notifyOutdated: {value: true, autoload: false, description: "Shows a Notification when one of your Themes is outdated"},
notifyNewEntries: {value: true, autoload: false, description: "Shows a Notification when there are new Entries in the Repo"},
startDownloaded: {value: false, autoload: true, description: "Starts new Themes after Download"},
startUpdated: {value: false, autoload: true, description: "Starts updated Themes after Download"}
2020-09-19 20:31:49 +02:00
},
2021-05-03 15:49:33 +02:00
filters: {
2023-11-18 18:31:04 +01:00
updated: {value: true, description: "Updated"},
outdated: {value: true, description: "Outdated"},
2021-05-03 15:49:33 +02:00
downloadable: {value: true, description: "Downloadable"},
2020-09-19 20:31:49 +02:00
}
};
2021-05-03 15:49:33 +02:00
2022-10-11 11:30:01 +02:00
this.modulePatches = {
before: [
"SettingsView",
"StandardSidebarView"
],
componentWillUnmount: [
"SettingsView"
]
2020-09-19 20:31:49 +02:00
};
}
2021-01-06 12:38:36 +01:00
onStart () {
2024-04-04 18:39:12 +02:00
generatorThemes = [];
2020-08-15 09:37:12 +02:00
this.forceUpdateAll();
this.loadThemes();
2022-02-16 15:54:37 +01:00
updateInterval = BDFDB.TimeUtils.interval(_ => this.checkForNewThemes(), 1000*60*30);
2020-08-15 09:37:12 +02:00
}
2020-09-19 20:31:49 +02:00
2021-01-06 12:38:36 +01:00
onStop () {
2020-08-15 09:37:12 +02:00
BDFDB.TimeUtils.clear(updateInterval);
2022-02-16 15:54:37 +01:00
BDFDB.TimeUtils.clear(loading.timeout);
2020-08-15 09:37:12 +02:00
this.forceUpdateAll();
2021-01-22 21:01:58 +01:00
BDFDB.DOMUtils.remove(BDFDB.dotCN._themereponotice, BDFDB.dotCN._themerepoloadingicon);
2020-08-15 09:37:12 +02:00
}
2021-05-03 15:49:33 +02:00
2021-01-06 12:38:36 +01:00
onSettingsClosed () {
2020-09-19 20:31:49 +02:00
if (this.SettingsUpdated) {
delete this.SettingsUpdated;
this.forceUpdateAll();
}
}
2020-08-15 09:37:12 +02:00
2021-01-06 12:38:36 +01:00
forceUpdateAll () {
2020-09-19 20:31:49 +02:00
favorites = BDFDB.DataUtils.load(this, "favorites");
2021-05-03 15:49:33 +02:00
favorites = (typeof favorites == "string" ? favorites.split(" ") : []).map(n => parseInt(n)).filter(n => !isNaN(n));
2020-09-19 20:31:49 +02:00
BDFDB.PatchUtils.forceAllUpdates(this);
2020-08-15 09:37:12 +02:00
}
2020-09-19 20:31:49 +02:00
onUserSettingsCogContextMenu (e) {
BDFDB.TimeUtils.timeout(_ => {
2020-10-24 10:45:35 +02:00
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["label", ["BandagedBD", "BetterDiscord"]]]});
2020-09-19 20:31:49 +02:00
if (index > -1 && BDFDB.ArrayUtils.is(children[index].props.children)) children[index].props.children.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
2020-08-15 09:37:12 +02:00
label: "Theme Repo",
2020-09-19 20:31:49 +02:00
id: BDFDB.ContextMenuUtils.createItemId(this.name, "repo"),
2023-03-18 12:07:50 +01:00
action: _ => BDFDB.LibraryModules.UserSettingsUtils.open("themerepo")
2020-09-19 20:31:49 +02:00
}));
});
}
processSettingsView (e) {
2021-05-03 19:20:03 +02:00
if (e.node) searchString = "";
2022-10-11 11:30:01 +02:00
else if (e.component.prototype && !BDFDB.PatchUtils.isPatched(this, e.component.prototype, "getPredicateSections")) {
BDFDB.PatchUtils.patch(this, e.component.prototype, "getPredicateSections", {after: e2 => {
2022-02-16 15:54:37 +01:00
if (BDFDB.ArrayUtils.is(e2.returnValue) && e2.returnValue.findIndex(n => n.section && (n.section.toLowerCase() == "changelog" || n.section == BDFDB.DiscordConstants.UserSettingsSections.CHANGE_LOG || n.section.toLowerCase() == "logout" || n.section == BDFDB.DiscordConstants.UserSettingsSections.LOGOUT))) {
e2.returnValue = e2.returnValue.filter(n => n.section != "themerepo");
let index = e2.returnValue.indexOf(e2.returnValue.find(n => n.section == "pluginrepo") || e2.returnValue.find(n => n.section == "themes") || e2.returnValue.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.DEVELOPER_OPTIONS) || e2.returnValue.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.HYPESQUAD_ONLINE));
if (index > -1) {
e2.returnValue.splice(index + 1, 0, {
2022-08-21 19:05:37 +02:00
className: "themerepo-tab",
2022-02-16 15:54:37 +01:00
section: "themerepo",
label: "Theme Repo",
element: _ => {
let options = Object.assign({}, this.settings.filters);
options.updated = options.updated && !showOnlyOutdated;
options.outdated = options.outdated || showOnlyOutdated;
options.downloadable = options.downloadable && !showOnlyOutdated;
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
options.useLightMode = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
options.useThemeFixer = false;
options.useCustomCSS = false;
return BDFDB.ReactUtils.createElement(RepoListComponent, options);
}
});
if (!e2.returnValue.find(n => n.section == "plugins" || n.section == "pluginrepo")) e2.returnValue.splice(index + 1, 0, {section: "DIVIDER"});
}
}
}});
}
2020-08-15 09:37:12 +02:00
}
2020-09-19 20:31:49 +02:00
processStandardSidebarView (e) {
2022-11-26 13:43:14 +01:00
if (e.instance.props && e.instance.props.section == "themerepo") e.instance.props.contentType = "custom";
2020-08-15 09:37:12 +02:00
}
2020-09-19 20:31:49 +02:00
generateTheme (fullCSS, generatorValues) {
if (!fullCSS || !BDFDB.ObjectUtils.is(generatorValues)) return "";
2020-11-19 16:51:14 +01:00
for (let inputId in generatorValues) if (generatorValues[inputId].value && generatorValues[inputId].value.trim() && generatorValues[inputId].value != generatorValues[inputId].oldValue) fullCSS = fullCSS.replace(new RegExp(`--${BDFDB.StringUtils.regEscape(inputId)}(\\s*):(\\s*)${BDFDB.StringUtils.regEscape(generatorValues[inputId].oldValue)}`,"g"),`--${inputId}$1: $2${generatorValues[inputId].value}`);
2020-09-19 20:31:49 +02:00
return fullCSS;
2020-08-15 09:37:12 +02:00
}
2023-04-15 17:03:37 +02:00
loadThemes (forceBanner) {
2021-01-22 21:01:58 +01:00
BDFDB.DOMUtils.remove(BDFDB.dotCN._themerepoloadingicon);
2021-05-03 15:49:33 +02:00
cachedThemes = BDFDB.DataUtils.load(this, "cached");
cachedThemes = (typeof cachedThemes == "string" ? cachedThemes.split(" ") : []).map(n => parseInt(n)).filter(n => !isNaN(n));
let loadingIcon;
let newEntries = 0, outdatedEntries = 0, checkIndex = 0, checksRunning = 0, callbackCalled = false;
2021-05-03 19:20:03 +02:00
const checkTheme = _ => {
2021-05-03 15:49:33 +02:00
if (checksRunning > 20) return;
2021-05-12 19:44:23 +02:00
else if (grabbedThemes.every(t => t.loaded || (!t.latestSourceUrl && !t.latest_source_url)) || !this.started || !loading.is) {
2021-05-03 15:49:33 +02:00
if (!callbackCalled) {
callbackCalled = true;
if (!this.started) return BDFDB.TimeUtils.clear(loading.timeout);
2020-11-12 17:48:14 +01:00
BDFDB.TimeUtils.clear(loading.timeout);
2021-01-22 21:01:58 +01:00
BDFDB.DOMUtils.remove(loadingIcon, BDFDB.dotCN._themerepoloadingicon);
2020-11-19 16:51:14 +01:00
loading = {is: false, timeout: null, amount: loading.amount};
2020-11-12 17:48:14 +01:00
2021-03-08 14:42:56 +01:00
BDFDB.LogUtils.log("Finished fetching Themes", this);
2021-05-03 15:49:33 +02:00
BDFDB.ReactUtils.forceUpdate(list);
2020-11-12 17:48:14 +01:00
2023-04-15 17:03:37 +02:00
if ((this.settings.general.notifyOutdated || forceBanner) && outdatedEntries > 0) {
2021-02-09 12:44:26 +01:00
let notice = document.querySelector(BDFDB.dotCN._themerepooutdatednotice);
if (notice) notice.close();
2021-05-03 15:49:33 +02:00
BDFDB.NotificationUtils.notice(this.labels.notice_outdated_themes.replace("{{var0}}", outdatedEntries), {
2020-11-12 17:48:14 +01:00
type: "danger",
2021-01-22 21:01:58 +01:00
className: BDFDB.disCNS._themereponotice + BDFDB.disCN._themerepooutdatednotice,
2021-02-09 13:05:30 +01:00
customIcon: themeRepoIcon.replace(/COLOR_[0-9]+/gi, "currentColor"),
2021-01-23 19:15:17 +01:00
buttons: [{
2021-01-23 19:19:40 +01:00
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
2021-01-23 19:15:17 +01:00
close: true,
onClick: _ => {
showOnlyOutdated = true;
BDFDB.LibraryModules.UserSettingsUtils.open("themerepo");
}
}]
2020-11-12 17:48:14 +01:00
});
}
2021-05-03 15:49:33 +02:00
if (this.settings.general.notifyNewEntries && newEntries > 0) {
2021-02-09 12:44:26 +01:00
let notice = document.querySelector(BDFDB.dotCN._themereponewentriesnotice);
if (notice) notice.close();
2021-01-23 20:15:58 +01:00
BDFDB.NotificationUtils.notice(this.labels.notice_new_themes.replace("{{var0}}", newEntries), {
2020-11-12 17:48:14 +01:00
type: "success",
2021-01-22 21:01:58 +01:00
className: BDFDB.disCNS._themereponotice + BDFDB.disCN._themereponewentriesnotice,
2021-02-09 13:05:30 +01:00
customIcon: themeRepoIcon.replace(/COLOR_[0-9]+/gi, "currentColor"),
2021-01-23 19:15:17 +01:00
buttons: [{
2021-01-23 19:19:40 +01:00
contents: BDFDB.LanguageUtils.LanguageStrings.OPEN,
2021-01-23 19:15:17 +01:00
close: true,
onClick: _ => {
2021-05-12 19:44:23 +02:00
forcedSort = "RELEASEDATE";
2021-01-23 19:15:17 +01:00
forcedOrder = "ASC";
BDFDB.LibraryModules.UserSettingsUtils.open("themerepo");
}
}]
2020-11-12 17:48:14 +01:00
});
}
2023-11-04 10:33:32 +01:00
BDFDB.LibraryRequires.request("https://mwittrien.github.io/BetterDiscordAddons/Plugins/ThemeRepo/_res/GeneratorList.txt", (error, response, body) => {
if (!error && body) for (let id of body.replace(/[\r\t]/g, "").split(" ").map(n => parseInt(n)).filter(n => n != null)) {
2021-05-03 15:49:33 +02:00
let theme = grabbedThemes.find(t => t.id == id);
if (theme) generatorThemes.push(theme);
2020-08-15 09:37:12 +02:00
}
2020-11-12 17:48:14 +01:00
});
2023-11-04 10:33:32 +01:00
BDFDB.LibraryRequires.request(document.querySelector("head link[rel='stylesheet'][href*='assets/app.'], body link[rel='stylesheet'][href*='assets/app.']").href, (error, response, body) => {
let nativeCSS = !error && body;
2022-12-07 11:31:44 +01:00
if (nativeCSS) {
2020-11-12 17:48:14 +01:00
let theme = BDFDB.DiscordUtils.getTheme();
let vars = (nativeCSS.split(`.${theme}{`)[1] || "").split("}")[0];
nativeCSSvars = vars ? `.theme-dark, .theme-light {${vars}}` : "";
2020-09-19 20:31:49 +02:00
}
2020-11-12 17:48:14 +01:00
else nativeCSS = nativeCSSvars = "";
2020-09-09 23:25:23 +02:00
});
2021-05-03 15:49:33 +02:00
}
2020-09-19 20:31:49 +02:00
return;
}
2021-05-03 15:49:33 +02:00
else if (checkIndex > grabbedThemes.length) return;
const theme = grabbedThemes[checkIndex++];
2021-05-12 19:44:23 +02:00
if (!theme || (!theme.latestSourceUrl && !theme.latest_source_url)) checkTheme();
2021-05-03 15:49:33 +02:00
else {
checksRunning++;
2021-05-12 19:44:23 +02:00
theme.releasedate = new Date(theme.releaseDate || theme.release_date || 0).getTime();
theme.latestSourceUrl = theme.latestSourceUrl || theme.latest_source_url;
2021-05-03 19:20:03 +02:00
theme.rawSourceUrl = theme.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1");
2021-05-12 19:44:23 +02:00
theme.thumbnailUrl = theme.thumbnailUrl || theme.thumbnail_url;
2021-05-03 19:20:03 +02:00
theme.thumbnailUrl = theme.thumbnailUrl ? (theme.thumbnailUrl.startsWith("https://") ? theme.thumbnailUrl : `https://betterdiscord.app${theme.thumbnailUrl}`) : "";
2021-05-12 19:44:23 +02:00
delete theme.release_date;
delete theme.latest_source_url;
delete theme.thumbnail_url;
2023-11-04 10:33:32 +01:00
BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => {
if (error || !body || body.indexOf("404: Not Found") == 0) theme.failed = true;
2022-12-07 11:31:44 +01:00
else {
2023-11-04 10:33:32 +01:00
const META = body.split("*/")[0];
theme.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || theme.name || "");
theme.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || theme.author.display_name || theme.author;
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1];
if (version) theme.version = version;
if (theme.version) {
const installedTheme = this.getInstalledTheme(theme);
if (installedTheme && this.compareVersions(version, this.getString(installedTheme.version))) outdatedEntries++;
}
let text = body.trim();
let hasMETAline = text.replace(/\s/g, "").indexOf("//META{"), newMeta = "";
if (hasMETAline < 20 && hasMETAline > -1) {
let i = 0, j = 0, metaString = "";
try {
for (let c of `{${text.split("{").slice(1).join("{")}`) {
metaString += c;
if (c == "{") i++;
else if (c == "}") j++;
if (i > 0 && i == j) break;
2021-04-03 19:19:31 +02:00
}
2023-11-04 10:33:32 +01:00
let metaObj = JSON.parse(metaString);
newMeta = "/**\n";
for (let key in metaObj) newMeta += ` * @${key} ${metaObj[key]}\n`;
newMeta += "*/";
2021-04-03 19:19:31 +02:00
}
2023-11-04 10:33:32 +01:00
catch (err) {newMeta = "";}
2020-08-15 09:37:12 +02:00
}
2023-11-04 10:33:32 +01:00
theme.fullCSS = [newMeta, newMeta ? text.split("\n").slice(1).join("\n") : text].filter(n => n).join("\n");
theme.css = (hasMETAline < 20 && hasMETAline > -1 ? text.split("\n").slice(1).join("\n") : text).replace(/[\r|\n|\t]/g, "");
2022-12-07 11:31:44 +01:00
if (!cachedThemes.includes(theme.id)) newEntries++;
2020-08-15 09:37:12 +02:00
}
2021-05-03 15:49:33 +02:00
theme.loaded = true;
let loadingTooltip = document.querySelector(BDFDB.dotCN._themerepoloadingtooltip);
if (loadingTooltip) loadingTooltip.update(this.getLoadingTooltipText());
checksRunning--;
2021-05-03 19:20:03 +02:00
checkTheme();
2021-05-03 15:49:33 +02:00
});
}
};
2023-10-20 14:32:21 +02:00
BDFDB.TimeUtils.timeout(_ => BDFDB.LibraryRequires.request("https://api.betterdiscord.app/v1/store/themes", {bdVersion: true}, (error, response, body) => {
2022-02-22 09:49:27 +01:00
if (!error && body && response.statusCode == 200) try {
2021-05-03 15:49:33 +02:00
grabbedThemes = BDFDB.ArrayUtils.keySort(JSON.parse(body).filter(n => n), "name");
2021-05-20 19:30:10 +02:00
2021-05-03 15:49:33 +02:00
BDFDB.DataUtils.save(BDFDB.ArrayUtils.numSort(grabbedThemes.map(n => n.id)).join(" "), this, "cached");
loading = {is: true, timeout: BDFDB.TimeUtils.timeout(_ => {
BDFDB.TimeUtils.clear(loading.timeout);
if (this.started) {
if (loading.is && loading.amount < 4) BDFDB.TimeUtils.timeout(_ => this.loadThemes(), 10000);
loading = {is: false, timeout: null, amount: loading.amount};
}
}, 1200000), amount: loading.amount + 1};
2020-09-19 20:31:49 +02:00
2021-05-03 15:49:33 +02:00
loadingIcon = BDFDB.DOMUtils.create(themeRepoIcon.replace(/COLOR_1/gi, "var(--bdfdb-blurple)").replace(/COLOR_2/gi, "#72767d"));
BDFDB.DOMUtils.addClass(loadingIcon, BDFDB.disCN._themerepoloadingicon);
loadingIcon.addEventListener("mouseenter", _ => {
BDFDB.TooltipUtils.create(loadingIcon, this.getLoadingTooltipText(), {
type: "left",
className: BDFDB.disCN._themerepoloadingtooltip,
delay: 500,
style: "max-width: unset;"
});
});
BDFDB.PluginUtils.addLoadingIcon(loadingIcon);
2020-09-19 20:31:49 +02:00
2022-10-11 11:30:01 +02:00
BDFDB.ReactUtils.forceUpdate(list);
2021-05-03 15:49:33 +02:00
2021-05-03 19:20:03 +02:00
for (let i = 0; i <= 20; i++) checkTheme();
2020-09-19 20:31:49 +02:00
}
2021-05-03 15:49:33 +02:00
catch (err) {BDFDB.NotificationUtils.toast("Failed to load Theme Store", {type: "danger"});}
2023-11-24 11:33:58 +01:00
let status = {};
if (response && response.statusCode == 403) status = {code: response.statusCode, reason: " due to DDoS Protection"};
else if (response && response.statusCode == 404) status = {code: response.statusCode, reason: " due to DDoS Protection"};
else if (response && response.statusCode == 502) status = {code: response.statusCode, reason: ", because the API is down"};
if (status.code) {
BDFDB.NotificationUtils.toast("Failed to fetch Theme Store from the Website API" + status.reason, {type: "danger"});
errorState = status.code;
}
else errorState = null;
2023-10-20 14:32:21 +02:00
}), 10000);
2020-09-19 20:31:49 +02:00
}
2020-08-15 09:37:12 +02:00
2021-05-03 15:49:33 +02:00
getLoadingTooltipText () {
return BDFDB.LanguageUtils.LibraryStringsFormat("loading", `Theme Repo - [${grabbedThemes.filter(n => n.loaded).length}/${grabbedThemes.length}]`);
2020-09-19 20:31:49 +02:00
}
2020-08-15 09:37:12 +02:00
2021-05-03 15:49:33 +02:00
getString (obj) {
let string = "";
if (typeof obj == "string") string = obj;
else if (obj && obj.props) {
if (typeof obj.props.children == "string") string = obj.props.children;
else if (Array.isArray(obj.props.children)) for (let c of obj.props.children) string += typeof c == "string" ? c : this.getString(c);
}
return string;
2020-08-15 09:37:12 +02:00
}
2022-06-07 08:06:07 +02:00
2022-06-07 08:50:28 +02:00
compareVersions (v1, v2) {
2022-06-07 12:12:47 +02:00
return !(v1 == v2 || !BDFDB.NumberUtils.compareVersions(v1, v2));
2022-06-07 08:06:07 +02:00
}
2021-05-03 15:49:33 +02:00
getInstalledTheme (theme) {
2021-05-20 19:30:10 +02:00
if (!theme || typeof theme.authorname != "string") return;
2021-05-03 15:49:33 +02:00
const iTheme = BDFDB.BDUtils.getTheme(theme.name, false, true);
2023-03-21 20:00:39 +01:00
if (iTheme && (theme.authorname.toUpperCase().indexOf(this.getString(iTheme.author).toUpperCase()) > -1 || this.getString(iTheme.author).toUpperCase().indexOf(theme.authorname.toUpperCase()) > -1)) return iTheme;
2021-05-03 15:49:33 +02:00
else if (theme.rawSourceUrl && window.BdApi && BdApi.Themes && typeof BdApi.Themes.getAll == "function") {
const filename = theme.rawSourceUrl.split("/").pop();
2023-03-21 20:00:39 +01:00
for (let t of BdApi.Themes.getAll()) if (t.filename == filename && (theme.authorname.toUpperCase().indexOf(this.getString(t.author).toUpperCase()) > -1 || this.getString(t.author).toUpperCase().indexOf(theme.authorname.toUpperCase()) > -1)) return t;
2020-09-19 20:31:49 +02:00
}
}
2020-08-15 09:37:12 +02:00
2021-05-03 15:49:33 +02:00
checkForNewThemes () {
2023-10-20 14:25:24 +02:00
BDFDB.LibraryRequires.request("https://api.betterdiscord.app/v1/store/themes", {bdVersion: true}, (error, response, body) => {
2021-05-03 15:49:33 +02:00
if (!error && body) try {
if (JSON.parse(body).filter(n => n).length != grabbedThemes.length) {
loading = {is: false, timeout: null, amount: 0};
this.loadThemes();
}
}
catch (err) {BDFDB.NotificationUtils.toast("Failed to load Theme Store", {type: "danger"});}
2020-09-19 20:31:49 +02:00
});
2020-08-15 09:37:12 +02:00
}
2021-01-23 20:15:58 +01:00
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "bg": // Bulgarian
return {
list: "Списък",
notice_failed_themes: "Някои Themes [{{var0}}] не можаха да бъдат заредени",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Новите Themes [{{var0}}] бяха добавени към Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Някои Themes [{{var0}}] са остарели"
};
case "da": // Danish
return {
list: "Liste",
notice_failed_themes: "Nogle Themes [{{var0}}] kunne ikke indlæses",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Nye Themes [{{var0}}] er blevet føjet til Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Nogle Themes [{{var0}}] er forældede"
};
case "de": // German
return {
list: "Liste",
notice_failed_themes: "Einige Themes [{{var0}}] konnten nicht geladen werden",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Neue Themes [{{var0}}] wurden zur Theme Repo hinzugefügt",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Einige Themes [{{var0}}] sind veraltet"
};
case "el": // Greek
return {
list: "Λίστα",
2023-04-19 10:39:58 +02:00
notice_failed_themes: "Ορισμένα Θέματα [{{var0}}] δεν μπορούν να φορτωθούν",
notice_new_themes: "Νέα Θέματα [{{var0}}] προστέθηκαν στο Απωθετήριο Θεμάτων",
notice_outdated_themes: "Ορισμένα Θέματα [{{var0}}] είναι παλαιά"
2021-01-23 20:15:58 +01:00
};
case "es": // Spanish
return {
list: "Lista",
notice_failed_themes: "Algunos Themes [{{var0}}] no se pudieron cargar",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Se han agregado nuevos Themes [{{var0}}] a Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Algunas Themes [{{var0}}] están desactualizadas"
};
case "fi": // Finnish
return {
list: "Lista",
notice_failed_themes: "Joitain kohdetta Themes [{{var0}}] ei voitu ladata",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Uusi Themes [{{var0}}] on lisätty Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Jotkut Themes [{{var0}}] ovat vanhentuneita"
};
case "fr": // French
return {
list: "Liste",
notice_failed_themes: "Certains Themes [{{var0}}] n'ont pas pu être chargés",
2021-04-01 22:35:07 +02:00
notice_new_themes: "De nouveaux Themes [{{var0}}] ont été ajoutés à Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Certains Themes [{{var0}}] sont obsolètes"
};
case "hr": // Croatian
return {
list: "Popis",
notice_failed_themes: "Neke datoteke Themes [{{var0}}] nije moguće učitati",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Novi Themes [{{var0}}] dodani su u Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Neki su Themes [{{var0}}] zastarjeli"
};
case "hu": // Hungarian
return {
list: "Lista",
notice_failed_themes: "Néhány Themes [{{var0}}] nem sikerült betölteni",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Új Themes [{{var0}}] hozzáadva a következőhöz: Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Néhány Themes [{{var0}}] elavult"
};
case "it": // Italian
return {
list: "Elenco",
notice_failed_themes: "Impossibile caricare alcuni Themes [{{var0}}] ",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Il nuovo Themes [{{var0}}] è stato aggiunto a Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Alcuni Themes [{{var0}}] non sono aggiornati"
};
case "ja": // Japanese
return {
list: "リスト",
notice_failed_themes: "一部の Themes [{{var0}}] を読み込めませんでした",
2021-04-01 22:35:07 +02:00
notice_new_themes: "新しい Themes [{{var0}}] が Theme Repo に追加されました",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "一部の Themes [{{var0}}] は古くなっています"
};
case "ko": // Korean
return {
list: "명부",
notice_failed_themes: "일부 Themes [{{var0}}] 을 (를)로드 할 수 없습니다.",
2021-04-01 22:35:07 +02:00
notice_new_themes: "새 Themes [{{var0}}] 이 Theme Repo 에 추가되었습니다.",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "일부 Themes [{{var0}}] 이 오래되었습니다."
};
case "lt": // Lithuanian
return {
list: "Sąrašas",
notice_failed_themes: "Kai kurių Themes [{{var0}}] nepavyko įkelti",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Naujas Themes [{{var0}}] pridėtas prie Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Kai kurie Themes [{{var0}}] yra pasenę"
};
case "nl": // Dutch
return {
list: "Lijst",
notice_failed_themes: "Sommige Themes [{{var0}}] konden niet worden geladen",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Nieuwe Themes [{{var0}}] zijn toegevoegd aan de Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Sommige Themes [{{var0}}] zijn verouderd"
};
case "no": // Norwegian
return {
list: "Liste",
notice_failed_themes: "Noen Themes [{{var0}}] kunne ikke lastes inn",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Nye Themes [{{var0}}] er lagt til i Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Noen Themes [{{var0}}] er utdaterte"
};
case "pl": // Polish
return {
list: "Lista",
notice_failed_themes: "Nie można załadować niektórych Themes [{{var0}}] ",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Nowe Themes [{{var0}}] zostały dodane do Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Niektóre Themes [{{var0}}] są nieaktualne"
};
case "pt-BR": // Portuguese (Brazil)
return {
list: "Lista",
notice_failed_themes: "Algum Themes [{{var0}}] não pôde ser carregado",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Novo Themes [{{var0}}] foi adicionado ao Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Alguns Themes [{{var0}}] estão desatualizados"
};
case "ro": // Romanian
return {
list: "Listă",
notice_failed_themes: "Unele Themes [{{var0}}] nu au putut fi încărcate",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Themes [{{var0}}] nou au fost adăugate la Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Unele Themes [{{var0}}] sunt învechite"
};
case "ru": // Russian
return {
list: "Список",
notice_failed_themes: "Не удалось загрузить некоторые Themes [{{var0}}] ",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Новые Themes [{{var0}}] добавлены в Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Некоторые Themes [{{var0}}] устарели"
};
case "sv": // Swedish
return {
list: "Lista",
notice_failed_themes: "Vissa Themes [{{var0}}] kunde inte laddas",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Nya Themes [{{var0}}] har lagts till i Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Vissa Themes [{{var0}}] är föråldrade"
};
case "th": // Thai
return {
list: "รายการ",
notice_failed_themes: "ไม่สามารถโหลด Themes [{{var0}}] บางรายการได้",
2021-04-01 22:35:07 +02:00
notice_new_themes: "เพิ่ม Themes [{{var0}}] ใหม่ใน Theme Repo แล้ว",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Themes [{{var0}}] บางรายการล้าสมัย"
};
case "tr": // Turkish
return {
list: "Liste",
notice_failed_themes: "Bazı Themes [{{var0}}] yüklenemedi",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Yeni Themes [{{var0}}], Theme Repo 'ye eklendi",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Bazı Themes [{{var0}}] güncel değil"
};
case "uk": // Ukrainian
return {
list: "Список",
notice_failed_themes: "Деякі Themes [{{var0}}] не вдалося завантажити",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Нові Themes [{{var0}}] були додані до Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Деякі Themes [{{var0}}] застарілі"
};
case "vi": // Vietnamese
return {
list: "Danh sách",
notice_failed_themes: "Không thể tải một số Themes [{{var0}}] ",
2021-04-01 22:35:07 +02:00
notice_new_themes: "Themes [{{var0}}] mới đã được thêm vào Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Một số Themes [{{var0}}] đã lỗi thời"
};
case "zh-CN": // Chinese (China)
return {
list: "清单",
notice_failed_themes: "某些 Themes [{{var0}}] 无法加载",
2021-04-01 22:35:07 +02:00
notice_new_themes: "新的 Themes [{{var0}}] 已添加到 Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "一些 Themes [{{var0}}] 已过时"
};
case "zh-TW": // Chinese (Taiwan)
return {
list: "清單",
notice_failed_themes: "某些 Themes [{{var0}}] 無法加載",
2021-04-01 22:35:07 +02:00
notice_new_themes: "新的 Themes [{{var0}}] 已添加到 Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "一些 Themes [{{var0}}] 已過時"
};
default: // English
return {
list: "List",
notice_failed_themes: "Some Themes [{{var0}}] could not be loaded",
2021-04-01 22:35:07 +02:00
notice_new_themes: "New Themes [{{var0}}] have been added to the Theme Repo",
2021-01-23 20:15:58 +01:00
notice_outdated_themes: "Some Themes [{{var0}}] are outdated"
};
}
}
2020-09-19 20:31:49 +02:00
};
2022-09-01 14:40:11 +02:00
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
2023-04-19 10:39:58 +02:00
})();