fix transparency

This commit is contained in:
Zack Rauen 2020-03-27 23:31:28 -04:00
parent 505e0187f6
commit dbcf2f9cef
5 changed files with 44 additions and 30 deletions

File diff suppressed because one or more lines are too long

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -11,19 +11,7 @@ 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 WindowConfigFile() {return Utils.WindowConfigFile;},
get settings() {return settings;},
get emotes() {return bdEmotes;},
get screenWidth() { return Math.max(document.documentElement.clientWidth, window.innerWidth || 0); },
@ -31,22 +19,15 @@ const BdApi = {
};
BdApi.getAllWindowPreferences = function() {
if (!this.WindowConfigFile) return {}; // Tempfix until new injection on other platforms
return __non_webpack_require__(this.WindowConfigFile);
return Utils.getAllWindowPreferences();
};
BdApi.getWindowPreference = function(key) {
if (!this.WindowConfigFile) return undefined; // Tempfix until new injection on other platforms
return this.getAllWindowPreferences()[key];
return Utils.getWindowPreference(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));
return Utils.setWindowPreference(key, value);
};
//Inject CSS to document head

View File

@ -170,9 +170,9 @@ export default new class V2_SettingsPanel {
}
if (id == "fork-wp-1") {
// BdApi.setWindowPreference("transparent", enabled);
// if (enabled) BdApi.setWindowPreference("backgroundColor", null);
// else BdApi.setWindowPreference("backgroundColor", "#2f3136");
Utils.setWindowPreference("transparent", enabled);
if (enabled) Utils.setWindowPreference("backgroundColor", null);
else Utils.setWindowPreference("backgroundColor", "#2f3136");
}
/*if (_c["fork-wp-2"]) {

View File

@ -8,6 +8,39 @@ export default class Utils {
/** Document/window height */
static get screenHeight() { return Math.max(document.documentElement.clientHeight, window.innerHeight || 0); }
static 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;
}
static getAllWindowPreferences() {
if (!this.WindowConfigFile) return {}; // Tempfix until new injection on other platforms
return __non_webpack_require__(this.WindowConfigFile);
}
static getWindowPreference(key) {
if (!this.WindowConfigFile) return undefined; // Tempfix until new injection on other platforms
return this.getAllWindowPreferences()[key];
}
static setWindowPreference(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));
}
static stripBOM(content) {
if (content.charCodeAt(0) === 0xFEFF) {
content = content.slice(1);