import {bdConfig, minSupportedVersion, bbdVersion, settingsCookie, bdpluginErrors, bdthemeErrors, bbdChangelog, defaultCookie} from "./0globals"; import Utils from "./utils"; import emoteModule from "./emoteModule"; import quickEmoteMenu from "./quickEmoteMenu"; // import publicServersModule from "./publicServers"; // import voiceMode from "./voiceMode"; // import dMode from "./devMode"; import BDV2 from "./v2"; import settingsPanel from "./settingsPanel"; import pluginModule from "./pluginModule"; import themeModule from "./themeModule"; import DataStore from "./dataStore"; import WebpackModules from "./webpackModules"; import BDLogo from "./react/bdLogo"; function Core(config) { Object.assign(bdConfig, config); } Core.prototype.init = async function() { if (bdConfig.version < minSupportedVersion) { Utils.alert("Not Supported", "BetterDiscord v" + bdConfig.version + " (your version)" + " is not supported by the latest js (" + bbdVersion + ").

Please download the latest version from GitHub"); return; } if (window.ED) { Utils.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")) { Utils.alert("Not Supported", "BandagedBD does not work with Powercord. Please uninstall one of them."); return; } const latestLocalVersion = bdConfig.updater ? bdConfig.updater.LatestVersion : bdConfig.latestVersion; if (latestLocalVersion > bdConfig.version) { Utils.alert("Update Available", ` An update for BandagedBD is available (${latestLocalVersion})! Please Reinstall!

Download Installer `); } Utils.log("Startup", "Initializing Settings"); this.initSettings(); // emoteModule = new EmoteModule(); // quickEmoteMenu = new QuickEmoteMenu(); Utils.log("Startup", "Initializing EmoteModule"); window.emotePromise = emoteModule.init().then(() => { emoteModule.initialized = true; Utils.log("Startup", "Initializing QuickEmoteMenu"); quickEmoteMenu.init(); }); // publicServersModule = new V2_PublicServers(); // voiceMode = new VoiceMode(); // dMode = new devMode(); this.injectExternals(); await this.checkForGuilds(); BDV2.initialize(); Utils.log("Startup", "Updating Settings"); // settingsPanel = new V2_SettingsPanel(); settingsPanel.initializeSettings(); Utils.log("Startup", "Loading Plugins"); // pluginModule = new PluginModule(); pluginModule.loadPlugins(); Utils.log("Startup", "Loading Themes"); // themeModule = new ThemeModule(); themeModule.loadThemes(); $("#customcss").detach().appendTo(document.head); window.addEventListener("beforeunload", function() { if (settingsCookie["bda-dc-0"]) document.querySelector(".btn.btn-disconnect").click(); }); emoteModule.autoCapitalize(); Utils.log("Startup", "Removing Loading Icon"); if (document.getElementsByClassName("bd-loaderv2").length) document.getElementsByClassName("bd-loaderv2")[0].remove(); Utils.log("Startup", "Initializing Main Observer"); this.initObserver(); // Show loading errors if (settingsCookie["fork-ps-1"]) { Utils.log("Startup", "Collecting Startup Errors"); Utils.showContentErrors({plugins: bdpluginErrors, themes: bdthemeErrors}); } const previousVersion = DataStore.getBDData("version"); if (bbdVersion > previousVersion) { if (bbdChangelog) this.showChangelogModal(bbdChangelog); DataStore.setBDData("version", bbdVersion); } Utils.suppressErrors(this.patchSocial.bind(this), "BD Social Patch")(); Utils.suppressErrors(this.patchGuildPills.bind(this), "BD Guild Pills Patch")(); Utils.suppressErrors(this.patchGuildListItems.bind(this), "BD Guild List Items Patch")(); Utils.suppressErrors(this.patchGuildSeparator.bind(this), "BD Guild Separator Patch")(); }; Core.prototype.checkForGuilds = function() { let timesChecked = 0; return new Promise(resolve => { const checkForGuilds = function() { const wrapper = BDV2.guildClasses.wrapper.split(" ")[0]; if (document.querySelectorAll(`.${wrapper}`).length > 0) timesChecked++; const guild = BDV2.guildClasses.listItem.split(" ")[0]; const blob = BDV2.guildClasses.blobContainer.split(" ")[0]; if (document.querySelectorAll(`.${wrapper} .${guild} .${blob}`).length > 0) return resolve(bdConfig.deferLoaded = true); else if (timesChecked >= 50) return resolve(bdConfig.deferLoaded = true); setTimeout(checkForGuilds, 100); }; $(document).ready(function () { setTimeout(checkForGuilds, 100); }); }); }; Core.prototype.injectExternals = async function() { await Utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"); if (window.require.original) window.require = window.require.original; }; Core.prototype.initSettings = function () { DataStore.initialize(); if (!DataStore.getSettingGroup("settings")) { Object.assign(settingsCookie, defaultCookie); settingsPanel.saveSettings(); } else { settingsPanel.loadSettings(); $("