stuff
This commit is contained in:
parent
ae0fa08908
commit
cfa78cb0e1
|
@ -421,7 +421,6 @@ img:not([src]), img[src=""], img[src="null"] {
|
|||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
padding: 6px 8px;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
[REPLACE_CLASS_discoverycardstats] {
|
||||
display: flex;
|
||||
|
|
|
@ -97,9 +97,9 @@ module.exports = (_ => {
|
|||
${BDFDB.dotCN._charcountercounter} {
|
||||
display: block;
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
font-size: 15px;
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
}
|
||||
${BDFDB.dotCN._charcounterchatcounter} {
|
||||
right: 0;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name PluginRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.1.9
|
||||
* @version 2.2.0
|
||||
* @description Allows you to download all Plugins from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,12 +17,16 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "PluginRepo",
|
||||
"author": "DevilBro",
|
||||
"version": "2.1.9",
|
||||
"version": "2.2.0",
|
||||
"description": "Allows you to download all Plugins from BD's Website within Discord"
|
||||
},
|
||||
"changeLog": {
|
||||
"progress": {
|
||||
"New Style and Website Store": "The Repo now directly reflects the Plugins hosted on <a>https://betterdiscord.app/</a> and uses a new Card Style"
|
||||
},
|
||||
"improved": {
|
||||
"Search String Cache": "Saves the Search Query for the Plugins Repo until the Settings Window was closed",
|
||||
"Thumbnails": "Converted Thumbnail Gifs to PNGs to reduce the stress, GIFs play when you hover over the Thumbnail"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -70,7 +74,7 @@ module.exports = (_ => {
|
|||
var list, header;
|
||||
|
||||
var loading, cachedPlugins, grabbedPlugins, updateInterval;
|
||||
var searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
var searchString, searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
|
||||
var favorites = [];
|
||||
|
||||
|
@ -148,9 +152,9 @@ module.exports = (_ => {
|
|||
if (!this.props.updated) plugins = plugins.filter(plugin => plugin.state != pluginStates.INSTALLED);
|
||||
if (!this.props.outdated) plugins = plugins.filter(plugin => plugin.state != pluginStates.OUTDATED);
|
||||
if (!this.props.downloadable) plugins = plugins.filter(plugin => plugin.state != pluginStates.DOWNLOADABLE);
|
||||
if (this.props.searchString) {
|
||||
let searchString = this.props.searchString.toUpperCase();
|
||||
plugins = plugins.filter(plugin => plugin.search.indexOf(searchString) > -1);
|
||||
if (searchString) {
|
||||
let usedSearchString = searchString.toUpperCase();
|
||||
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;
|
||||
|
@ -245,8 +249,6 @@ module.exports = (_ => {
|
|||
|
||||
const RepoCardComponent = class PluginCard extends BdApi.React.Component {
|
||||
render() {
|
||||
const thumbnailUrl = this.props.data.thumbnailUrl && `https://betterdiscord.app${this.props.data.thumbnailUrl}`;
|
||||
let downloadButton;
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycard,
|
||||
children: [
|
||||
|
@ -256,11 +258,14 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardcoverwrapper,
|
||||
children: [
|
||||
thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
this.props.data.thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN.discoverycardcover,
|
||||
src: thumbnailUrl,
|
||||
src: this.props.data.thumbnailUrl,
|
||||
onMouseEnter: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailGifUrl),
|
||||
onMouseLeave: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailUrl),
|
||||
onClick: _ => {
|
||||
let img = document.createElement("img");
|
||||
const url = this.props.data.thumbnailGifUrl || this.props.data.thumbnailUrl;
|
||||
const img = document.createElement("img");
|
||||
img.addEventListener("load", function() {
|
||||
BDFDB.LibraryModules.ModalUtils.openModal(modalData => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalRoot, Object.assign({
|
||||
|
@ -270,8 +275,8 @@ module.exports = (_ => {
|
|||
"aria-label": BDFDB.LanguageUtils.LanguageStrings.IMAGE,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ImageModal, {
|
||||
animated: false,
|
||||
src: thumbnailUrl,
|
||||
original: thumbnailUrl,
|
||||
src: url,
|
||||
original: url,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
className: BDFDB.disCN.imagemodalimage,
|
||||
|
@ -281,7 +286,7 @@ module.exports = (_ => {
|
|||
}), true);
|
||||
});
|
||||
});
|
||||
img.src = thumbnailUrl;
|
||||
img.src = url;
|
||||
}
|
||||
}),
|
||||
this.props.data.new && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
|
@ -479,18 +484,18 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
|
||||
autoFocus: true,
|
||||
query: this.props.searchString,
|
||||
query: searchString,
|
||||
onChange: (value, instance) => {
|
||||
if (loading.is) return;
|
||||
BDFDB.TimeUtils.clear(searchTimeout);
|
||||
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
this.props.searchString = list.props.searchString = value.replace(/[<|>]/g, "");
|
||||
searchString = value.replace(/[<|>]/g, "");
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}, 1000);
|
||||
},
|
||||
onClear: instance => {
|
||||
if (loading.is) return;
|
||||
this.props.searchString = list.props.searchString = "";
|
||||
searchString = "";
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
|
@ -572,6 +577,7 @@ module.exports = (_ => {
|
|||
|
||||
cachedPlugins = [];
|
||||
grabbedPlugins = [];
|
||||
searchString = "";
|
||||
|
||||
this.defaults = {
|
||||
general: {
|
||||
|
@ -588,7 +594,7 @@ module.exports = (_ => {
|
|||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
SettingsView: "render"
|
||||
SettingsView: ["render", "componentWillUnmount"]
|
||||
},
|
||||
after: {
|
||||
StandardSidebarView: "render"
|
||||
|
@ -645,7 +651,8 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processSettingsView (e) {
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.sections) && e.instance.props.sections[0] && e.instance.props.sections[0].label == BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS) {
|
||||
if (e.node) searchString = "";
|
||||
else if (BDFDB.ArrayUtils.is(e.instance.props.sections) && e.instance.props.sections[0] && e.instance.props.sections[0].label == BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS) {
|
||||
e.instance.props.sections = e.instance.props.sections.filter(n => n.section != "pluginrepo");
|
||||
let index = e.instance.props.sections.indexOf(e.instance.props.sections.find(n => n.section == "themes") || e.instance.props.sections.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.DEVELOPER_OPTIONS) || e.instance.props.sections.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.HYPESQUAD_ONLINE));
|
||||
if (index > -1) {
|
||||
|
@ -657,7 +664,6 @@ module.exports = (_ => {
|
|||
options.updated = options.updated && !showOnlyOutdated;
|
||||
options.outdated = options.outdated || showOnlyOutdated;
|
||||
options.downloadable = options.downloadable && !showOnlyOutdated;
|
||||
options.searchString = "";
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
|
||||
|
@ -676,7 +682,6 @@ module.exports = (_ => {
|
|||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregionscroller]]});
|
||||
if (index > -1) {
|
||||
let options = {};
|
||||
options.searchString = "";
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
|
@ -695,7 +700,7 @@ module.exports = (_ => {
|
|||
let loadingIcon;
|
||||
let newEntries = 0, outdatedEntries = 0, checkIndex = 0, checksRunning = 0, callbackCalled = false;
|
||||
|
||||
const checkPluginVersion = _ => {
|
||||
const checkPlugin = _ => {
|
||||
if (checksRunning > 20) return;
|
||||
else if (grabbedPlugins.every(p => p.loaded || !p.latestSourceUrl) || !this.started || !loading.is) {
|
||||
if (!callbackCalled) {
|
||||
|
@ -750,10 +755,26 @@ module.exports = (_ => {
|
|||
else if (checkIndex > grabbedPlugins.length) return;
|
||||
|
||||
const plugin = grabbedPlugins[checkIndex++];
|
||||
if (!plugin || !plugin.latestSourceUrl) checkPluginVersion();
|
||||
if (!plugin || !plugin.latestSourceUrl) checkPlugin();
|
||||
else {
|
||||
checksRunning++;
|
||||
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.thumbnailUrl.startsWith("https://") ? plugin.thumbnailUrl : `https://betterdiscord.app${plugin.thumbnailUrl}`) : "";
|
||||
if (plugin.thumbnailUrl) BDFDB.LibraryRequires.request({url: plugin.thumbnailUrl, encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
let throwAwayImg = new Image();
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = plugin.thumbnailUrl;
|
||||
plugin.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
plugin.thumbnailGifUrl = oldUrl;
|
||||
} catch(err) {}
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
});
|
||||
BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => {
|
||||
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 || "");
|
||||
|
@ -773,7 +794,7 @@ module.exports = (_ => {
|
|||
if (loadingTooltip) loadingTooltip.update(this.getLoadingTooltipText());
|
||||
|
||||
checksRunning--;
|
||||
checkPluginVersion();
|
||||
checkPlugin();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -805,7 +826,7 @@ module.exports = (_ => {
|
|||
|
||||
BDFDB.ReactUtils.forceUpdate(list, header);
|
||||
|
||||
for (let i = 0; i <= 20; i++) checkPluginVersion();
|
||||
for (let i = 0; i <= 20; i++) checkPlugin();
|
||||
}
|
||||
catch (err) {BDFDB.NotificationUtils.toast("Failed to load Plugin Store", {type: "danger"});}
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name ServerFolders
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 6.9.1
|
||||
* @version 6.9.2
|
||||
* @description Changes Discord's Folders, Servers open in a new Container, also adds extra Features to more easily organize, customize and manage your Folders
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,13 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ServerFolders",
|
||||
"author": "DevilBro",
|
||||
"version": "6.9.1",
|
||||
"version": "6.9.2",
|
||||
"description": "Changes Discord's Folders, Servers open in a new Container, also adds extra Features to more easily organize, customize and manage your Folders"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Full Screen": "Extra Column is no longer visible in Full Screen Voice Mode",
|
||||
"Settings": "Fixed Settings resetting after reloading"
|
||||
"Custom Icon Picker": "Fixed some Issues with the Custom Icon Picker"
|
||||
},
|
||||
}
|
||||
};
|
||||
|
@ -264,7 +263,10 @@ module.exports = (_ => {
|
|||
BDFDB.TimeUtils.clear(this._previewInterval);
|
||||
}
|
||||
checkImage(base64OrUrl, callback) {
|
||||
if (base64OrUrl.indexOf("https://") == 0 || base64OrUrl.indexOf("http://") == 0) BDFDB.LibraryRequires.request(base64OrUrl.trim(), (error, response, body) => {
|
||||
if (base64OrUrl.indexOf("https://") == 0 || base64OrUrl.indexOf("http://") == 0) BDFDB.LibraryRequires.request({
|
||||
url: base64OrUrl.trim(),
|
||||
encoding: null
|
||||
}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1 && response.headers["content-type"] != "image/gif") {
|
||||
this.resizeImage("data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64")), callback);
|
||||
}
|
||||
|
@ -291,13 +293,14 @@ module.exports = (_ => {
|
|||
let ctx = canvas.getContext("2d");
|
||||
ctx.canvas.width = width;
|
||||
ctx.canvas.height = height;
|
||||
document.body.appendChild(canvas);
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
callback(canvas.toDataURL(type));
|
||||
};
|
||||
img.onerror = function() {
|
||||
console.log("b");
|
||||
callback(base64);
|
||||
};
|
||||
console.log(base64);
|
||||
img.src = base64;
|
||||
}
|
||||
}
|
||||
|
@ -343,21 +346,21 @@ module.exports = (_ => {
|
|||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._serverfoldersiconswatch, BDFDB.disCN._serverfoldersiconswatchpreview, !this.props.open && BDFDB.disCN._serverfoldersiconswatchnopreview),
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._serverfoldersiconswatchinner,
|
||||
style: this.props.open && {background: `url(${this.props.open}) center/cover no-repeat`}
|
||||
style: this.props.open && {background: `url(${this.props.open}) center/cover no-repeat`} || {}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._serverfoldersiconswatch, BDFDB.disCN._serverfoldersiconswatchpreview, !this.props.closed && BDFDB.disCN._serverfoldersiconswatchnopreview),
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._serverfoldersiconswatchinner,
|
||||
style: this.props.closed && {background: `url(${this.props.closed}) center/cover no-repeat`}
|
||||
style: this.props.closed && {background: `url(${this.props.closed}) center/cover no-repeat`} || {}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._serverfoldersiconswatch, BDFDB.disCN._serverfoldersiconswatchpreview, !(this.props.tick ? this.props.open : this.props.closed) && BDFDB.disCN._serverfoldersiconswatchnopreview),
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._serverfoldersiconswatchinner,
|
||||
style: (this.props.tick ? this.props.open : this.props.closed) && {background: `url(${(this.props.tick ? this.props.open : this.props.closed)}) center/cover no-repeat`}
|
||||
style: (this.props.tick ? this.props.open : this.props.closed) && {background: `url(${(this.props.tick ? this.props.open : this.props.closed)}) center/cover no-repeat`} || {}
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Button, {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name ThemeRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.1.9
|
||||
* @version 2.2.0
|
||||
* @description Allows you to download all Themes from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,12 +17,16 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ThemeRepo",
|
||||
"author": "DevilBro",
|
||||
"version": "2.1.9",
|
||||
"version": "2.2.0",
|
||||
"description": "Allows you to download all Themes from BD's Website within Discord"
|
||||
},
|
||||
"changeLog": {
|
||||
"progress": {
|
||||
"New Style and Website Store": "The Repo now directly reflects the Themes hosted on <a>https://betterdiscord.app/</a> and uses a new Card Style"
|
||||
},
|
||||
"improved": {
|
||||
"Search String Cache": "Saves the Search Query for the Themes Repo until the Settings Window was closed",
|
||||
"Thumbnails": "Converted Thumbnail Gifs to PNGs to reduce the stress, GIFs play when you hover over the Thumbnail"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -70,7 +74,7 @@ module.exports = (_ => {
|
|||
var list, header, preview;
|
||||
|
||||
var loading, cachedThemes, grabbedThemes, generatorThemes, updateInterval;
|
||||
var searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
var searchString, searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
var updateGeneratorTimeout, forceRerenderGenerator, nativeCSS, nativeCSSvars;
|
||||
|
||||
var favorites = [];
|
||||
|
@ -150,9 +154,9 @@ module.exports = (_ => {
|
|||
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 (this.props.searchString) {
|
||||
let searchString = this.props.searchString.toUpperCase();
|
||||
themes = themes.filter(theme => theme.search.indexOf(searchString) > -1);
|
||||
if (searchString) {
|
||||
let usedSearchString = searchString.toUpperCase();
|
||||
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;
|
||||
|
@ -554,7 +558,7 @@ module.exports = (_ => {
|
|||
title: "Show following Themes",
|
||||
children: Object.keys(_this.defaults.filters).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
theme: this,
|
||||
plugin: this,
|
||||
keys: ["filters", key],
|
||||
label: _this.defaults.filters[key].description,
|
||||
value: _this.settings.filters[key],
|
||||
|
@ -566,7 +570,7 @@ module.exports = (_ => {
|
|||
}),
|
||||
Object.keys(_this.defaults.general).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||
type: "Switch",
|
||||
theme: this,
|
||||
plugin: this,
|
||||
keys: ["general", key],
|
||||
label: _this.defaults.general[key].description,
|
||||
note: key == "rnmStart" && !automaticLoading && "Automatic Loading has to be enabled",
|
||||
|
@ -650,7 +654,6 @@ module.exports = (_ => {
|
|||
|
||||
const RepoCardComponent = class ThemeCard extends BdApi.React.Component {
|
||||
render() {
|
||||
const thumbnailUrl = this.props.data.thumbnailUrl && `https://betterdiscord.app${this.props.data.thumbnailUrl}`;
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycard,
|
||||
children: [
|
||||
|
@ -660,11 +663,14 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardcoverwrapper,
|
||||
children: [
|
||||
thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
this.props.data.thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN.discoverycardcover,
|
||||
src: thumbnailUrl,
|
||||
src: this.props.data.thumbnailUrl,
|
||||
onMouseEnter: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailGifUrl),
|
||||
onMouseLeave: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailUrl),
|
||||
onClick: _ => {
|
||||
let img = document.createElement("img");
|
||||
const url = this.props.data.thumbnailGifUrl || this.props.data.thumbnailUrl;
|
||||
const img = document.createElement("img");
|
||||
img.addEventListener("load", function() {
|
||||
BDFDB.LibraryModules.ModalUtils.openModal(modalData => {
|
||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalRoot, Object.assign({
|
||||
|
@ -674,8 +680,8 @@ module.exports = (_ => {
|
|||
"aria-label": BDFDB.LanguageUtils.LanguageStrings.IMAGE,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ImageModal, {
|
||||
animated: false,
|
||||
src: thumbnailUrl,
|
||||
original: thumbnailUrl,
|
||||
src: url,
|
||||
original: url,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
className: BDFDB.disCN.imagemodalimage,
|
||||
|
@ -685,7 +691,7 @@ module.exports = (_ => {
|
|||
}), true);
|
||||
});
|
||||
});
|
||||
img.src = thumbnailUrl;
|
||||
img.src = url;
|
||||
}
|
||||
}),
|
||||
this.props.data.new && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.TextBadge, {
|
||||
|
@ -897,18 +903,18 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
|
||||
autoFocus: true,
|
||||
query: this.props.searchString,
|
||||
query: searchString,
|
||||
onChange: (value, instance) => {
|
||||
if (loading.is) return;
|
||||
BDFDB.TimeUtils.clear(searchTimeout);
|
||||
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
this.props.searchString = list.props.searchString = value.replace(/[<|>]/g, "");
|
||||
searchString = value.replace(/[<|>]/g, "");
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}, 1000);
|
||||
},
|
||||
onClear: instance => {
|
||||
if (loading.is) return;
|
||||
this.props.searchString = list.props.searchString = "";
|
||||
searchString = "";
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
|
@ -991,6 +997,7 @@ module.exports = (_ => {
|
|||
cachedThemes = [];
|
||||
grabbedThemes = [];
|
||||
generatorThemes = [];
|
||||
searchString = "";
|
||||
|
||||
this.defaults = {
|
||||
general: {
|
||||
|
@ -1007,7 +1014,7 @@ module.exports = (_ => {
|
|||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
SettingsView: "render"
|
||||
SettingsView: ["render", "componentWillUnmount"]
|
||||
},
|
||||
after: {
|
||||
StandardSidebarView: "render"
|
||||
|
@ -1152,7 +1159,8 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processSettingsView (e) {
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.sections) && e.instance.props.sections[0] && e.instance.props.sections[0].label == BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS) {
|
||||
if (e.node) searchString = "";
|
||||
else if (BDFDB.ArrayUtils.is(e.instance.props.sections) && e.instance.props.sections[0] && e.instance.props.sections[0].label == BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS) {
|
||||
e.instance.props.sections = e.instance.props.sections.filter(n => n.section != "themerepo");
|
||||
let index = e.instance.props.sections.indexOf(e.instance.props.sections.find(n => n.section == "pluginrepo") || e.instance.props.sections.find(n => n.section == "themes") || e.instance.props.sections.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.DEVELOPER_OPTIONS) || e.instance.props.sections.find(n => n.section == BDFDB.DiscordConstants.UserSettingsSections.HYPESQUAD_ONLINE));
|
||||
if (index > -1) {
|
||||
|
@ -1164,7 +1172,6 @@ module.exports = (_ => {
|
|||
options.updated = options.updated && !showOnlyOutdated;
|
||||
options.outdated = options.outdated || showOnlyOutdated;
|
||||
options.downloadable = options.downloadable && !showOnlyOutdated;
|
||||
options.searchString = "";
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
options.useLightMode = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
||||
|
@ -1186,7 +1193,6 @@ module.exports = (_ => {
|
|||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregionscroller]]});
|
||||
if (index > -1) {
|
||||
let options = {};
|
||||
options.searchString = "";
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
|
@ -1211,7 +1217,7 @@ module.exports = (_ => {
|
|||
let loadingIcon;
|
||||
let newEntries = 0, outdatedEntries = 0, checkIndex = 0, checksRunning = 0, callbackCalled = false;
|
||||
|
||||
const checkThemeVersion = _ => {
|
||||
const checkTheme = _ => {
|
||||
if (checksRunning > 20) return;
|
||||
else if (grabbedThemes.every(t => t.loaded || !t.latestSourceUrl) || !this.started || !loading.is) {
|
||||
if (!callbackCalled) {
|
||||
|
@ -1283,10 +1289,26 @@ module.exports = (_ => {
|
|||
else if (checkIndex > grabbedThemes.length) return;
|
||||
|
||||
const theme = grabbedThemes[checkIndex++];
|
||||
if (!theme || !theme.latestSourceUrl) checkThemeVersion();
|
||||
if (!theme || !theme.latestSourceUrl) checkTheme();
|
||||
else {
|
||||
checksRunning++;
|
||||
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.thumbnailUrl.startsWith("https://") ? theme.thumbnailUrl : `https://betterdiscord.app${theme.thumbnailUrl}`) : "";
|
||||
if (theme.thumbnailUrl) BDFDB.LibraryRequires.request({url: theme.thumbnailUrl, encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
let throwAwayImg = new Image();
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = theme.thumbnailUrl;
|
||||
theme.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
theme.thumbnailGifUrl = oldUrl;
|
||||
} catch(err) {}
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
});
|
||||
BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => {
|
||||
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 || "");
|
||||
|
@ -1326,7 +1348,7 @@ module.exports = (_ => {
|
|||
if (loadingTooltip) loadingTooltip.update(this.getLoadingTooltipText());
|
||||
|
||||
checksRunning--;
|
||||
checkThemeVersion();
|
||||
checkTheme();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1358,7 +1380,7 @@ module.exports = (_ => {
|
|||
|
||||
BDFDB.ReactUtils.forceUpdate(list, header);
|
||||
|
||||
for (let i = 0; i <= 20; i++) checkThemeVersion();
|
||||
for (let i = 0; i <= 20; i++) checkTheme();
|
||||
}
|
||||
catch (err) {BDFDB.NotificationUtils.toast("Failed to load Theme Store", {type: "danger"});}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue