From 0fb71dfe2b8a723d3879ddc0a8e7918ee652cac0 Mon Sep 17 00:00:00 2001
From: smartfridge <37928912+smartfrigde@users.noreply.github.com>
Date: Mon, 18 Jul 2022 17:13:52 +0200
Subject: [PATCH] Add Cordwood, better Hummus support and skip splash
---
src/extensions/mods.ts | 2 +-
src/preload/preload.ts | 16 +++++++++++++---
src/preload/titlebar.ts | 39 ++++++++++++++++++++++++++++++++++++++
src/settings/settings.html | 14 ++++++++++++--
src/utils.ts | 2 ++
src/window.ts | 24 ++++++++++++++++++++++-
6 files changed, 90 insertions(+), 7 deletions(-)
diff --git a/src/extensions/mods.ts b/src/extensions/mods.ts
index fb2c5c2..9821a12 100644
--- a/src/extensions/mods.ts
+++ b/src/extensions/mods.ts
@@ -28,7 +28,7 @@ const unstrictCSP = () => {
"https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js",
"https://raw.githubusercontent.com/Cumcord/Cumcord/master/dist/build.js",
"https://raw.githubusercontent.com/FlickerMod/dist/main/build.js",
- "https://localhost:1234/dist.js"
+ "https://raw.githubusercontent.com/Cordwood/builds/master/index.js"
];
electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, url}, done) => {
diff --git a/src/preload/preload.ts b/src/preload/preload.ts
index ac6ccf7..52cf93e 100644
--- a/src/preload/preload.ts
+++ b/src/preload/preload.ts
@@ -3,7 +3,7 @@ import "./capturer";
import "./patch";
import * as fs from "fs";
import * as path from "path";
-import {injectTitlebar} from "./titlebar";
+import {injectHummusTitlebar, injectTitlebar} from "./titlebar";
import {sleep, addStyle, injectJS, addScript} from "../utils";
import {ipcRenderer} from "electron";
import {injectMobileStuff} from "./mobile";
@@ -25,7 +25,8 @@ declare global {
const clientMods = {
goosemod: "https://api.goosemod.com/inject.js",
cumcord: "https://raw.githubusercontent.com/Cumcord/Cumcord/stable/dist/build.js",
- flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js"
+ flicker: "https://raw.githubusercontent.com/FlickerMod/dist/main/build.js",
+ cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js"
};
console.log("ArmCord " + version);
@@ -36,7 +37,11 @@ if (window.location.href.indexOf("splash.html") > -1) {
console.log("Skipping titlebar injection and client mod injection.");
} else {
if (ipcRenderer.sendSync("titlebar")) {
- injectTitlebar();
+ if (ipcRenderer.sendSync("channel")) {
+ injectHummusTitlebar();
+ } else {
+ injectTitlebar();
+ }
}
if (ipcRenderer.sendSync("mobileMode")) {
injectMobileStuff();
@@ -61,6 +66,11 @@ if (window.location.href.indexOf("splash.html") > -1) {
console.log("Loading FlickerMod...");
await updateLang();
break;
+ case "cordwood":
+ injectJS(clientMods.cordwood);
+ console.log("Loading Cordwood...");
+ await updateLang();
+ break;
}
});
}
diff --git a/src/preload/titlebar.ts b/src/preload/titlebar.ts
index a3fe1bc..bd54ef6 100644
--- a/src/preload/titlebar.ts
+++ b/src/preload/titlebar.ts
@@ -54,3 +54,42 @@ export function injectTitlebar() {
});
});
}
+export function injectHummusTitlebar() {
+ document.addEventListener("DOMContentLoaded", function (event) {
+ var elem = document.createElement("div");
+ elem.innerHTML = `
+
+ `;
+ elem.classList.add("win-buttons");
+ elem.classList.add("win-buttons-light");
+ document.getElementsByClassName("titlebar")[0].appendChild(elem);
+ document.body.setAttribute("customTitlebar", "");
+ document.body.setAttribute("armcord-platform", os.platform());
+ addStyle(".chat>.title-wrap {width: 87% !important;}");
+ addStyle(".friends-header {width: 91% !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");
+ }
+ });
+ });
+}
diff --git a/src/settings/settings.html b/src/settings/settings.html
index a75a8d2..355e8ff 100644
--- a/src/settings/settings.html
+++ b/src/settings/settings.html
@@ -112,8 +112,9 @@
PTB - public test build. Receives features earlier than stable but is a bit older than
Canary.
- Hummus - unofficial instance of Discord that takes you back to 2016! None of the client mods
- bundled with ArmCord work with it. It's run by community, so you take all the risk by using it.
+ Hummus - unofficial instance of Discord that takes you back to 2016! Only client mod
+ available to run alongside with it is Cordwood. It's run by community, so you take all the risk by
+ using it.
Skips ArmCord splash screen when you start up the app.
+