update
This commit is contained in:
537
.config/BetterDiscord/plugins/PluginRepo.plugin.js
Executable file → Normal file
537
.config/BetterDiscord/plugins/PluginRepo.plugin.js
Executable file → Normal file
@@ -2,7 +2,7 @@
|
||||
* @name PluginRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.3.5
|
||||
* @version 2.4.0
|
||||
* @description Allows you to download all Plugins from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
@@ -13,20 +13,16 @@
|
||||
*/
|
||||
|
||||
module.exports = (_ => {
|
||||
const config = {
|
||||
"info": {
|
||||
"name": "PluginRepo",
|
||||
"author": "DevilBro",
|
||||
"version": "2.3.5",
|
||||
"description": "Allows you to download all Plugins from BD's Website within Discord"
|
||||
}
|
||||
const changeLog = {
|
||||
|
||||
};
|
||||
|
||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
||||
getName () {return config.info.name;}
|
||||
getAuthor () {return config.info.author;}
|
||||
getVersion () {return config.info.version;}
|
||||
getDescription () {return `The Library Plugin needed for ${config.info.name} is missing. Open the Plugin Settings to download it. \n\n${config.info.description}`;}
|
||||
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}`;}
|
||||
|
||||
downloadLibrary () {
|
||||
require("request").get("https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js", (e, r, b) => {
|
||||
@@ -39,7 +35,7 @@ module.exports = (_ => {
|
||||
if (!window.BDFDB_Global || !Array.isArray(window.BDFDB_Global.pluginQueue)) window.BDFDB_Global = Object.assign({}, window.BDFDB_Global, {pluginQueue: []});
|
||||
if (!window.BDFDB_Global.downloadModal) {
|
||||
window.BDFDB_Global.downloadModal = true;
|
||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${config.info.name} is missing. Please click "Download Now" to install it.`, {
|
||||
BdApi.showConfirmationModal("Library Missing", `The Library Plugin needed for ${this.name} is missing. Please click "Download Now" to install it.`, {
|
||||
confirmText: "Download Now",
|
||||
cancelText: "Cancel",
|
||||
onCancel: _ => {delete window.BDFDB_Global.downloadModal;},
|
||||
@@ -49,20 +45,20 @@ module.exports = (_ => {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (!window.BDFDB_Global.pluginQueue.includes(config.info.name)) window.BDFDB_Global.pluginQueue.push(config.info.name);
|
||||
if (!window.BDFDB_Global.pluginQueue.includes(this.name)) window.BDFDB_Global.pluginQueue.push(this.name);
|
||||
}
|
||||
start () {this.load();}
|
||||
stop () {}
|
||||
getSettingsPanel () {
|
||||
let template = document.createElement("template");
|
||||
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 ${config.info.name} is missing.\nPlease click <a style="font-weight: 500;">Download Now</a> to install it.</div>`;
|
||||
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>`;
|
||||
template.content.firstElementChild.querySelector("a").addEventListener("click", this.downloadLibrary);
|
||||
return template.content.firstElementChild;
|
||||
}
|
||||
} : (([Plugin, BDFDB]) => {
|
||||
var _this;
|
||||
|
||||
var list, header;
|
||||
var list;
|
||||
|
||||
var loading, cachedPlugins, grabbedPlugins, updateInterval;
|
||||
var searchString, searchTimeout, forcedSort, forcedOrder, showOnlyOutdated;
|
||||
@@ -153,113 +149,187 @@ module.exports = (_ => {
|
||||
render() {
|
||||
if (!this.props.tab) this.props.tab = "Plugins";
|
||||
|
||||
this.props.entries = (!loading.is && grabbedPlugins.length ? this.filterPlugins() : []).map(plugin => BDFDB.ReactUtils.createElement(RepoCardComponent, {
|
||||
data: plugin
|
||||
})).filter(n => n);
|
||||
const entries = (!loading.is && grabbedPlugins.length ? this.filterPlugins() : []);
|
||||
|
||||
BDFDB.TimeUtils.timeout(_ => {
|
||||
if (!loading.is && header && this.props.entries.length != header.props.amount) {
|
||||
header.props.amount = this.props.entries.length;
|
||||
BDFDB.ReactUtils.forceUpdate(header);
|
||||
}
|
||||
});
|
||||
|
||||
return [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
|
||||
tab: "Plugins",
|
||||
open: this.props.tab == "Plugins",
|
||||
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%"},
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repo,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCNS._repolistheader + BDFDB.disCN.settingswindowcontentcolumndefault,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Spinner, {
|
||||
type: BDFDB.LibraryComponents.Spinner.Type.WANDERING_CUBES
|
||||
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, {
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H1,
|
||||
className: BDFDB.disCN.marginreset,
|
||||
children: `Plugin Repo — ${loading.is ? 0 : entries.length || 0}/${loading.is ? 0 : grabbedPlugins.length}`
|
||||
})
|
||||
}),
|
||||
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};
|
||||
_this.loadPlugins();
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TextElement, {
|
||||
className: BDFDB.disCN.margintop20,
|
||||
style: {textAlign: "center"},
|
||||
children: `${BDFDB.LanguageUtils.LibraryStringsFormat("loading", "Plugin Repo")} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`
|
||||
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: "Plugins"}, {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);
|
||||
}
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Scrollers.Auto, {
|
||||
className: BDFDB.disCNS._repolistscroller + BDFDB.disCN.settingswindowcontentcolumndefault,
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ModalComponents.ModalTabContent, {
|
||||
tab: "Plugins",
|
||||
open: this.props.tab == "Plugins",
|
||||
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", "Plugin Repo")} - ${BDFDB.LanguageUtils.LibraryStrings.please_wait}`
|
||||
})
|
||||
]
|
||||
}) : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycards,
|
||||
children: entries.map(plugin => BDFDB.ReactUtils.createElement(RepoCardComponent, {
|
||||
data: plugin
|
||||
})).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, {
|
||||
title: "Show following Plugins",
|
||||
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],
|
||||
onChange: value => {
|
||||
this.props[key] = _this.settings.filters[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
}))
|
||||
}),
|
||||
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)
|
||||
})
|
||||
]
|
||||
}) : BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycards,
|
||||
children: this.props.entries
|
||||
})
|
||||
}),
|
||||
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, {
|
||||
title: "Show following Plugins",
|
||||
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],
|
||||
onChange: value => {
|
||||
this.props[key] = _this.settings.filters[key] = value;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
}))
|
||||
}),
|
||||
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)
|
||||
})
|
||||
];
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const RepoCardComponent = class PluginCard extends BdApi.React.Component {
|
||||
render() {
|
||||
if (this.props.data.thumbnailUrl && !this.props.data.thumbnailChecked) {
|
||||
if (!window.Buffer) this.props.data.thumbnailChecked = true;
|
||||
else BDFDB.LibraryRequires.request(this.props.data.thumbnailUrl, {encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
const throwAwayImg = new Image(), instance = this;
|
||||
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 = instance.props.data.thumbnailUrl;
|
||||
instance.props.data.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
instance.props.data.thumbnailGifUrl = oldUrl;
|
||||
instance.props.data.thumbnailChecked = true;
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
}
|
||||
catch (err) {
|
||||
instance.props.data.thumbnailChecked = true;
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
}
|
||||
};
|
||||
throwAwayImg.onerror = function() {
|
||||
instance.props.data.thumbnailChecked = true;
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
else {
|
||||
this.props.data.thumbnailChecked = true;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycard,
|
||||
onMouseEnter: _ => {
|
||||
this.props.hovered = true;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
},
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardheader,
|
||||
@@ -267,34 +337,29 @@ module.exports = (_ => {
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardcoverwrapper,
|
||||
children: [
|
||||
this.props.data.thumbnailUrl && this.props.data.thumbnailChecked && BDFDB.ReactUtils.createElement("img", {
|
||||
this.props.data.thumbnailUrl && this.props.hovered && BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN.discoverycardcover,
|
||||
src: this.props.data.thumbnailUrl,
|
||||
loading: "lazy",
|
||||
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: _ => {
|
||||
const url = this.props.data.thumbnailGifUrl || this.props.data.thumbnailUrl;
|
||||
const url = 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({
|
||||
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);
|
||||
});
|
||||
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));
|
||||
});
|
||||
img.src = url;
|
||||
}
|
||||
@@ -310,32 +375,16 @@ module.exports = (_ => {
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(class extends BDFDB.ReactUtils.Component {
|
||||
render() {
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardiconwrapper,
|
||||
children: this.props.data.author && this.props.data.author.discord_avatar_hash && this.props.data.author.discord_snowflake && !this.props.data.author.discord_avatar_failed ? BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.discoverycardicon, !this.props.data.author.discord_avatar_loaded && BDFDB.disCN.discoverycardiconloading),
|
||||
src: `https://cdn.discordapp.com/avatars/${this.props.data.author.discord_snowflake}/${this.props.data.author.discord_avatar_hash}.webp?size=128`,
|
||||
loading: "lazy",
|
||||
onLoad: _ => {
|
||||
this.props.data.author.discord_avatar_loaded = true;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
},
|
||||
onError: _ => {
|
||||
this.props.data.author.discord_avatar_failed = true;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
}) : 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="${BDFDB.ArrayUtils.is(this.props.data.tags) && this.props.data.tags.includes("library") ? "m 7.3125,2.625 c -0.3238672,0 -0.5859375,0.2620703 -0.5859375,0.5859375 V 14.929687 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 2.710313,0 3.840547,1.498711 4.101563,1.914062 V 3.9905599 C 10.603047,3.3127865 9.3007813,2.625 7.3125,2.625 Z M 4.96875,3.796875 c -0.3238672,0 -0.5859375,0.2620703 -0.5859375,0.5859375 V 17.273437 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 h 5.30599 C 9.9465755,17.461602 9.0865625,16.6875 7.3125,16.6875 c -0.9692969,0 -1.7578125,-0.788516 -1.7578125,-1.757813 V 3.796875 Z m 9.375,0 c -0.662031,0 -1.266641,0.2287891 -1.757812,0.6005859 V 18.445312 c 0,-0.323281 0.262656,-0.585937 0.585937,-0.585937 h 5.859375 c 0.323868,0 0.585937,-0.26207 0.585937,-0.585938 V 4.3828125 c 0,-0.3238672 -0.262069,-0.5859375 -0.585937,-0.5859375 z M 2.5859375,4.96875 C 2.2620703,4.96875 2,5.2308203 2,5.5546875 V 19.617187 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 H 9.171224 c 0.2420313,0.68207 0.892995,1.171875 1.656901,1.171875 h 2.34375 c 0.763906,0 1.414831,-0.489805 1.656901,-1.171875 h 6.585286 C 21.73793,20.203125 22,19.941055 22,19.617187 V 5.5546875 C 22,5.2308203 21.73793,4.96875 21.414062,4.96875 h -0.585937 v 12.304687 c 0,0.969297 -0.827578,1.757813 -1.796875,1.757813 H 13.656901 C 13.41487,19.71332 12.763907,20.203125 12,20.203125 c -0.763906,0 -1.414831,-0.489805 -1.656901,-1.171875 H 4.96875 c -0.9692968,0 -1.796875,-0.788516 -1.796875,-1.757813 V 4.96875 Z" : "m 11.470703,0.625 c -1.314284,0 -2.3808593,1.0666594 -2.3808592,2.3808594 V 4.4335938 H 5.2792969 c -1.0476168,0 -1.8945313,0.85855 -1.8945313,1.90625 v 3.6191406 h 1.4179688 c 1.41905,0 2.5722656,1.1512126 2.5722656,2.5703126 0,1.4191 -1.1532156,2.572266 -2.5722656,2.572265 H 3.375 v 3.619141 c 0,1.0477 0.8566801,1.904297 1.9042969,1.904297 h 3.6191406 v -1.427734 c 0,-1.4189 1.1532235,-2.572266 2.5722655,-2.572266 1.41905,0 2.570313,1.153366 2.570313,2.572266 V 20.625 h 3.61914 c 1.047626,0 1.90625,-0.856597 1.90625,-1.904297 v -3.810547 h 1.427735 c 1.314292,0 2.380859,-1.066559 2.380859,-2.380859 0,-1.3143 -1.066567,-2.38086 -2.380859,-2.380859 H 19.566406 V 6.3398438 c 0,-1.0477002 -0.858624,-1.90625 -1.90625,-1.90625 H 13.851562 V 3.0058594 c 0,-1.3142 -1.066568,-2.3808594 -2.380859,-2.3808594 z"}"/></svg>`
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
}, this.props)
|
||||
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="${BDFDB.ArrayUtils.is(this.props.data.tags) && this.props.data.tags.includes("library") ? "m 7.3125,2.625 c -0.3238672,0 -0.5859375,0.2620703 -0.5859375,0.5859375 V 14.929687 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 2.710313,0 3.840547,1.498711 4.101563,1.914062 V 3.9905599 C 10.603047,3.3127865 9.3007813,2.625 7.3125,2.625 Z M 4.96875,3.796875 c -0.3238672,0 -0.5859375,0.2620703 -0.5859375,0.5859375 V 17.273437 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 h 5.30599 C 9.9465755,17.461602 9.0865625,16.6875 7.3125,16.6875 c -0.9692969,0 -1.7578125,-0.788516 -1.7578125,-1.757813 V 3.796875 Z m 9.375,0 c -0.662031,0 -1.266641,0.2287891 -1.757812,0.6005859 V 18.445312 c 0,-0.323281 0.262656,-0.585937 0.585937,-0.585937 h 5.859375 c 0.323868,0 0.585937,-0.26207 0.585937,-0.585938 V 4.3828125 c 0,-0.3238672 -0.262069,-0.5859375 -0.585937,-0.5859375 z M 2.5859375,4.96875 C 2.2620703,4.96875 2,5.2308203 2,5.5546875 V 19.617187 c 0,0.323868 0.2620703,0.585938 0.5859375,0.585938 H 9.171224 c 0.2420313,0.68207 0.892995,1.171875 1.656901,1.171875 h 2.34375 c 0.763906,0 1.414831,-0.489805 1.656901,-1.171875 h 6.585286 C 21.73793,20.203125 22,19.941055 22,19.617187 V 5.5546875 C 22,5.2308203 21.73793,4.96875 21.414062,4.96875 h -0.585937 v 12.304687 c 0,0.969297 -0.827578,1.757813 -1.796875,1.757813 H 13.656901 C 13.41487,19.71332 12.763907,20.203125 12,20.203125 c -0.763906,0 -1.414831,-0.489805 -1.656901,-1.171875 H 4.96875 c -0.9692968,0 -1.796875,-0.788516 -1.796875,-1.757813 V 4.96875 Z" : "m 11.470703,0.625 c -1.314284,0 -2.3808593,1.0666594 -2.3808592,2.3808594 V 4.4335938 H 5.2792969 c -1.0476168,0 -1.8945313,0.85855 -1.8945313,1.90625 v 3.6191406 h 1.4179688 c 1.41905,0 2.5722656,1.1512126 2.5722656,2.5703126 0,1.4191 -1.1532156,2.572266 -2.5722656,2.572265 H 3.375 v 3.619141 c 0,1.0477 0.8566801,1.904297 1.9042969,1.904297 h 3.6191406 v -1.427734 c 0,-1.4189 1.1532235,-2.572266 2.5722655,-2.572266 1.41905,0 2.570313,1.153366 2.570313,2.572266 V 20.625 h 3.61914 c 1.047626,0 1.90625,-0.856597 1.90625,-1.904297 v -3.810547 h 1.427735 c 1.314292,0 2.380859,-1.066559 2.380859,-2.380859 0,-1.3143 -1.066567,-2.38086 -2.380859,-2.380859 H 19.566406 V 6.3398438 c 0,-1.0477002 -0.858624,-1.90625 -1.90625,-1.90625 H 13.851562 V 3.0058594 c 0,-1.3142 -1.066568,-2.3808594 -2.380859,-2.3808594 z"}"/></svg>`
|
||||
})
|
||||
})
|
||||
})
|
||||
]
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
@@ -463,15 +512,11 @@ module.exports = (_ => {
|
||||
onDelete: _ => {
|
||||
if (this.props.deleting) return;
|
||||
this.props.deleting = true;
|
||||
BDFDB.LibraryRequires.fs.unlink(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()), error => {
|
||||
delete this.props.deleting;
|
||||
if (error) BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_fail", `Plugin "${this.props.data.name}"`), {type: "danger"});
|
||||
else {
|
||||
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_success", `Plugin "${this.props.data.name}"`));
|
||||
this.props.data.state = pluginStates.DOWNLOADABLE;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
});
|
||||
BDFDB.LibraryRequires.fs.unlinkSync(BDFDB.LibraryRequires.path.join(BDFDB.BDUtils.getPluginsFolder(), this.props.data.rawSourceUrl.split("/").pop()));
|
||||
delete this.props.deleting;
|
||||
BDFDB.NotificationUtils.toast(BDFDB.LanguageUtils.LibraryStringsFormat("delete_success", `Plugin "${this.props.data.name}"`));
|
||||
this.props.data.state = pluginStates.DOWNLOADABLE;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}
|
||||
})
|
||||
]
|
||||
@@ -521,116 +566,6 @@ module.exports = (_ => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const RepoListHeaderComponent = class PluginListHeader extends BdApi.React.Component {
|
||||
componentDidMount() {
|
||||
header = this;
|
||||
}
|
||||
render() {
|
||||
if (!this.props.tab) this.props.tab = "Plugins";
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN._repolistheader,
|
||||
children: [
|
||||
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, {
|
||||
tag: BDFDB.LibraryComponents.FormComponents.FormTitle.Tags.H2,
|
||||
className: BDFDB.disCN.marginreset,
|
||||
children: `Plugin Repo — ${loading.is ? 0 : this.props.amount || 0}/${loading.is ? 0 : grabbedPlugins.length}`
|
||||
})
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex.Child, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SearchBar, {
|
||||
autoFocus: true,
|
||||
query: searchString,
|
||||
onChange: (value, instance) => {
|
||||
if (loading.is) return;
|
||||
BDFDB.TimeUtils.clear(searchTimeout);
|
||||
searchTimeout = BDFDB.TimeUtils.timeout(_ => {
|
||||
searchString = value.replace(/[<|>]/g, "");
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}, 1000);
|
||||
},
|
||||
onClear: instance => {
|
||||
if (loading.is) return;
|
||||
searchString = "";
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
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};
|
||||
_this.loadPlugins();
|
||||
}
|
||||
})
|
||||
]
|
||||
}),
|
||||
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: "Plugins"}, {value: BDFDB.LanguageUtils.LanguageStrings.SETTINGS}],
|
||||
onItemSelect: value => {
|
||||
this.props.tab = list.props.tab = value;
|
||||
BDFDB.ReactUtils.forceUpdate(list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
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 = list.props.sortKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
}),
|
||||
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 = list.props.orderKey = key;
|
||||
BDFDB.ReactUtils.forceUpdate(this, list);
|
||||
}
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return class PluginRepo extends Plugin {
|
||||
onLoad () {
|
||||
@@ -656,13 +591,14 @@ module.exports = (_ => {
|
||||
}
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
SettingsView: ["render", "componentWillUnmount"]
|
||||
},
|
||||
after: {
|
||||
StandardSidebarView: "render"
|
||||
}
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"SettingsView",
|
||||
"StandardSidebarView"
|
||||
],
|
||||
componentWillUnmount: [
|
||||
"SettingsView"
|
||||
]
|
||||
};
|
||||
|
||||
}
|
||||
@@ -713,13 +649,14 @@ module.exports = (_ => {
|
||||
|
||||
processSettingsView (e) {
|
||||
if (e.node) searchString = "";
|
||||
else {
|
||||
if (!BDFDB.PatchUtils.isPatched(this, e.component, "getPredicateSections")) BDFDB.PatchUtils.patch(this, e.component, "getPredicateSections", {after: e2 => {
|
||||
else if (e.component.prototype && !BDFDB.PatchUtils.isPatched(this, e.component.prototype, "getPredicateSections")) {
|
||||
BDFDB.PatchUtils.patch(this, e.component.prototype, "getPredicateSections", {after: e2 => {
|
||||
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 != "pluginrepo");
|
||||
let index = e2.returnValue.indexOf(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, {
|
||||
className: "pluginrepo-tab",
|
||||
section: "pluginrepo",
|
||||
label: "Plugin Repo",
|
||||
element: _ => {
|
||||
@@ -741,20 +678,7 @@ module.exports = (_ => {
|
||||
}
|
||||
|
||||
processStandardSidebarView (e) {
|
||||
if (e.instance.props.section == "pluginrepo") {
|
||||
let content = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregion]]});
|
||||
if (content) content.props.className = BDFDB.DOMUtils.formatClassName(BDFDB.disCN._repolistwrapper, content.props.className);
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.settingswindowcontentregionscroller]]});
|
||||
if (index > -1) {
|
||||
let options = {};
|
||||
options.sortKey = forcedSort || Object.keys(sortKeys)[0];
|
||||
options.orderKey = forcedOrder || Object.keys(orderKeys)[0];
|
||||
children[index] = [
|
||||
BDFDB.ReactUtils.createElement(RepoListHeaderComponent, options, true),
|
||||
children[index]
|
||||
];
|
||||
}
|
||||
}
|
||||
if (e.instance.props.section == "pluginrepo") e.instance.props.contentType = "custom";
|
||||
}
|
||||
|
||||
loadPlugins () {
|
||||
@@ -833,9 +757,10 @@ module.exports = (_ => {
|
||||
delete plugin.thumbnail_url;
|
||||
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+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || "");
|
||||
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 META = body.split("*/")[0];
|
||||
plugin.name = BDFDB.StringUtils.upperCaseFirstChar((/@name\s+([^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.name || "");
|
||||
plugin.authorname = (/@author\s+(.+)|\/\/\**META.*["']author["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1] || plugin.author.display_name || plugin.author;
|
||||
const version = (/@version\s+(.+)|\/\/\**META.*["']version["']\s*:\s*["'](.+?)["']/i.exec(META) || []).filter(n => n)[1];
|
||||
if (version) {
|
||||
plugin.version = version;
|
||||
const installedPlugin = this.getInstalledPlugin(plugin);
|
||||
@@ -880,7 +805,7 @@ module.exports = (_ => {
|
||||
});
|
||||
BDFDB.PluginUtils.addLoadingIcon(loadingIcon);
|
||||
|
||||
BDFDB.ReactUtils.forceUpdate(list, header);
|
||||
BDFDB.ReactUtils.forceUpdate(list);
|
||||
|
||||
for (let i = 0; i <= 20; i++) checkPlugin();
|
||||
}
|
||||
@@ -1124,5 +1049,5 @@ module.exports = (_ => {
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user