mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Re-add client mods (vencord, shelter)
This commit is contained in:
parent
842b6e8c5d
commit
5d80d44fc8
14 changed files with 188 additions and 38 deletions
3
src/.npmrc
Normal file
3
src/.npmrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
node-linker=hoisted
|
||||
public-hoist-pattern=*
|
||||
shamefully-hoist=true
|
|
@ -53,7 +53,9 @@
|
|||
<p class="text-center setup-ask" id="setup_question4">Select a client mod you want to install:</p>
|
||||
<div class="center">
|
||||
<select name="mod" id="mod" class="dropdown-button">
|
||||
<option value="none">None (check Discord)</option>
|
||||
<option value="vencord">Vencord</option>
|
||||
<option value="shelter">Shelter</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
<p class="text-center" id="setup_question4_clientmodnotice">
|
||||
|
|
|
@ -47,6 +47,25 @@
|
|||
console.log("ArmCord is up to date.");
|
||||
}
|
||||
}
|
||||
|
||||
function check() {
|
||||
if (armcordinternal.installState === "installing") {
|
||||
text.innerHTML = "Installing mods";
|
||||
} else if (armcordinternal.installState === "done") {
|
||||
return true;
|
||||
} else if (armcordinternal.installState === "modDownload") {
|
||||
text.innerHTML = "Updating " + armcord.mods;
|
||||
} else if (armcordinternal.installState === "none") {
|
||||
text.innerHTML = "Nothing to install. Starting ArmCord";
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
while (check() == false) {
|
||||
console.log("Installing");
|
||||
}
|
||||
setTimeout(() => {
|
||||
window.armcord.splashEnd();
|
||||
switch (window.armcord.channel) {
|
||||
|
@ -68,7 +87,7 @@
|
|||
default:
|
||||
window.location.replace("https://discord.com/app");
|
||||
}
|
||||
}, 5000);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,11 @@ const unstrictCSP = () => {
|
|||
|
||||
const cspAllowAll = ["connect-src", "style-src", "img-src", "font-src"];
|
||||
|
||||
const corsAllowUrls = ["https://raw.githubusercontent.com/Cordwood/builds/master/index.js"];
|
||||
const corsAllowUrls = [
|
||||
"https://raw.githubusercontent.com/Cordwood/builds/master/index.js",
|
||||
"https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
|
||||
"https://cors.armcord.xyz/raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js"
|
||||
];
|
||||
|
||||
electron.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders, url}, done) => {
|
||||
let csp = responseHeaders!["content-security-policy"];
|
||||
|
|
|
@ -12,7 +12,7 @@ app.whenReady().then(() => {
|
|||
const manifest = fs.readFileSync(`${userDataPath}/plugins/${file}/manifest.json`, "utf8");
|
||||
var pluginFile = JSON.parse(manifest);
|
||||
session.defaultSession.loadExtension(`${userDataPath}/plugins/${file}`);
|
||||
console.log(`%cLoaded ${pluginFile.name} made by ${pluginFile.author}`, "color:red");
|
||||
console.log(`[Mod loader] Loaded ${pluginFile.name} made by ${pluginFile.author}`);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
|
@ -9,11 +9,14 @@ import {
|
|||
getLang,
|
||||
getWindowState,
|
||||
packageVersion,
|
||||
getDisplayVersion
|
||||
getDisplayVersion,
|
||||
modInstallState,
|
||||
installModLoader
|
||||
} from "./utils";
|
||||
import {customTitlebar} from "./main";
|
||||
import {createSettingsWindow} from "./settings/main";
|
||||
import os from "os";
|
||||
import fs from "fs"
|
||||
import path from "path";
|
||||
export function registerIpc() {
|
||||
ipcMain.on("get-app-path", (event, arg) => {
|
||||
|
@ -73,6 +76,9 @@ export function registerIpc() {
|
|||
ipcMain.on("displayVersion", (event) => {
|
||||
event.returnValue = getDisplayVersion();
|
||||
});
|
||||
ipcMain.on("modInstallState", (event) => {
|
||||
event.returnValue = modInstallState;
|
||||
});
|
||||
ipcMain.on("get-package-version", (event) => {
|
||||
event.returnValue = packageVersion;
|
||||
});
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
// Modules to control application life and create native browser window
|
||||
import {app, BrowserWindow, session} from "electron";
|
||||
import "v8-compile-cache";
|
||||
import {getConfig, checkIfConfigExists, injectElectronFlags} from "./utils";
|
||||
import {getConfig, checkIfConfigExists, injectElectronFlags, installModLoader} from "./utils";
|
||||
import "./extensions/mods";
|
||||
import "./extensions/plugin";
|
||||
import "./tray";
|
||||
import {createCustomWindow, createNativeWindow, createTransparentWindow} from "./window";
|
||||
import {createCustomWindow, createNativeWindow, createTransparentWindow, mainWindow} from "./window";
|
||||
import path from "path";
|
||||
export var iconPath: string;
|
||||
export var settings: any;
|
||||
|
@ -53,6 +52,7 @@ app.whenReady().then(async () => {
|
|||
}
|
||||
}
|
||||
await init();
|
||||
await installModLoader()
|
||||
session.fromPartition("some-partition").setPermissionRequestHandler((webContents, permission, callback) => {
|
||||
if (permission === "notifications") {
|
||||
// Approves the permissions request
|
||||
|
|
|
@ -22,6 +22,7 @@ contextBridge.exposeInMainWorld("armcord", {
|
|||
return result;
|
||||
}),
|
||||
version: ipcRenderer.sendSync("get-app-version", "app-version"),
|
||||
mods: ipcRenderer.sendSync("clientmod"),
|
||||
packageVersion: ipcRenderer.sendSync("get-package-version", "app-version"),
|
||||
getDisplayMediaSelector: getDisplayMediaSelector,
|
||||
splashEnd: () => ipcRenderer.send("splashEnd"),
|
||||
|
@ -31,6 +32,7 @@ contextBridge.exposeInMainWorld("armcord", {
|
|||
if (window.location.href.indexOf("splash.html") > -1 || window.location.href.indexOf("setup.html") > -1) {
|
||||
contextBridge.exposeInMainWorld("armcordinternal", {
|
||||
restart: () => ipcRenderer.send("restart"),
|
||||
installState: ipcRenderer.sendSync("modInstallState"),
|
||||
saveSettings: (...args: any) => ipcRenderer.send("saveSettings", ...args)
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {ipcRenderer} from "electron";
|
||||
import "./bridge";
|
||||
import "./capturer";
|
||||
import "./patch";
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import {injectHummusTitlebar, injectTitlebar} from "./titlebar";
|
||||
import {sleep, addStyle, injectJS} from "../utils";
|
||||
import {ipcRenderer} from "electron";
|
||||
import {sleep, addStyle} from "../utils";
|
||||
import {injectMobileStuff} from "./mobile";
|
||||
var version = ipcRenderer.sendSync("displayVersion");
|
||||
var channel = ipcRenderer.sendSync("channel");
|
||||
|
@ -23,10 +23,6 @@ declare global {
|
|||
armcord: any;
|
||||
}
|
||||
}
|
||||
const clientMods = {
|
||||
goosemod: "https://api.goosemod.com/inject.js",
|
||||
cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js"
|
||||
};
|
||||
|
||||
console.log("ArmCord " + version);
|
||||
ipcRenderer.on("themeLoader", (event, message) => {
|
||||
|
@ -48,19 +44,7 @@ if (window.location.href.indexOf("splash.html") > -1) {
|
|||
sleep(5000).then(async () => {
|
||||
const cssPath = path.join(__dirname, "../", "/content/css/discord.css");
|
||||
addStyle(fs.readFileSync(cssPath, "utf8"));
|
||||
|
||||
switch (ipcRenderer.sendSync("clientmod")) {
|
||||
case "goosemod":
|
||||
injectJS(clientMods.goosemod);
|
||||
console.log("Loading GooseMod...");
|
||||
await updateLang();
|
||||
break;
|
||||
case "cordwood":
|
||||
injectJS(clientMods.cordwood);
|
||||
console.log("Loading Cordwood...");
|
||||
await updateLang();
|
||||
break;
|
||||
}
|
||||
await updateLang();
|
||||
});
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -123,7 +123,8 @@
|
|||
<br />
|
||||
<div class="switch acClientMod">
|
||||
<select name="mod" id="mod" class="left dropdown">
|
||||
<option value="goosemod">GooseMod</option>
|
||||
<option value="vencord">Vencord</option>
|
||||
<option value="shelter">Shelter</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
<p class="header" id="settings-mod">Client mod</p>
|
||||
|
@ -131,8 +132,9 @@
|
|||
Client mods are programs that allow you customize your Discord experience. They can change appearance of
|
||||
the client, modify behaviours or add new features!
|
||||
<br />
|
||||
<b>GooseMod</b> - light, secure, and easy to use, with out of the box experience. Features a built-in
|
||||
store for plugins.
|
||||
<b>Vencord</b> - lightweight, and easy to use client mod. Features a built-in store for plugins.
|
||||
<br />
|
||||
<b>Shelter</b> - is a new generation client mod built to be essentially bulletproof.
|
||||
</p>
|
||||
</div>
|
||||
<br />
|
||||
|
|
78
src/utils.ts
78
src/utils.ts
|
@ -1,6 +1,10 @@
|
|||
import * as fs from "fs";
|
||||
import {app, dialog} from "electron";
|
||||
import {app, dialog, session} from "electron";
|
||||
import path from "path";
|
||||
import fetch from "node-fetch"
|
||||
import extract from "extract-zip"
|
||||
import util from "util"
|
||||
const streamPipeline = util.promisify(require('stream').pipeline)
|
||||
export var firstRun: boolean;
|
||||
export var contentPath: string;
|
||||
export var transparency: boolean;
|
||||
|
@ -73,6 +77,7 @@ export function getDisplayVersion() {
|
|||
}
|
||||
}
|
||||
export async function injectJS(inject: string) {
|
||||
|
||||
const js = await (await fetch(`${inject}`)).text();
|
||||
|
||||
const el = document.createElement("script");
|
||||
|
@ -252,11 +257,8 @@ export async function setConfig(object: string, toSet: any) {
|
|||
fs.writeFileSync(getConfigLocation(), toSave, "utf-8");
|
||||
}
|
||||
export async function setConfigBulk(object: Settings) {
|
||||
const userDataPath = app.getPath("userData");
|
||||
const storagePath = path.join(userDataPath, "/storage/");
|
||||
const settingsFile = storagePath + "settings.json";
|
||||
let toSave = JSON.stringify(object);
|
||||
fs.writeFileSync(settingsFile, toSave, "utf-8");
|
||||
fs.writeFileSync(getConfigLocation(), toSave, "utf-8");
|
||||
}
|
||||
export async function checkIfConfigExists() {
|
||||
const userDataPath = app.getPath("userData");
|
||||
|
@ -281,3 +283,69 @@ export async function checkIfConfigExists() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mods
|
||||
async function updateModBundle() {
|
||||
try {
|
||||
console.log("Downloading mod bundle")
|
||||
const distFolder = app.getPath("userData") + "/plugins/loader/dist/";
|
||||
while (!fs.existsSync(distFolder)){
|
||||
//waiting
|
||||
}
|
||||
var name: string = await getConfig("mods")
|
||||
const clientMods = {
|
||||
vencord: "https://github.com/Vendicated/Vencord/releases/download/devbuild/browser.js",
|
||||
cordwood: "https://raw.githubusercontent.com/Cordwood/builds/master/index.js",
|
||||
shelter: "https://raw.githubusercontent.com/uwu/shelter-builds/main/shelter.js"
|
||||
};
|
||||
var bundle: string = await (await fetch(clientMods[name as keyof typeof clientMods])).text()
|
||||
fs.writeFileSync(distFolder + "bundle.js", bundle, "utf-8");
|
||||
} catch (e) {
|
||||
console.log("[Mod loader] Failed to install mods")
|
||||
console.error(e)
|
||||
dialog.showErrorBox(
|
||||
"Oops, something went wrong.",
|
||||
"ArmCord couldn't install mods, please check if you have stable internet connection and restart the app. If this issue persists, report it on the support server/Github issues."
|
||||
);
|
||||
}
|
||||
}
|
||||
export var modInstallState: string;
|
||||
export async function installModLoader() {
|
||||
if (await getConfig("mods") == "none") {
|
||||
modInstallState = "none"
|
||||
import("./extensions/plugin");
|
||||
console.log("[Mod loader] Skipping")
|
||||
} else {
|
||||
const pluginFolder = app.getPath("userData") + "/plugins/";
|
||||
if (!fs.existsSync(pluginFolder + "loader")) {
|
||||
try {
|
||||
modInstallState = "installing"
|
||||
var zipPath = app.getPath("temp") + "/" + "loader.zip";
|
||||
if (!fs.existsSync(pluginFolder)) {
|
||||
fs.mkdirSync(pluginFolder);
|
||||
console.log("[Mod loader] Created missing plugin folder");
|
||||
}
|
||||
var loaderZip = await fetch("https://armcord.xyz/loader.zip")
|
||||
if (!loaderZip.ok) throw new Error(`unexpected response ${loaderZip.statusText}`)
|
||||
await streamPipeline(loaderZip.body, fs.createWriteStream(zipPath))
|
||||
await extract(zipPath, { dir: path.join(app.getPath("userData"), "plugins") })
|
||||
modInstallState = "modDownload"
|
||||
updateModBundle()
|
||||
import("./extensions/plugin");
|
||||
modInstallState = "done"
|
||||
} catch(e) {
|
||||
console.log("[Mod loader] Failed to install modloader")
|
||||
console.error(e)
|
||||
dialog.showErrorBox(
|
||||
"Oops, something went wrong.",
|
||||
"ArmCord couldn't install internal mod loader, please check if you have stable internet connection and restart the app. If this issue persists, report it on the support server/Github issues."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
modInstallState = "modDownload"
|
||||
updateModBundle()
|
||||
import("./extensions/plugin");
|
||||
modInstallState = "done"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
setConfig,
|
||||
setLang,
|
||||
setWindowState,
|
||||
transparency
|
||||
transparency,
|
||||
} from "./utils";
|
||||
import {registerIpc} from "./ipc";
|
||||
import {setMenu} from "./menu";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue