mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
fb6348ee82
* 2 new things (Read desc.) - Cleaned up ASAR packaging, ignoring unneeded files for building - Moved install location for Windows users ("AppData\Local\Programs" -> "AppData\Local" * 3 things (Read desc.) - Updated things related to Hummus (Hummus settings don't save nor load in it's respective settings window yet, idk why) - Added check for package version (ArmCord's internal version) - Made check for Kernel mod a bit cleaner, it still uses the same jank method * 3 things - Made macOS titlebar more accurate to Discord - Added "unFocused" class when window isn't focused - Added option to uninstall Husky hook for Windows users with reminder to run format script before committing * Resolved a dumb issue My dumbass not knowing the "echo" command existed smh * Made "precommit-fix" warning more noticable * Whoops * Fixed a CSS bug Discord updates are gonna hate us, huh?
104 lines
4.2 KiB
TypeScript
104 lines
4.2 KiB
TypeScript
import {ipcRenderer} from "electron";
|
|
import {addStyle} from "../utils";
|
|
import * as fs from "fs";
|
|
import * as path from "path";
|
|
import os from "os";
|
|
export function injectTitlebar() {
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
var elem = document.createElement("div");
|
|
elem.innerHTML = `<nav class="titlebar">
|
|
<div class="window-title" id="window-title"></div>
|
|
<div id="window-controls-container">
|
|
<div id="spacer"></div>
|
|
<div id="minimize"><div id="minimize-icon"></div></div>
|
|
<div id="maximize"><div id="maximize-icon"></div></div>
|
|
<div id="quit"><div id="quit-icon"></div></div>
|
|
</div>
|
|
</nav>`;
|
|
elem.classList.add("withFrame-haYltI");
|
|
if (document.getElementById("app-mount") == null) {
|
|
document.body.appendChild(elem);
|
|
} else {
|
|
document.getElementById("app-mount")!.prepend(elem);
|
|
}
|
|
const titlebarcssPath = path.join(__dirname, "../", "/content/css/titlebar.css");
|
|
const wordmarkcssPath = path.join(__dirname, "../", "/content/css/logos.css");
|
|
addStyle(fs.readFileSync(titlebarcssPath, "utf8"));
|
|
addStyle(fs.readFileSync(wordmarkcssPath, "utf8"));
|
|
document.body.setAttribute("customTitlebar", "");
|
|
document.body.setAttribute("armcord-platform", os.platform());
|
|
|
|
var minimize = document.getElementById("minimize");
|
|
var maximize = document.getElementById("maximize");
|
|
var quit = document.getElementById("quit");
|
|
|
|
minimize!.addEventListener("click", () => {
|
|
ipcRenderer.send("win-minimize");
|
|
});
|
|
|
|
maximize!.addEventListener("click", () => {
|
|
if (ipcRenderer.sendSync("win-isMaximized") == true) {
|
|
ipcRenderer.send("win-unmaximize");
|
|
document.body.removeAttribute("isMaximized");
|
|
} else if (ipcRenderer.sendSync("win-isNormal") == true) {
|
|
ipcRenderer.send("win-maximize");
|
|
}
|
|
});
|
|
|
|
quit!.addEventListener("click", () => {
|
|
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
ipcRenderer.send("win-hide");
|
|
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
ipcRenderer.send("win-quit");
|
|
}
|
|
});
|
|
});
|
|
}
|
|
export function injectHummusTitlebar() {
|
|
document.addEventListener("DOMContentLoaded", function (event) {
|
|
var elem = document.createElement("div");
|
|
elem.innerHTML = `
|
|
<button class="win-minimize" id="minimize"></button><button class="win-maximize" id="maximize"></button><button class="win-close" id="quit"></button>
|
|
`;
|
|
elem.classList.add("win-buttons");
|
|
elem.classList.add("win-buttons-light");
|
|
document.getElementsByClassName("titlebar")[0].appendChild(elem);
|
|
document.body.setAttribute("customTitlebar", "");
|
|
document.body.setAttribute("hummus", "");
|
|
document.body.setAttribute("armcord-platform", os.platform());
|
|
addStyle(`
|
|
html, body {
|
|
background-color: #1e2124;
|
|
}
|
|
|
|
.friends-header,
|
|
.chat > .title-wrap {
|
|
float: right !important;
|
|
padding-right: 140px !important;
|
|
}`);
|
|
var minimize = document.getElementById("minimize");
|
|
var maximize = document.getElementById("maximize");
|
|
var quit = document.getElementById("quit");
|
|
|
|
minimize!.addEventListener("click", () => {
|
|
ipcRenderer.send("win-minimize");
|
|
});
|
|
|
|
maximize!.addEventListener("click", () => {
|
|
if (ipcRenderer.sendSync("win-isMaximized") == true) {
|
|
ipcRenderer.send("win-unmaximize");
|
|
document.body.removeAttribute("isMaximized");
|
|
} else if (ipcRenderer.sendSync("win-isNormal") == true) {
|
|
ipcRenderer.send("win-maximize");
|
|
}
|
|
});
|
|
|
|
quit!.addEventListener("click", () => {
|
|
if (ipcRenderer.sendSync("minimizeToTray") === true) {
|
|
ipcRenderer.send("win-hide");
|
|
} else if (ipcRenderer.sendSync("minimizeToTray") === false) {
|
|
ipcRenderer.send("win-quit");
|
|
}
|
|
});
|
|
});
|
|
}
|