Add Cordwood, better Hummus support and skip splash

This commit is contained in:
smartfridge 2022-07-18 17:13:52 +02:00
parent 9717eaedb1
commit 0fb71dfe2b
6 changed files with 90 additions and 7 deletions

View file

@ -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) => {

View file

@ -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,8 +37,12 @@ if (window.location.href.indexOf("splash.html") > -1) {
console.log("Skipping titlebar injection and client mod injection.");
} else {
if (ipcRenderer.sendSync("titlebar")) {
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;
}
});
}

View file

@ -54,3 +54,42 @@ export function injectTitlebar() {
});
});
}
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("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");
}
});
});
}

View file

@ -112,8 +112,9 @@
<b>PTB</b> - public test build. Receives features earlier than stable but is a bit older than
Canary.
<br />
<b>Hummus</b> - 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.
<b>Hummus</b> - 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.
</p>
</div>
</div>
@ -168,6 +169,13 @@
<br />
<br />
<h1 class="center advancedText">Advanced user zone⚠</h1>
<div class="switch acAltPaste">
<label class="header2" id="settings-skipSplash">Skip splash screen (experimental)</label>
<input class="tgl tgl-light left" id="skipSplash" type="checkbox" />
<label class="tgl-btn left" for="skipSplash"></label>
<p class="description2">Skips ArmCord splash screen when you start up the app.</p>
</div>
<br />
<button id="settings-pluginsFolder" class="center">Open plugins folder</button>
<br />
<button id="settings-themesFolder" class="center">Open themes folder</button>
@ -206,6 +214,7 @@
document.getElementById("tray").checked = await settings.get("minimizeToTray");
document.getElementById("websocket").checked = await settings.get("inviteWebsocket");
document.getElementById("alternativePaste").checked = await settings.get("alternativePaste");
document.getElementById("skipSplash").checked = await settings.get("skipSplash");
document.getElementById("mobile").checked = await settings.get("mobileMode");
document.getElementById("patches").value = await settings.get("automaticPatches");
document.getElementById("mod").value = await settings.get("mods");
@ -222,6 +231,7 @@
armcordCSP: document.getElementById("csp").checked,
minimizeToTray: document.getElementById("tray").checked,
alternativePaste: document.getElementById("alternativePaste").checked,
skipSplash: document.getElementById("skipSplash").checked,
automaticPatches: document.getElementById("patches").checked,
mods: document.getElementById("mod").value,
mobileMode: document.getElementById("mobile").checked,

View file

@ -42,6 +42,7 @@ export function setup() {
alternativePaste: false,
mods: "cumcord",
performanceMode: "none",
skipSplash: false,
inviteWebsocket: true,
mobileMode: false,
trayIcon: "ac_plug_colored",
@ -191,6 +192,7 @@ export interface Settings {
alternativePaste: boolean;
mods: string;
mobileMode: boolean,
skipSplash: boolean,
performanceMode: string;
inviteWebsocket: boolean;
trayIcon: string;

View file

@ -125,9 +125,31 @@ async function doAfterDefiningTheWindow() {
await setLang(Intl.DateTimeFormat().resolvedOptions().locale)
mainWindow.setSize(390, 470);
await mainWindow.loadFile(path.join(__dirname, "/content/setup.html"));
} else {
if (await getConfig("skipSplash") == true) {
switch (await getConfig("channel")) {
case "stable":
mainWindow.loadURL("https://discord.com/app");
break;
case "canary":
mainWindow.loadURL("https://canary.discord.com/app");
break;
case "ptb":
mainWindow.loadURL("https://ptb.discord.com/app");
break;
case "hummus":
mainWindow.loadURL("https://hummus.sys42.net/");
break;
case undefined:
mainWindow.loadURL("https://discord.com/app");
break;
default:
mainWindow.loadURL("https://discord.com/app");
}
} else {
await mainWindow.loadFile(path.join(__dirname, "/content/splash.html"));
}
}
}
export function createCustomWindow() {
mainWindow = new BrowserWindow({