minor fixes
This commit is contained in:
parent
ded3f96b07
commit
097c2687fb
18
js/main.js
18
js/main.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
11
src/index.js
11
src/index.js
|
@ -4,9 +4,18 @@ localStorageFix();
|
|||
loadingIcon();
|
||||
|
||||
const deprecateGlobal = (key, value) => {
|
||||
// value = typeof(value) !== "object" ? value : new Proxy(value, {
|
||||
// get: function(obj, mod) {
|
||||
// if (!obj.hasOwnProperty(mod)) return undefined;
|
||||
// return obj[mod];
|
||||
// },
|
||||
// set: function(obj, mod) {
|
||||
// if (obj.hasOwnProperty(mod)) return Utils.err("Deprecated Global", "Trying to overwrite deprecated BD globals");
|
||||
// }
|
||||
// });
|
||||
Object.defineProperty(window, key, {
|
||||
get() {
|
||||
Utils.warn("Deprecation Notice", `"${key}" will be removed in future versions. Please only use BdApi.`);
|
||||
Utils.warn("Deprecated Global", `"${key}" will be removed in future versions. Please only use BdApi.`);
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -185,36 +185,38 @@ Core.prototype.patchSocial = function() {
|
|||
if (this.socialPatch) return;
|
||||
const TabBar = WebpackModules.find(m => m.displayName == "TabBar");
|
||||
const Anchor = WebpackModules.find(m => m.displayName == "Anchor");
|
||||
if (!TabBar || !Anchor) return;
|
||||
if (!TabBar) return;
|
||||
this.socialPatch = Utils.monkeyPatch(TabBar.prototype, "render", {after: (data) => {
|
||||
const children = data.returnValue.props.children;
|
||||
if (!children || !children.length || children.length < 3) return;
|
||||
if (children[children.length - 3].type.displayName !== "Separator") return;
|
||||
if (!children[children.length - 2].type.toString().includes("socialLinks")) return;
|
||||
const original = children[children.length - 2].type;
|
||||
const newOne = function() {
|
||||
const returnVal = original(...arguments);
|
||||
returnVal.props.children.push(
|
||||
BDV2.React.createElement(TooltipWrap, {color: "black", side: "top", text: "BandagedBD"},
|
||||
BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", title: "BandagedBD", target: "_blank"},
|
||||
BDV2.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
|
||||
if (Anchor) {
|
||||
const original = children[children.length - 2].type;
|
||||
const newOne = function() {
|
||||
const returnVal = original(...arguments);
|
||||
returnVal.props.children.push(
|
||||
BDV2.React.createElement(TooltipWrap, {color: "black", side: "top", text: "BandagedBD"},
|
||||
BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", title: "BandagedBD", target: "_blank"},
|
||||
BDV2.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return returnVal;
|
||||
};
|
||||
children[children.length - 2].type = newOne;
|
||||
);
|
||||
return returnVal;
|
||||
};
|
||||
children[children.length - 2].type = newOne;
|
||||
}
|
||||
|
||||
const BBDLink = BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://twitter.com/BandagedBD", title: "BandagedBD", target: "_blank"}, "BandagedBD");
|
||||
const AuthorLink = BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://twitter.com/ZackRauen", title: "Zerebos", target: "_blank"}, "Zerebos");
|
||||
const additional = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, [BBDLink, ` ${bbdVersion} by `, AuthorLink]);
|
||||
const injector = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, ["BBD Injector", ` ${bdConfig.version} by `, AuthorLink]);
|
||||
const injector = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, `Injector ${bdConfig.version}`);
|
||||
const versionHash = `(${bdConfig.hash ? bdConfig.hash.substring(0, 7) : bdConfig.branch})`;
|
||||
const additional = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, `BBD ${bbdVersion} `, BDV2.react.createElement("span", {className: "versionHash-2gXjIB da-versionHash"}, versionHash));
|
||||
|
||||
|
||||
const originalVersions = children[children.length - 1].type;
|
||||
children[children.length - 1].type = function() {
|
||||
const returnVal = originalVersions(...arguments);
|
||||
returnVal.props.children.push(injector);
|
||||
returnVal.props.children.push(additional);
|
||||
returnVal.props.children.splice(returnVal.props.children.length - 1, 0, injector);
|
||||
returnVal.props.children.splice(1, 0, additional);
|
||||
return returnVal;
|
||||
};
|
||||
}});
|
||||
|
|
|
@ -22,7 +22,14 @@ PluginModule.prototype.loadPlugins = function () {
|
|||
plugin = bdplugins[plugins[i]].plugin;
|
||||
name = plugin.getName();
|
||||
if (plugin.load && typeof(plugin.load) == "function") plugin.load();
|
||||
const meta = bdplugins[plugins[i]];
|
||||
let meta = bdplugins[plugins[i]];
|
||||
|
||||
// Because DiscordCrypt is freezing bd globals they shouldn't be accessing.
|
||||
if (Object.isFrozen(meta)) {
|
||||
meta = Object.assign({}, meta);
|
||||
delete bdplugins[plugins[i]];
|
||||
bdplugins[plugins[i]] = meta;
|
||||
}
|
||||
meta.name = this.getString(plugin.getName());
|
||||
meta.author = this.getString(plugin.getAuthor());
|
||||
meta.description = this.getString(plugin.getDescription());
|
||||
|
|
|
@ -31,8 +31,8 @@ export default new class V2_SettingsPanel {
|
|||
this.onChange = this.onChange.bind(this);
|
||||
this.updateSettings = this.updateSettings.bind(this);
|
||||
this.sidebar = new V2_SettingsPanel_Sidebar(this.sideBarOnClick);
|
||||
this.buildPluginProps = this.buildPluginProps.bind(this);
|
||||
this.buildThemeProps = this.buildThemeProps.bind(this);
|
||||
// this.buildPluginProps = this.buildPluginProps.bind(this);
|
||||
// this.buildThemeProps = this.buildThemeProps.bind(this);
|
||||
this.showOriginal = this.showOriginal.bind(this);
|
||||
}
|
||||
|
||||
|
@ -93,10 +93,8 @@ export default new class V2_SettingsPanel {
|
|||
this.renderCustomCssEditor();
|
||||
break;
|
||||
case "plugins":
|
||||
this.renderPluginPane();
|
||||
break;
|
||||
case "themes":
|
||||
this.renderThemePane();
|
||||
this.renderAddonPane(id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -164,11 +162,6 @@ export default new class V2_SettingsPanel {
|
|||
else Utils.setWindowPreference("backgroundColor", "#2f3136");
|
||||
}
|
||||
|
||||
/*if (_c["fork-wp-2"]) {
|
||||
const current = BdApi.getWindowPreference("frame");
|
||||
if (current != _c["fork-wp-2"]) BdApi.setWindowPreference("frame", _c["fork-wp-2"]);
|
||||
}*/
|
||||
|
||||
|
||||
if (id == "bda-gs-8") {
|
||||
if (enabled) dMode.startDebugListener();
|
||||
|
@ -258,110 +251,62 @@ export default new class V2_SettingsPanel {
|
|||
);
|
||||
}
|
||||
|
||||
contentComponent(type) {
|
||||
const componentElement = this.getAddonList(type);
|
||||
const prefix = type.replace("s", "");
|
||||
const settingsList = this;
|
||||
class ContentList extends BDV2.react.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.onChange = this.onChange.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
BDEvents.on(`${prefix}-reloaded`, this.onChange);
|
||||
BDEvents.on(`${prefix}-loaded`, this.onChange);
|
||||
BDEvents.on(`${prefix}-unloaded`, this.onChange);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
BDEvents.off(`${prefix}-reloaded`, this.onChange);
|
||||
BDEvents.off(`${prefix}-loaded`, this.onChange);
|
||||
BDEvents.off(`${prefix}-unloaded`, this.onChange);
|
||||
}
|
||||
|
||||
onChange() {
|
||||
settingsList.sideBarOnClick(type);
|
||||
}
|
||||
|
||||
render() {return componentElement;}
|
||||
}
|
||||
return BDV2.react.createElement(ContentList);
|
||||
}
|
||||
|
||||
getString(value) {
|
||||
if (!value) return "???";
|
||||
return typeof value == "string" ? value : value.toString();
|
||||
}
|
||||
|
||||
buildPluginProps(meta) {
|
||||
const plugin = meta.plugin;
|
||||
return Object.assign({}, meta, {
|
||||
name: this.getString(plugin.getName()),
|
||||
author: this.getString(plugin.getAuthor()),
|
||||
description: this.getString(plugin.getDescription()),
|
||||
version: this.getString(plugin.getVersion()),
|
||||
getSettingsPanel: plugin.getSettingsPanel && plugin.getSettingsPanel.bind(plugin)
|
||||
});
|
||||
}
|
||||
|
||||
buildThemeProps(meta) {
|
||||
return Object.assign({}, meta, {
|
||||
name: this.getString(meta.name),
|
||||
author: this.getString(meta.author),
|
||||
description: this.getString(meta.description),
|
||||
version: this.getString(meta.version)
|
||||
});
|
||||
}
|
||||
|
||||
getAddonList(type) {
|
||||
const isPlugins = type === "plugins";
|
||||
const list = isPlugins ? Object.values(bdplugins) : Object.values(bdthemes);
|
||||
return BDV2.react.createElement(CardList, {type, list});
|
||||
}
|
||||
|
||||
renderCoreSettings() {
|
||||
const root = this.root;
|
||||
if (!root) {
|
||||
console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
return;
|
||||
}
|
||||
if (!root) return Utils.err("SettingsPanel", "FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
BDV2.reactDom.render(this.coreComponent, root);
|
||||
}
|
||||
|
||||
renderEmoteSettings() {
|
||||
const root = this.root;
|
||||
if (!root) {
|
||||
console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
return;
|
||||
}
|
||||
if (!root) return Utils.err("SettingsPanel", "FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
BDV2.reactDom.render(this.emoteComponent, root);
|
||||
}
|
||||
|
||||
renderCustomCssEditor() {
|
||||
const root = this.root;
|
||||
if (!root) {
|
||||
console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
return;
|
||||
}
|
||||
if (!root) return Utils.err("SettingsPanel", "FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
BDV2.reactDom.render(this.customCssComponent, root);
|
||||
}
|
||||
|
||||
renderPluginPane() {
|
||||
const root = this.root;
|
||||
if (!root) {
|
||||
console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
return;
|
||||
}
|
||||
BDV2.reactDom.render(this.contentComponent("plugins"), root);
|
||||
}
|
||||
// renderAddonPane(type) {
|
||||
// const root = this.root;
|
||||
// if (!root) return Utils.err("SettingsPanel", "FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
// BDV2.reactDom.render(this.contentComponent(type), root);
|
||||
// }
|
||||
|
||||
renderThemePane() {
|
||||
const root = this.root;
|
||||
if (!root) {
|
||||
console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
return;
|
||||
renderAddonPane(type) {
|
||||
if (!this.root) return Utils.err("SettingsPanel", "FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i");
|
||||
// I know this shouldn't be here, but when it isn't,
|
||||
// React refuses to change the button when going
|
||||
// between plugins and themes page... something
|
||||
// to debug later.
|
||||
class ContentList extends BDV2.react.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.prefix = this.props.type.replace("s", "");
|
||||
this.onChange = this.onChange.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
BDEvents.on(`${this.prefix}-reloaded`, this.onChange);
|
||||
BDEvents.on(`${this.prefix}-loaded`, this.onChange);
|
||||
BDEvents.on(`${this.prefix}-unloaded`, this.onChange);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
BDEvents.off(`${this.prefix}-reloaded`, this.onChange);
|
||||
BDEvents.off(`${this.prefix}-loaded`, this.onChange);
|
||||
BDEvents.off(`${this.prefix}-unloaded`, this.onChange);
|
||||
}
|
||||
|
||||
onChange() {
|
||||
this.props.onChange(this.props.type);
|
||||
}
|
||||
|
||||
render() {return this.props.children;}
|
||||
}
|
||||
BDV2.reactDom.render(this.contentComponent("themes"), root);
|
||||
const list = type === "plugins" ? Object.values(bdplugins) : Object.values(bdthemes);
|
||||
return BDV2.reactDom.render(BDV2.react.createElement(ContentList, {type, onChange: this.sideBarOnClick}, BDV2.react.createElement(CardList, {type, list})), this.root);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -187,15 +187,20 @@ export default class Utils {
|
|||
* @param {number} options.timeout Adjusts the time (in ms) the toast should be shown for before disappearing automatically. Default: 3000
|
||||
*/
|
||||
static showToast(content, options = {}) {
|
||||
// if (!bdConfig.deferLoaded) return;
|
||||
if (!document.querySelector(".bd-toasts")) {
|
||||
const container = document.querySelector(".sidebar-2K8pFh + div") || null;
|
||||
const memberlist = container ? container.querySelector(".membersWrap-2h-GB4") : null;
|
||||
const form = container ? container.querySelector("form") : null;
|
||||
const left = container ? container.getBoundingClientRect().left : 310;
|
||||
const right = memberlist ? memberlist.getBoundingClientRect().left : 0;
|
||||
const width = right ? right - container.getBoundingClientRect().left : Utils.screenWidth - left - 240;
|
||||
const bottom = form ? form.offsetHeight : 80;
|
||||
const toastWrapper = document.createElement("div");
|
||||
toastWrapper.classList.add("bd-toasts");
|
||||
const boundingElement = document.querySelector(".chat-3bRxxu form, #friends, .noChannel-Z1DQK7, .activityFeed-28jde9");
|
||||
toastWrapper.style.setProperty("left", boundingElement ? boundingElement.getBoundingClientRect().left + "px" : "0px");
|
||||
toastWrapper.style.setProperty("width", boundingElement ? boundingElement.offsetWidth + "px" : "100%");
|
||||
toastWrapper.style.setProperty("bottom", (document.querySelector(".chat-3bRxxu form") ? document.querySelector(".chat-3bRxxu form").offsetHeight : 80) + "px");
|
||||
document.querySelector(".app, .app-2rEoOp").appendChild(toastWrapper);
|
||||
toastWrapper.style.setProperty("left", left + "px");
|
||||
toastWrapper.style.setProperty("width", width + "px");
|
||||
toastWrapper.style.setProperty("bottom", bottom + "px");
|
||||
document.querySelector("#app-mount").appendChild(toastWrapper);
|
||||
}
|
||||
const {type = "", icon = true, timeout = 3000} = options;
|
||||
const toastElem = document.createElement("div");
|
||||
|
@ -377,4 +382,6 @@ export default class Utils {
|
|||
}, props));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Utils.showToast = Utils.suppressErrors(Utils.showToast, "Could not show toast.");
|
|
@ -11,6 +11,7 @@ import Switch from "./components/switch";
|
|||
import TooltipWrap from "./tooltipWrap";
|
||||
|
||||
const React = BDV2.React;
|
||||
const anchorClasses = BDV2.anchorClasses;
|
||||
|
||||
export default class V2C_PluginCard extends BDV2.reactComponent {
|
||||
|
||||
|
@ -112,7 +113,7 @@ export default class V2C_PluginCard extends BDV2.reactComponent {
|
|||
if (nameIndex) {
|
||||
const props = {className: "author bda-author"};
|
||||
if (author.link || author.id) {
|
||||
props.className += ` ${BDV2.anchorClasses.anchor} ${BDV2.anchorClasses.anchorUnderlineOnHover}`;
|
||||
props.className += ` ${anchorClasses.anchor} ${anchorClasses.anchorUnderlineOnHover}`;
|
||||
props.target = "_blank";
|
||||
|
||||
if (author.link) props.href = author.link;
|
||||
|
|
|
@ -93,7 +93,7 @@ export default class CardList extends BDV2.reactComponent {
|
|||
key: addon.name,
|
||||
enabled: this.cookie[addon.name],
|
||||
toggle: this.manager.toggle.bind(this.manager),
|
||||
edit: this.edit.bind(this),
|
||||
//edit: this.edit.bind(this),
|
||||
remove: this.delete.bind(this),
|
||||
addon: addon
|
||||
};
|
||||
|
|
|
@ -63,8 +63,8 @@ export default class EmulatedTooltip {
|
|||
if (!classExists(this.side)) return Utils.err("EmulatedTooltip", `Side ${this.side} does not exist.`);
|
||||
if (!classExists(this.style)) return Utils.err("EmulatedTooltip", `Style ${this.style} does not exist.`);
|
||||
|
||||
this.element = DOM.createElement(`<div class="${TooltipLayers.layer}">`);
|
||||
this.tooltipElement = DOM.createElement(`<div class="${TooltipClasses.tooltip} ${getClass(this.style)}"><div class="${TooltipClasses.tooltipPointer}"></div>${this.label}</div>`);
|
||||
this.element = DOM.createElement(`<div class="${TooltipLayers.layer}"><div class="${TooltipClasses.tooltip} ${getClass(this.style)}"><div class="${TooltipClasses.tooltipPointer}"></div>${this.label}</div></div>`);
|
||||
this.tooltipElement = this.element.childNodes[0];
|
||||
this.labelElement = this.tooltipElement.childNodes[1];
|
||||
this.element.append(this.tooltipElement);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export default class extends BDV2.reactComponent {
|
|||
this.onMouseLeave = this.onMouseLeave.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
async componentDidMount() {
|
||||
const {style = "black", side = "top", text = ""} = this.props;
|
||||
this.node = BDV2.reactDom.findDOMNode(this);
|
||||
// this.node.addEventListener("mouseenter", this.onMouseEnter);
|
||||
|
|
Loading…
Reference in New Issue