Add ability to remove discord's minimum size restriction

This commit is contained in:
Zack Rauen 2021-04-03 00:17:55 -04:00
parent a33279ea71
commit 826aa7999c
8 changed files with 41 additions and 7 deletions

View File

@ -10,3 +10,4 @@ export const OPEN_DEVTOOLS = "bd-open-devtools";
export const CLOSE_DEVTOOLS = "bd-close-devtools"; export const CLOSE_DEVTOOLS = "bd-close-devtools";
export const OPEN_WINDOW = "bd-open-window"; export const OPEN_WINDOW = "bd-open-window";
export const INSPECT_ELEMENT = "bd-inspect-element"; export const INSPECT_ELEMENT = "bd-inspect-element";
export const MINIMUM_SIZE = "bd-minimum-size";

View File

@ -22,10 +22,6 @@ electron.app.once("ready", async () => {
}); });
if (BetterDiscord.getSetting("general", "mediaKeys")) {
electron.app.commandLine.appendSwitch("disable-features", "HardwareMediaKeyHandling,MediaSessionService");
}
let hasCrashed = false; let hasCrashed = false;
export default class BetterDiscord { export default class BetterDiscord {
static getWindowPrefs() { static getWindowPrefs() {
@ -86,6 +82,7 @@ export default class BetterDiscord {
} }
static setup(browserWindow) { static setup(browserWindow) {
// Setup some useful vars to avoid blocking IPC calls // Setup some useful vars to avoid blocking IPC calls
process.env.DISCORD_PRELOAD = browserWindow.__originalPreload; process.env.DISCORD_PRELOAD = browserWindow.__originalPreload;
process.env.DISCORD_APP_PATH = appPath; process.env.DISCORD_APP_PATH = appPath;
@ -116,3 +113,7 @@ export default class BetterDiscord {
}); });
} }
} }
if (BetterDiscord.getSetting("general", "mediaKeys")) {
electron.app.commandLine.appendSwitch("disable-features", "HardwareMediaKeyHandling,MediaSessionService");
}

View File

@ -70,6 +70,11 @@ const inspectElement = async event => {
event.sender.devToolsWebContents.executeJavaScript("DevToolsAPI.enterInspectElementMode();"); event.sender.devToolsWebContents.executeJavaScript("DevToolsAPI.enterInspectElementMode();");
}; };
const setMinimumSize = (event, width, height) => {
const window = BrowserWindow.fromWebContents(event.sender);
window.setMinimumSize(width, height);
};
export default class IPCMain { export default class IPCMain {
static registerEvents() { static registerEvents() {
ipc.on(IPCEvents.GET_PATH, getPath); ipc.on(IPCEvents.GET_PATH, getPath);
@ -77,6 +82,7 @@ export default class IPCMain {
ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools); ipc.on(IPCEvents.OPEN_DEVTOOLS, openDevTools);
ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools); ipc.on(IPCEvents.CLOSE_DEVTOOLS, closeDevTools);
ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement); ipc.on(IPCEvents.INSPECT_ELEMENT, inspectElement);
ipc.on(IPCEvents.MINIMUM_SIZE, setMinimumSize);
ipc.handle(IPCEvents.RUN_SCRIPT, runScript); ipc.handle(IPCEvents.RUN_SCRIPT, runScript);
ipc.handle(IPCEvents.OPEN_WINDOW, createBrowserWindow); ipc.handle(IPCEvents.OPEN_WINDOW, createBrowserWindow);
} }

View File

@ -0,0 +1,16 @@
import Builtin from "../../structs/builtin";
import IPC from "../../modules/ipc";
export default new class RemoveMinimumSize extends Builtin {
get name() {return "RemoveMinimumSize";}
get category() {return "appearance";}
get id() {return "removeMinimumSize";}
enabled() {
IPC.setMinimumSize(1, 1);
}
disabled() {
IPC.setMinimumSize(940, 500);
}
};

View File

@ -12,6 +12,7 @@ export {default as ColoredText} from "./appearance/coloredtext";
export {default as HideGIFButton} from "./appearance/hidegifbutton"; export {default as HideGIFButton} from "./appearance/hidegifbutton";
export {default as HideGiftButton} from "./appearance/hidegiftbutton"; export {default as HideGiftButton} from "./appearance/hidegiftbutton";
export {default as MinimalMode} from "./appearance/minimalmode"; export {default as MinimalMode} from "./appearance/minimalmode";
export {default as RemoveMinimumSize} from "./appearance/removeminimumsize";
export {default as EmoteModule} from "./emotes/emotes"; export {default as EmoteModule} from "./emotes/emotes";
export {default as EmoteMenu} from "./emotes/emotemenu"; export {default as EmoteMenu} from "./emotes/emotemenu";

View File

@ -20,7 +20,8 @@ export default [
{type: "switch", id: "hideGiftButton", value: false}, {type: "switch", id: "hideGiftButton", value: false},
{type: "switch", id: "hideGIFButton", value: false}, {type: "switch", id: "hideGIFButton", value: false},
{type: "switch", id: "minimalMode", value: false}, {type: "switch", id: "minimalMode", value: false},
{type: "switch", id: "coloredText", value: false} {type: "switch", id: "coloredText", value: false},
{type: "switch", id: "removeMinimumSize", value: false}
] ]
}, },
{ {

View File

@ -47,6 +47,10 @@ export default {
hideGiftButton: { hideGiftButton: {
name: "Hide Gift Button", name: "Hide Gift Button",
note: "Hides the Nitro Gift button in the textarea" note: "Hides the Nitro Gift button in the textarea"
},
removeMinimumSize: {
name: "Remove Minimum Size",
note: "Removes Discord's forced minimum window size of 940x500"
} }
}, },
addons: { addons: {

View File

@ -33,6 +33,10 @@ export default new class IPCRenderer {
} }
inspectElement() { inspectElement() {
ipc.send(IPCEvents.INSPECT_ELEMENT); return ipc.send(IPCEvents.INSPECT_ELEMENT);
}
setMinimumSize(width, height) {
return ipc.send(IPCEvents.MINIMUM_SIZE, width, height);
} }
}; };