import {pluginCookie, themeCookie, bdplugins, bdthemes, settingsCookie, settings, bdEmotes} from "../0globals"; import mainCore from "./core"; import Utils from "./utils"; import BDV2 from "./v2"; import DataStore from "./dataStore"; import pluginModule from "./pluginModule"; import themeModule from "./themeModule"; import settingsPanel from "./settingsPanel"; const BdApi = { get React() { return BDV2.React; }, get ReactDOM() { return BDV2.ReactDom; }, get ReactComponent() {return BDV2.ReactComponent;}, get WindowConfigFile() { if (this._windowConfigFile) return this._windowConfigFile; const electron = require("electron").remote.app; const path = require("path"); const base = electron.getAppPath(); const roamingBase = electron.getPath("userData"); const roamingLocation = path.resolve(roamingBase, electron.getVersion(), "modules", "discord_desktop_core", "injector", "config.json"); const location = path.resolve(base, "..", "app", "config.json"); const fs = require("fs"); const realLocation = fs.existsSync(location) ? location : fs.existsSync(roamingLocation) ? roamingLocation : null; if (!realLocation) return this._windowConfigFile = null; return this._windowConfigFile = realLocation; }, get settings() {return settings;}, get emotes() {return bdEmotes;}, get screenWidth() { return Math.max(document.documentElement.clientWidth, window.innerWidth || 0); }, get screenHeight() { return Math.max(document.documentElement.clientHeight, window.innerHeight || 0); } }; BdApi.getAllWindowPreferences = function() { if (!this.WindowConfigFile) return {}; // Tempfix until new injection on other platforms return __non_webpack_require__(this.WindowConfigFile); }; BdApi.getWindowPreference = function(key) { if (!this.WindowConfigFile) return undefined; // Tempfix until new injection on other platforms return this.getAllWindowPreferences()[key]; }; BdApi.setWindowPreference = function(key, value) { if (!this.WindowConfigFile) return; // Tempfix until new injection on other platforms const fs = require("fs"); const prefs = this.getAllWindowPreferences(); prefs[key] = value; delete __non_webpack_require__.cache[this.WindowConfigFile]; fs.writeFileSync(this.WindowConfigFile, JSON.stringify(prefs, null, 4)); }; //Inject CSS to document head //id = id of element //css = custom css BdApi.injectCSS = function (id, css) { $("head").append($("