Update 0BDFDB.plugin.js
This commit is contained in:
parent
4ef163b5dd
commit
6c262aa908
|
@ -7263,9 +7263,20 @@ module.exports = (_ => {
|
||||||
}
|
}
|
||||||
BDFDB.LibraryComponents = Object.assign({}, InternalComponents.LibraryComponents);
|
BDFDB.LibraryComponents = Object.assign({}, InternalComponents.LibraryComponents);
|
||||||
|
|
||||||
InternalBDFDB.createCustomControl = function (reactChild) {
|
InternalBDFDB.createCustomControl = function (data, beta) {
|
||||||
let controlButton = BDFDB.DOMUtils.create(`<div class="${BDFDB.disCN._repocontrolsbutton}"></div>`);
|
let child = BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
|
||||||
BDFDB.ReactUtils.render(reactChild, controlButton);
|
className: !beta && BDFDB.disCN._repoicon,
|
||||||
|
nativeClass: true,
|
||||||
|
name: data.svgName,
|
||||||
|
width: beta ? "20" : "24",
|
||||||
|
height: beta ? "20" : "24"
|
||||||
|
})
|
||||||
|
let controlButton = BDFDB.DOMUtils.create(`<${beta ? "button" : "div"} class="${BDFDB.DOMUtils.formatClassName(beta && BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton)}"></${beta ? "button" : "div"}>`);
|
||||||
|
BDFDB.ReactUtils.render(data.tooltipText ? BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
||||||
|
text: data.tooltipText,
|
||||||
|
children: child
|
||||||
|
}) : child, controlButton);
|
||||||
|
controlButton.addEventListener("click", _ => {if (typeof data.onClick == "function") data.onClick();});
|
||||||
return controlButton;
|
return controlButton;
|
||||||
};
|
};
|
||||||
InternalBDFDB.appendCustomControls = function (card) {
|
InternalBDFDB.appendCustomControls = function (card) {
|
||||||
|
@ -7277,23 +7288,19 @@ module.exports = (_ => {
|
||||||
props.hasCustomControls = true;
|
props.hasCustomControls = true;
|
||||||
let url = plugin.rawUrl ||`https://mwittrien.github.io/BetterDiscordAddons/Plugins/${plugin.name}/${plugin.name}.plugin.js`;
|
let url = plugin.rawUrl ||`https://mwittrien.github.io/BetterDiscordAddons/Plugins/${plugin.name}/${plugin.name}.plugin.js`;
|
||||||
let controls = [];
|
let controls = [];
|
||||||
if (plugin.changeLog) controls.push(InternalBDFDB.createCustomControl(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
let footerControls = card.querySelector("." + BDFDB.disCN._repofooter.split(" ")[0] + " ." + BDFDB.disCN._repocontrols.split(" ")[0]);
|
||||||
text: BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG,
|
if (plugin.changeLog) controls.push(InternalBDFDB.createCustomControl({
|
||||||
children: BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
|
tooltipText: BDFDB.LanguageUtils.LanguageStrings.CHANGE_LOG,
|
||||||
className: BDFDB.disCN._repoicon,
|
svgName: InternalComponents.LibraryComponents.SvgIcon.Names.CHANGELOG,
|
||||||
name: InternalComponents.LibraryComponents.SvgIcon.Names.CHANGELOG,
|
onClick: _ => {BDFDB.PluginUtils.openChangeLog(plugin);}
|
||||||
onClick: _ => {BDFDB.PluginUtils.openChangeLog(plugin);}
|
}, !!footerControls));
|
||||||
})
|
if (window.PluginUpdates && window.PluginUpdates.plugins && window.PluginUpdates.plugins[url] && window.PluginUpdates.plugins[url].outdated) controls.push(InternalBDFDB.createCustomControl({
|
||||||
})));
|
tooltipText: BDFDB.LanguageUtils.LanguageStrings.UPDATE_MANUALLY,
|
||||||
if (window.PluginUpdates && window.PluginUpdates.plugins && window.PluginUpdates.plugins[url] && window.PluginUpdates.plugins[url].outdated) controls.push(InternalBDFDB.createCustomControl(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.TooltipContainer, {
|
svgName: InternalComponents.LibraryComponents.SvgIcon.Names.DOWNLOAD,
|
||||||
text: BDFDB.LanguageUtils.LanguageStrings.UPDATE_MANUALLY,
|
onClick: _ => {BDFDB.PluginUtils.downloadUpdate(plugin.name, url);}
|
||||||
children: BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
|
}, !!footerControls));
|
||||||
className: BDFDB.disCN._repoicon,
|
if (footerControls) for (let control of controls) footerControls.insertBefore(control, footerControls.firstElementChild);
|
||||||
name: InternalComponents.LibraryComponents.SvgIcon.Names.DOWNLOAD,
|
else for (let control of controls) checkbox.parentElement.insertBefore(control, checkbox.parentElement.firstElementChild);
|
||||||
onClick: _ => {BDFDB.PluginUtils.downloadUpdate(plugin.name, url);}
|
|
||||||
})
|
|
||||||
})));
|
|
||||||
for (let control of controls) checkbox.parentElement.insertBefore(control, checkbox.parentElement.firstElementChild);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const cardObserver = (new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
|
const cardObserver = (new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
|
||||||
|
|
Loading…
Reference in New Issue