some updating, no build
This commit is contained in:
parent
341e685bc2
commit
a7f9978957
42
js/main.js
42
js/main.js
File diff suppressed because one or more lines are too long
|
@ -66,9 +66,9 @@ export default new class ClassNormalizer extends Builtin {
|
|||
if (this.shouldIgnore(value)) continue;
|
||||
const classList = value.split(" ");
|
||||
for (const normalClass of classList) {
|
||||
const match = normalClass.match(randClass)[1];
|
||||
if (!match) continue; // Shouldn't ever happen since they passed the moduleFilter, but you never know
|
||||
const camelCase = match.split("-").map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join("");
|
||||
const match = normalClass.match(randClass);
|
||||
if (!match || !match.length || match.length < 2) continue; // Shouldn't ever happen since they passed the moduleFilter, but you never know
|
||||
const camelCase = match[1].split("-").map((s, i) => i ? s[0].toUpperCase() + s.slice(1) : s).join("");
|
||||
classNames[baseClassName] += ` ${componentName}-${camelCase}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Builtin from "../structs/builtin";
|
||||
import {WebpackModules} from "modules";
|
||||
|
||||
const MessageContent = WebpackModules.getModule(m => m.defaultProps && m.defaultProps.hasOwnProperty("disableButtons"));
|
||||
const MessageContent = WebpackModules.getModule(m => m.default && m.default.displayName && m.default.displayName == "Message");
|
||||
|
||||
export default new class ColoredText extends Builtin {
|
||||
get name() {return "ColoredText";}
|
||||
|
|
|
@ -15,7 +15,7 @@ export default new class DeveloperMode extends Builtin {
|
|||
}
|
||||
|
||||
enabled() {
|
||||
$(window).on("keydown.bdDevmode", (e) => {
|
||||
$(document).on("keydown.bdDevmode", (e) => {
|
||||
if (e.which === 119 || e.which == 118) {//F8
|
||||
this.log("Debugger Activated");
|
||||
debugger; // eslint-disable-line no-debugger
|
||||
|
@ -26,7 +26,7 @@ export default new class DeveloperMode extends Builtin {
|
|||
}
|
||||
|
||||
disabled() {
|
||||
$(window).off("keydown.bdDevmode");
|
||||
$(document).off("keydown.bdDevmode");
|
||||
if (this.selectorMode) this.disableSelectors();
|
||||
if (this.selectorCancel) this.selectorCancel();
|
||||
}
|
||||
|
|
|
@ -160,7 +160,8 @@ export default new class EmoteMenu extends Builtin {
|
|||
observe(mutation) {
|
||||
if (!mutation.addedNodes.length || !(mutation.addedNodes[0] instanceof Element)) return;
|
||||
const node = mutation.addedNodes[0];
|
||||
if (!node.classList.contains("popout-3sVMXz") || node.classList.contains("popoutLeft-30WmrD") || !node.getElementsByClassName("emojiPicker-3m1S-j").length) return;
|
||||
// if (!node.classList.contains("popout-2iWAc-") || node.classList.contains("popoutLeft-30WmrD") || !node.getElementsByClassName("emojiPicker-3m1S-j").length) return;
|
||||
if (!node.classList.contains("layer-v9HyYc") || !node.getElementsByClassName("emojiPicker-3m1S-j").length || node.querySelector(".emojiPicker-3m1S-j").parentElement.classList.contains("animatorLeft-1EQxU0")) return;
|
||||
|
||||
const e = $(node);
|
||||
if (this.hideEmojis) e.addClass("bd-qme-hidden");
|
||||
|
|
|
@ -67,14 +67,15 @@ export default new class EmoteModule extends Builtin {
|
|||
await this.getBlacklist();
|
||||
await this.loadEmoteData();
|
||||
|
||||
while (!this.MessageContentComponent) await new Promise(resolve => setTimeout(resolve, 100));
|
||||
this.patchMessageContent();
|
||||
// while (!this.MessageContentComponent) await new Promise(resolve => setTimeout(resolve, 100));
|
||||
// this.patchMessageContent();
|
||||
Events.on("emotes-favorite-added", this.addFavorite);
|
||||
Events.on("emotes-favorite-removed", this.removeFavorite);
|
||||
Events.on("setting-updated", this.onCategoryToggle);
|
||||
}
|
||||
|
||||
disabled() {
|
||||
console.log("DISABLED");
|
||||
Events.off("setting-updated", this.onCategoryToggle);
|
||||
Events.off("emotes-favorite-added", this.addFavorite);
|
||||
Events.off("emotes-favorite-removed", this.removeFavorite);
|
||||
|
@ -185,12 +186,17 @@ export default new class EmoteModule extends Builtin {
|
|||
}
|
||||
|
||||
async getBlacklist() {
|
||||
const category = "Blacklist";
|
||||
const exists = DataStore.emotesExist(category);
|
||||
const valid = await this.isCacheValid(category);
|
||||
const useCache = (valid) || (!valid && exists && !this.shouldDownload);
|
||||
const list = useCache ? DataStore.getEmoteData(category) : await this.downloadEmotes(category);
|
||||
blacklist.push(...list);
|
||||
try {
|
||||
const category = "Blacklist";
|
||||
const exists = DataStore.emotesExist(category);
|
||||
const valid = await this.isCacheValid(category);
|
||||
const useCache = (valid) || (!valid && exists && !this.shouldDownload);
|
||||
const list = useCache ? DataStore.getEmoteData(category) : await this.downloadEmotes(category);
|
||||
blacklist.push(...list);
|
||||
}
|
||||
catch (err) {
|
||||
// TODO: Log this
|
||||
}
|
||||
}
|
||||
|
||||
isCacheValid(category) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
export default {
|
||||
description: "Don't be shocked, this modal is supposed to be here.",
|
||||
changes: [
|
||||
{
|
||||
title: "What's New?",
|
||||
items: [
|
||||
"**BandagedBD will now keep you updated with changelogs!** I will try to only show a changelog when there's more than a tiny or internal change.",
|
||||
"**Twitter (@BandagedBD)** I created a Twitter to try and provide support and such for those without access to the server. https://Twitter.com/BandagedBD"
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Fixes",
|
||||
type: "fixed",
|
||||
items: [
|
||||
"**Colored Text** option should work again.",
|
||||
"**Emotes** should show up in chat.",
|
||||
"Fixed a bug where BBD attempted to patch the TabBar module incorrectly. (Thanks, DevilBro)"
|
||||
]
|
||||
},
|
||||
{
|
||||
title: "Minor Stuff",
|
||||
type: "improved",
|
||||
items: [
|
||||
"**Colour->Color.** Swapped to using English-US spelling by default to be consistent, and to potentially be prepared for localization.",
|
||||
"**Versions simplified.** The BandagedBD version now integrates into Discord's at the bottom-left of settings instead of randomly being a part of the setting list."
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
export {default as Config} from "./config";
|
||||
export {default as EmoteConfig} from "./settings/emoteconfig";
|
||||
export {default as SettingsConfig} from "./settings/config";
|
||||
export {default as Strings} from "./strings";
|
||||
export {default as Strings} from "./strings";
|
||||
export {default as Changelog} from "./changelog";
|
|
@ -19,7 +19,7 @@ const fs = require("fs");
|
|||
const Module = require("module").Module;
|
||||
Module.globalPaths.push(path.resolve(require("electron").remote.app.getAppPath(), "node_modules"));
|
||||
|
||||
const splitRegex = /[^\S\r\n]*?\r?\n[^\S\r\n]*?\*[^\S\r\n]?/;
|
||||
const splitRegex = /[^\S\r\n]*?\r?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/;
|
||||
const escapedAtRegex = /^\\@/;
|
||||
|
||||
const stripBOM = function(fileContent) {
|
||||
|
@ -122,6 +122,7 @@ export default class AddonManager {
|
|||
const parsed = Utilities.testJSON(metaData);
|
||||
if (!parsed) throw new MetaError("META could not be parsed.");
|
||||
if (!parsed.name) throw new MetaError("META missing name data.");
|
||||
parsed.format = "json";
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
@ -144,6 +145,7 @@ export default class AddonManager {
|
|||
}
|
||||
out[field] = accum.trim();
|
||||
delete out[""];
|
||||
out.format = "jsdoc";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ export default new class ComponentPatcher {
|
|||
const GuildComponent = reactInstance.return.type;
|
||||
if (!GuildComponent) return;
|
||||
this.guildListItemsPatch = Patcher.after("ThemeHelper", GuildComponent.prototype, "render", (thisObject, _, returnValue) => {
|
||||
if (!returnValue || !thisObject) return;
|
||||
const guildData = thisObject.props;
|
||||
returnValue.props.className += " bd-guild";
|
||||
if (guildData.unread) returnValue.props.className += " bd-unread";
|
||||
|
|
|
@ -30,6 +30,16 @@ Core.prototype.init = async function() {
|
|||
Modals.alert("Not Supported", "BetterDiscord v" + Config.version + " (your version)" + " is not supported by the latest js (" + Config.bbdVersion + ").<br><br> Please download the latest version from <a href='https://github.com/rauenzi/BetterDiscordApp/releases/latest' target='_blank'>GitHub</a>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.ED) {
|
||||
Modals.alert("Not Supported", "BandagedBD does not work with EnhancedDiscord. Please uninstall one of them.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.WebSocket && window.WebSocket.name && window.WebSocket.name.includes("Patched")) {
|
||||
Modals.alert("Not Supported", "BandagedBD does not work with Powercord. Please uninstall one of them.");
|
||||
return;
|
||||
}
|
||||
// const latestLocalVersion = Config.updater ? Config.updater.LatestVersion : Config.latestVersion;
|
||||
// if (latestLocalVersion > Config.version) {
|
||||
// Modals.alert("Update Available", `
|
||||
|
@ -63,16 +73,25 @@ Core.prototype.init = async function() {
|
|||
// Show loading errors
|
||||
Logger.log("Startup", "Collecting Startup Errors");
|
||||
Modals.showAddonErrors({plugins: pluginErrors, themes: themeErrors});
|
||||
|
||||
// const previousVersion = DataStore.getBDData("version");
|
||||
// if (bbdVersion > previousVersion) {
|
||||
// if (bbdChangelog) this.showChangelogModal(bbdChangelog);
|
||||
// DataStore.setBDData("version", bbdVersion);
|
||||
// }
|
||||
};
|
||||
|
||||
Core.prototype.waitForGuilds = function() {
|
||||
let timesChecked = 0;
|
||||
return new Promise(resolve => {
|
||||
const checkForGuilds = function() {
|
||||
timesChecked++;
|
||||
if (document.readyState != "complete") setTimeout(checkForGuilds, 100);
|
||||
const wrapper = GuildClasses.wrapper.split(" ")[0];
|
||||
const guild = GuildClasses.listItem.split(" ")[0];
|
||||
const blob = GuildClasses.blobContainer.split(" ")[0];
|
||||
if (document.querySelectorAll(`.${wrapper} .${guild} .${blob}`).length > 0) return resolve(Config.deferLoaded = true);
|
||||
else if (timesChecked >= 50) return resolve(Config.deferLoaded = true);
|
||||
setTimeout(checkForGuilds, 100);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Settings, React, WebpackModules, Events, Strings} from "modules";
|
||||
|
||||
const TooltipWrapper = WebpackModules.getByDisplayName("TooltipDeprecated");
|
||||
const TooltipWrapper = WebpackModules.getByDisplayName("Tooltip");
|
||||
|
||||
export default class BDEmote extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -58,12 +58,13 @@ export default class BDEmote extends React.Component {
|
|||
text: this.label,
|
||||
delay: 750
|
||||
},
|
||||
React.createElement("div", {
|
||||
(childProps) => {
|
||||
return React.createElement("div", Object.assign({
|
||||
className: "emotewrapper" + (this.props.jumboable ? " jumboable" : ""),
|
||||
onMouseEnter: this.onMouseEnter,
|
||||
onMouseLeave: this.onMouseLeave,
|
||||
onClick: this.onClick
|
||||
},
|
||||
}, childProps),
|
||||
React.createElement("img", {
|
||||
draggable: false,
|
||||
className: "emote" + this.modifierClass + (this.props.jumboable ? " jumboable" : "") + (!this.state.shouldAnimate ? " stop-animation" : ""),
|
||||
|
@ -77,7 +78,7 @@ export default class BDEmote extends React.Component {
|
|||
type: "button",
|
||||
onClick: this.toggleFavorite
|
||||
})
|
||||
)
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -43,11 +43,11 @@ class FloatingWindowContainer extends React.Component {
|
|||
}
|
||||
|
||||
const containerRef = React.createRef();
|
||||
const container = <FloatingWindowContainer ref={containerRef} />;
|
||||
const App = Utilities.findInReactTree(Utilities.getReactInstance(document.querySelector(".app-19_DXt")), m => m && m.type && m.type.displayName && m.type.displayName == "App");
|
||||
Patcher.after("FloatingContainer", App.type.prototype, "render", (thisObject, args, returnValue) => {
|
||||
const group = Utilities.findInRenderTree(returnValue, m => m && m[6] && m[6].type && m[6].type.displayName == "LayerContainer", {walkable: ["children", "props"]});
|
||||
group.push(container);
|
||||
});
|
||||
App.stateNode.forceUpdate();
|
||||
// const container = <FloatingWindowContainer ref={containerRef} />;
|
||||
// const App = Utilities.findInReactTree(Utilities.getReactInstance(document.querySelector(".app-19_DXt")), m => m && m.type && m.type.displayName && m.type.displayName == "App");
|
||||
// Patcher.after("FloatingContainer", App.type.prototype, "render", (thisObject, args, returnValue) => {
|
||||
// const group = Utilities.findInRenderTree(returnValue, m => m && m[6] && m[6].type && m[6].type.displayName == "LayerContainer", {walkable: ["children", "props"]});
|
||||
// group.push(container);
|
||||
// });
|
||||
// App.stateNode.forceUpdate();
|
||||
export default containerRef.current;
|
|
@ -1,3 +1,4 @@
|
|||
import {Config} from "data";
|
||||
import {Logger, WebpackModules, Utilities, React, Settings, Strings} from "modules";
|
||||
|
||||
export default class Modals {
|
||||
|
@ -166,4 +167,60 @@ export default class Modals {
|
|||
if (pluginErrors.length) modal.find(".tab-bar-item")[0].click();
|
||||
else modal.find(".tab-bar-item")[1].click();
|
||||
}
|
||||
|
||||
showChangelogModal(options = {}) {
|
||||
const ModalStack = WebpackModules.getByProps("push", "update", "pop", "popWithKey");
|
||||
const ChangelogClasses = WebpackModules.getByProps("fixed", "improved");
|
||||
const TextElement = WebpackModules.getByProps("Sizes", "Weights");
|
||||
const FlexChild = WebpackModules.getByProps("Child");
|
||||
const Titles = WebpackModules.getByProps("Tags", "default");
|
||||
const Changelog = WebpackModules.getModule(m => m.defaultProps && m.defaultProps.selectable == false);
|
||||
const MarkdownParser = WebpackModules.getByProps("defaultRules", "parse");
|
||||
if (!Changelog || !ModalStack || !ChangelogClasses || !TextElement || !FlexChild || !Titles || !MarkdownParser) return;
|
||||
|
||||
const {image = "https://repository-images.githubusercontent.com/105473537/957b5480-7c26-11e9-8401-50fa820cbae5", description = "", changes = [], title = "BandagedBD", subtitle = `v${Config.bbdVersion}`, footer} = options;
|
||||
const ce = React.createElement;
|
||||
const changelogItems = [ce("img", {src: image})];
|
||||
if (description) changelogItems.push(ce("p", null, MarkdownParser.parse(description)));
|
||||
for (let c = 0; c < changes.length; c++) {
|
||||
const entry = changes[c];
|
||||
const type = ChangelogClasses[entry.type] ? ChangelogClasses[entry.type] : ChangelogClasses.added;
|
||||
const margin = c == 0 ? ChangelogClasses.marginTop : "";
|
||||
changelogItems.push(ce("h1", {className: `${type} ${margin}`,}, entry.title));
|
||||
const list = ce("ul", null, entry.items.map(i => ce("li", null, MarkdownParser.parse(i))));
|
||||
changelogItems.push(list);
|
||||
}
|
||||
const renderHeader = function() {
|
||||
return ce(FlexChild.Child, {grow: 1, shrink: 1},
|
||||
ce(Titles.default, {tag: Titles.Tags.H4}, title),
|
||||
ce(TextElement,{size: TextElement.Sizes.SMALL, color: TextElement.Colors.PRIMARY, className: ChangelogClasses.date}, subtitle)
|
||||
);
|
||||
};
|
||||
|
||||
const renderFooter = () => {
|
||||
const Anchor = WebpackModules.getModule(m => m.displayName == "Anchor");
|
||||
const AnchorClasses = WebpackModules.getByProps("anchorUnderlineOnHover") || {anchor: "anchor-3Z-8Bb", anchorUnderlineOnHover: "anchorUnderlineOnHover-2ESHQB"};
|
||||
const joinSupportServer = (click) => {
|
||||
click.preventDefault();
|
||||
click.stopPropagation();
|
||||
ModalStack.pop();
|
||||
BDV2.joinBD2();
|
||||
};
|
||||
const supportLink = Anchor ? ce(Anchor, {onClick: joinSupportServer}, "Join our Discord Server.") : ce("a", {className: `${AnchorClasses.anchor} ${AnchorClasses.anchorUnderlineOnHover}`, onClick: joinSupportServer}, "Join our Discord Server.");
|
||||
const defaultFooter = ce(TextElement,{size: TextElement.Sizes.SMALL, color: TextElement.Colors.PRIMARY}, "Need support? ", supportLink);
|
||||
return ce(FlexChild.Child, {grow: 1, shrink: 1}, footer ? footer : defaultFooter);
|
||||
};
|
||||
|
||||
ModalStack.push(function(props) {
|
||||
return ce(Changelog, Object.assign({
|
||||
className: ChangelogClasses.container,
|
||||
selectable: true,
|
||||
onScroll: _ => _,
|
||||
onClose: _ => _,
|
||||
renderHeader: renderHeader,
|
||||
renderFooter: renderFooter,
|
||||
children: changelogItems
|
||||
}, props));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -43,9 +43,11 @@ export default new class SettingsRenderer {
|
|||
}
|
||||
|
||||
async patchSections() {
|
||||
Patcher.after("SettingsManager", WebpackModules.getByDisplayName("FluxContainer(GuildSettings)").prototype, "render", (thisObject) => {
|
||||
thisObject._reactInternalFiber.return.return.return.return.return.return.memoizedProps.id = "guild-settings";
|
||||
});
|
||||
ReactComponents.get("FluxContainer(GuildSettings)", m => m.displayName == "FluxContainer(GuildSettings)").then(c => console.log("COMPONENT", c));
|
||||
// const GuildSettings = await ReactComponents.get("FluxContainer(GuildSettings)", m => m.displayName == "FluxContainer(GuildSettings)");
|
||||
// Patcher.after("SettingsManager", GuildSettings.prototype, "render", (thisObject) => {
|
||||
// thisObject._reactInternalFiber.return.return.return.return.return.return.memoizedProps.id = "guild-settings";
|
||||
// });
|
||||
const UserSettings = await ReactComponents.get("UserSettings", m => m.prototype && m.prototype.generateSections);
|
||||
Patcher.after("SettingsManager", UserSettings.prototype, "render", (thisObject) => {
|
||||
thisObject._reactInternalFiber.return.return.return.return.return.return.return.memoizedProps.id = "user-settings";
|
||||
|
|
|
@ -96,12 +96,21 @@ export default class AddonCard extends React.Component {
|
|||
|
||||
buildLink(which) {
|
||||
const url = this.props.addon[which];
|
||||
if (which == "invite") {
|
||||
const onClick = () => {
|
||||
const tester = /\.gg\/(.*)$/;
|
||||
let code = url;
|
||||
if (tester.test(code)) code = code.match(tester)[1];
|
||||
BDV2.LayerStack.popLayer();
|
||||
BDV2.InviteActions.acceptInviteAndTransitionToInviteChannel(code);
|
||||
};
|
||||
}
|
||||
if (!url) return null;
|
||||
return <a className="bd-link bd-link-website" href={url} target="_blank" rel="noopener noreferrer">{Strings.Addons[which]}</a>;
|
||||
}
|
||||
|
||||
get footer() {
|
||||
const links = ["website", "source"];
|
||||
const links = ["website", "source", "invite", "donate", "patreon"];
|
||||
if (!links.some(l => this.props.addon[l]) && !this.props.hasSettings) return null;
|
||||
const linkComponents = links.map(this.buildLink.bind(this)).filter(c => c);
|
||||
return <div className="bd-footer">
|
||||
|
|
Loading…
Reference in New Issue