some changes

This commit is contained in:
Zack Rauen 2020-04-23 16:01:48 -04:00
parent 23bfd6bbb9
commit b6313db456
5 changed files with 122 additions and 20 deletions

View File

@ -10,11 +10,32 @@ This branch is for the ongoing rewrite of BandagedBD. You can view what I believ
# Testing
The following steps tell you how you can currently test the state of the rewrite as of September 26th 2019.
The following steps tell you how you can currently test the state of the rewrite as of April 23rd 2020.
1. locate your BD installation. For Windows it is usually in `%localappdata%\Discord\app-0.0.305\resources\app\betterdiscord`.
1. locate your BD installation. For Windows it is usually in `%localappdata%\Discord\app-0.0.306\resources\app\betterdiscord`.
2. Open config.json in a text editor (n++, notepad, etc).
3. Change the line `"branch": "master",` to `"branch": "development",`.
4. (optional) Change `"minified": false,` to `"minified": true,` to stay on the bleeding edge (sometimes I forget to update the minified version).
4. (optional) Change `"minified": true,` to `"minified": false,` to stay on the bleeding edge (sometimes I forget to update the minified version).
5. Fully restart your Discord client.
6. You can verify it worked by seeing the revamped plugins and themes pages as well as custom css. You can also see if the version in settings is 1.0.0+
6. You can verify it worked by seeing the revamped plugins and themes pages as well as custom css. You can also see if the version in settings is 1.0.0+
## Script Version
The above can be automatically done in script form.
```js
((branch = "development", minified = false) => {
try {
const fs = require("fs");
const path = require("path");
const configPath = path.join(Utils.injectionPath, "betterdiscord", "config.json");
const config = require(configPath);
config.branch = branch;
config.minified = minified;
console.log(config);
fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
const app = require("electron").remote.app;
app.relaunch();
app.exit();
}
catch (err) {console.error(err);}
})("development", false);

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
import {Config} from "data";
import WebpackModules from "./webpackmodules";
import DiscordModules from "./discordmodules";
import Utilities from "./utilities";
@ -14,24 +15,63 @@ export default new class ComponentPatcher {
}
patchSocial() {
if (this.socialPatch) return;
// const TabBar = WebpackModules.getByDisplayName("TabBar");
// const Anchor = WebpackModules.getByDisplayName("Anchor");
// if (!TabBar || !Anchor) return;
// this.socialPatch = Patcher.after("ThemeHelper", TabBar.prototype, "render", (_, __, returnValue) => {
// const children = returnValue.props.children;
// if (!children || !children.length) return;
// if (children[children.length - 2].type.displayName !== "Separator") return;
// if (!children[children.length - 1].type.toString().includes("socialLinks")) return;
// const original = children[children.length - 1].type;
// const newOne = function() {
// const returnVal = original(...arguments);
// returnVal.props.children.push(DiscordModules.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", rel: "author", title: "BandagedBD", target: "_blank"},
// DiscordModules.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
// ));
// return returnVal;
// };
// children[children.length - 1].type = newOne;
// });
if (this.socialPatch) return;
const TabBar = WebpackModules.getByDisplayName("TabBar");
const Anchor = WebpackModules.getByDisplayName("Anchor");
if (!TabBar || !Anchor) return;
this.socialPatch = Patcher.after("ThemeHelper", TabBar.prototype, "render", (_, __, returnValue) => {
if (!TabBar) return;
this.socialPatch = Patcher.after("ComponentPatcher", TabBar.prototype, "render", (thisObject, args, returnValue) => {
const children = returnValue.props.children;
if (!children || !children.length) return;
if (children[children.length - 2].type.displayName !== "Separator") return;
if (!children[children.length - 1].type.toString().includes("socialLinks")) return;
const original = children[children.length - 1].type;
const newOne = function() {
const returnVal = original(...arguments);
returnVal.props.children.push(DiscordModules.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", rel: "author", title: "BandagedBD", target: "_blank"},
DiscordModules.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
));
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;
if (Anchor) {
const original = children[children.length - 2].type;
const newOne = function() {
const returnVal = original(...arguments);
returnVal.props.children.push(
// DiscordModules.React.createElement(TooltipWrap, {color: "black", side: "top", text: "BandagedBD"},
DiscordModules.React.createElement(Anchor, {className: "bd-social-link", href: "https://github.com/rauenzi/BetterDiscordApp", title: "BandagedBD", target: "_blank"},
DiscordModules.React.createElement(BDLogo, {size: "16px", className: "bd-social-logo"})
)
// )
);
return returnVal;
};
children[children.length - 2].type = newOne;
}
const injector = DiscordModules.React.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, `Injector ${Config.version}`);
const versionHash = `(${Config.hash ? Config.hash.substring(0, 7) : Config.branch})`;
const additional = DiscordModules.React.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, `BBD ${Config.bbdVersion} `, DiscordModules.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.splice(returnVal.props.children.length - 1, 0, injector);
returnVal.props.children.splice(1, 0, additional);
return returnVal;
};
children[children.length - 1].type = newOne;
});
}

View File

@ -240,4 +240,45 @@ BdApi.setBDData = function(key, data) {
return DataStore.setBDData(key, data);
};
// const makeAddonAPI = (cookie, list, manager) => new class AddonAPI {
// get folder() {return manager.folder;}
// isEnabled(name) {
// return !!cookie[name];
// }
// enable(name) {
// return manager.enable(name);
// }
// disable(name) {
// return manager.disable(name);
// }
// toggle(name) {
// if (cookie[name]) this.disable(name);
// else this.enable(name);
// }
// reload(name) {
// return manager.reload(name);
// }
// get(name) {
// if (list.hasOwnProperty(name)) {
// if (list[name].plugin) return list[name].plugin;
// return list[name];
// }
// return null;
// }
// getAll() {
// return Object.keys(list).map(k => this.get(k)).filter(a => a);
// }
// };
// BdApi.Plugins = makeAddonAPI(pluginCookie, bdplugins, pluginModule);
// BdApi.Themes = makeAddonAPI(themeCookie, bdthemes, themeModule);
export default BdApi;

View File

@ -72,7 +72,7 @@ export default new class SettingsRenderer {
if (panel.clickListener) panel.onClick = (event) => panel.clickListener(thisObject, event, returnValue);
insert(panel);
}
insert({section: "CUSTOM", element: Attribution});
// insert({section: "CUSTOM", element: Attribution});
});
this.forceUpdate();
}