Skip to content

Commit

Permalink
Bugfix: BetterDiscord gets initialized outside the indended web client
Browse files Browse the repository at this point in the history
- BdBrowser's check for `getCurrentUser` is not sufficient to determine
  whether a user really is in the web client, as the UserStore module also
  gets loaded on the OAuth authorization prompt. This causes BD to
  initialize on unintended parts of Discord's website.
  To combat this, the presence of the GuildStore will also be checked now.
  (Reported by @Serega007RU)
  • Loading branch information
tsukasa committed Nov 11, 2023
1 parent 2e03402 commit 49f0252
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "__MSG_extName__",
"version": "1.9.5.20231101",
"version": "1.9.5.20231111",
"description": "__MSG_extDesc__",
"homepage_url": "https://github.com/tsukasa/BdBrowser",
"icons": {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/modules/discordmodules.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export default {
/* User Stores and Utils */
get UserStore() {return Webpack.getByProps("getCurrentUser", "getUser");},

/* Guild Info, Stores, and Utilities */
get GuildStore() {return Webpack.getByProps("getGuild");},

/* Electron & Other Internals with Utils */
get ElectronModule() {return Webpack.getByProps("setBadge");},
get Dispatcher() {return Webpack.getByProps("dispatch", "subscribe", "wait", "unsubscribe", "register");},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async function loadBetterDiscord() {
return true;
}

if (!DiscordModules.UserStore?.getCurrentUser()) {
if (!DiscordModules.UserStore?.getCurrentUser() || !DiscordModules.GuildStore?.getGuilds()) {
Logger.log("Frontend", "getCurrentUser failed, registering callback.");
DiscordModules.Dispatcher.subscribe(connectionOpenEvent, callback);
}
Expand Down

0 comments on commit 49f0252

Please sign in to comment.