diff --git a/src/arrpc/src/transports/websocket.js b/src/arrpc/src/transports/websocket.js index 9667939..1aaf158 100644 --- a/src/arrpc/src/transports/websocket.js +++ b/src/arrpc/src/transports/websocket.js @@ -70,7 +70,7 @@ class WSServer { if ( origin !== "" && - !["https://discord.com", "https://ptb.discord.com", "https://canary.discord.com/"].includes(origin) + !["https://discord.com", "https://ptb.discord.com", "https://canary.discord.com"].includes(origin) ) { log("disallowed origin", origin); diff --git a/src/content/css/discord.css b/src/content/css/discord.css index ca79b1c..9f5668b 100644 --- a/src/content/css/discord.css +++ b/src/content/css/discord.css @@ -32,7 +32,8 @@ div#acThemes:after, div#acSettings:after, -div#acForceQuit:after { +div#acForceQuit:after, +div#acKeybinds:after { content: url("https://raw.githubusercontent.com/ArmCord/BrandingStuff/main/ac_white_plug16x.png"); margin-right: 5px; } diff --git a/src/ipc.ts b/src/ipc.ts index 1574f77..904fdbf 100644 --- a/src/ipc.ts +++ b/src/ipc.ts @@ -18,6 +18,7 @@ import os from "os"; import path from "path"; import {createTManagerWindow} from "./themeManager/main"; import {splashWindow} from "./splash/main"; +import {createKeybindWindow} from "./keybindMaker/main"; export function registerIpc(): void { ipcMain.on("get-app-path", (event) => { event.reply("app-path", app.getAppPath()); @@ -130,6 +131,9 @@ export function registerIpc(): void { ipcMain.on("openManagerWindow", () => { createTManagerWindow(); }); + ipcMain.on("openKeybindWindow", () => { + createKeybindWindow(); + }); ipcMain.on("setting-armcordCSP", async (event) => { if (await getConfig("armcordCSP")) { event.returnValue = true; diff --git a/src/keybindMaker/main.ts b/src/keybindMaker/main.ts index e69de29..dc484aa 100644 --- a/src/keybindMaker/main.ts +++ b/src/keybindMaker/main.ts @@ -0,0 +1,37 @@ +import {BrowserWindow, app, shell} from "electron"; +import path from "path"; +let keybindWindow: BrowserWindow; +let instance = 0; + +export function createKeybindWindow(): void { + console.log("Creating keybind maker window."); + instance += 1; + if (instance > 1) { + if (keybindWindow) { + keybindWindow.show(); + keybindWindow.restore(); + } + } else { + keybindWindow = new BrowserWindow({ + width: 660, + height: 670, + title: `ArmCord Global Keybinds Maker`, + darkTheme: true, + frame: true, + backgroundColor: "#2f3136", + autoHideMenuBar: true, + webPreferences: { + sandbox: false, + preload: path.join(__dirname, "preload.js") + } + }); + async function makerLoadPage(): Promise { + keybindWindow.loadURL(`file://${__dirname}/maker.html`); + } + keybindWindow.webContents.setWindowOpenHandler(({url}) => { + shell.openExternal(url); + return {action: "deny"}; + }); + makerLoadPage(); + } +} diff --git a/src/preload/preload.ts b/src/preload/preload.ts index 635f0a3..74ad61d 100644 --- a/src/preload/preload.ts +++ b/src/preload/preload.ts @@ -94,16 +94,21 @@ setInterval(() => { const acSettings = advanced.cloneNode(true) as HTMLElement; const tManager = advanced.cloneNode(true) as HTMLElement; const fQuit = advanced.cloneNode(true) as HTMLElement; + const keybindMaker = advanced.cloneNode(true) as HTMLElement; acSettings.textContent = "ArmCord"; acSettings.id = "acSettings"; acSettings.onclick = () => ipcRenderer.send("openSettingsWindow"); tManager.textContent = "Themes"; tManager.id = "acThemes"; tManager.onclick = () => ipcRenderer.send("openManagerWindow"); + keybindMaker.textContent = "Global keybinds"; + keybindMaker.id = "acKeybinds"; + keybindMaker.onclick = () => ipcRenderer.send("openKeybindWindow"); fQuit.textContent = "Force Quit"; fQuit.id = "acForceQuit"; fQuit.onclick = () => ipcRenderer.send("win-quit"); advanced.insertAdjacentElement("afterend", acSettings); advanced.insertAdjacentElement("afterend", tManager); + advanced.insertAdjacentElement("afterend", keybindMaker); advanced.insertAdjacentElement("afterend", fQuit); }, 1000);