mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
commit
18bebfb421
5 changed files with 76 additions and 44 deletions
|
@ -43,7 +43,15 @@
|
|||
} else {
|
||||
console.log("Starting ArmCord Setup...");
|
||||
document.getElementById("express").addEventListener("click", function () {
|
||||
window.armcordinternal.saveSettings("default", "stable", true, true, false, "cumcord", "acrylic");
|
||||
window.armcordinternal.saveSettings({
|
||||
windowStyle: "default",
|
||||
channel: "stable",
|
||||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: "cumcord",
|
||||
blurType: "acrylic"
|
||||
})
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart()
|
||||
|
@ -91,15 +99,30 @@
|
|||
.getElementById("next")
|
||||
.addEventListener("click", function () {
|
||||
var mod = document.getElementById("mod").value;
|
||||
window.armcordinternal.saveSettings("default", branch, true,true,false, mod, "acrylic");
|
||||
window.armcordinternal.saveSettings({
|
||||
windowStyle: "default",
|
||||
channel: branch,
|
||||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: mod,
|
||||
blurType: "acrylic"
|
||||
})
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart();
|
||||
}, 5000);
|
||||
});
|
||||
} else {
|
||||
//saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray:boolean, modsSetting: string)
|
||||
window.armcordinternal.saveSettings("default", branch, true,true,false, "none", "acrylic");
|
||||
window.armcordinternal.saveSettings({
|
||||
windowStyle: "default",
|
||||
channel: branch,
|
||||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: "none",
|
||||
blurType: "acrylic"
|
||||
})
|
||||
fade(document.getElementById("setup"));
|
||||
setTimeout(function () {
|
||||
window.armcordinternal.restart()
|
||||
|
|
|
@ -45,9 +45,8 @@ export function registerIpc() {
|
|||
app.relaunch();
|
||||
app.exit();
|
||||
});
|
||||
ipcMain.on("saveSettings", (event, ...args) => {
|
||||
//@ts-ignore
|
||||
saveSettings(...args);
|
||||
ipcMain.on("saveSettings", (event, args) => {
|
||||
saveSettings(args);
|
||||
});
|
||||
ipcMain.on("minimizeToTray", (event) => {
|
||||
console.log(settings.minimizeToTray);
|
||||
|
|
|
@ -8,14 +8,20 @@ const desktopCapturer = {
|
|||
};
|
||||
const CANCEL_ID = 'desktop-capturer-selection__cancel';
|
||||
|
||||
interface IPCSources {
|
||||
id: string;
|
||||
name: string;
|
||||
thumbnail: HTMLCanvasElement;
|
||||
}
|
||||
|
||||
export async function getDisplayMediaSelector() {
|
||||
const sources = await desktopCapturer.getSources({
|
||||
const sources: IPCSources[] = await desktopCapturer.getSources({
|
||||
types: ['screen', 'window'],
|
||||
});
|
||||
return `<div class="desktop-capturer-selection__scroller">
|
||||
<ul class="desktop-capturer-selection__list">
|
||||
${sources
|
||||
.map( //@ts-ignore i know it works
|
||||
.map(
|
||||
({ id, name, thumbnail }) => `
|
||||
<li class="desktop-capturer-selection__item">
|
||||
<button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}">
|
||||
|
@ -148,7 +154,7 @@ window.navigator.mediaDevices.getDisplayMedia = () => new Promise(async (resolve
|
|||
});
|
||||
`;
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
addScript(screenShareJS);
|
||||
addStyle(screenShareCSS);
|
||||
console.log("Capturer injected.")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { BrowserWindow, shell, ipcMain } from "electron";
|
||||
import * as storage from "electron-json-storage";
|
||||
import {getConfigUnsafe, saveSettings} from "../utils";
|
||||
import {getConfigUnsafe, saveSettings, Settings} from "../utils";
|
||||
import path from "path";
|
||||
var settings:any;
|
||||
var isAlreadyCreated:boolean = false;
|
||||
|
@ -25,9 +25,9 @@ export function createSettingsWindow() {
|
|||
preload: path.join(__dirname, "preload.js"),
|
||||
},
|
||||
});
|
||||
ipcMain.on("saveSettings", (event, ...args) => {
|
||||
//@ts-ignore
|
||||
saveSettings(...args);
|
||||
ipcMain.on("saveSettings", (event, args: Settings) => {
|
||||
console.log(args);
|
||||
saveSettings(args);
|
||||
});
|
||||
ipcMain.handle("getSetting", (event, toGet: string) => {
|
||||
return getConfigUnsafe(toGet);
|
||||
|
|
58
src/utils.ts
58
src/utils.ts
|
@ -16,54 +16,58 @@ export function addScript(scriptString: string) {
|
|||
script.textContent = scriptString;
|
||||
document.body.append(script);
|
||||
}
|
||||
|
||||
export async function sleep(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export async function checkIfConfigIsNew() {
|
||||
if (await getConfigUnsafe("automaticPatches") == undefined) {
|
||||
firstRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
windowStyle: string,
|
||||
channel: string,
|
||||
armcordCSP: boolean,
|
||||
minimizeToTray: boolean,
|
||||
automaticPatches: boolean,
|
||||
mods: string,
|
||||
blurType: string
|
||||
}
|
||||
export function setup() {
|
||||
console.log("Setting up temporary ArmCord settings.");
|
||||
storage.set(
|
||||
"settings",
|
||||
{
|
||||
const defaults: Settings = {
|
||||
windowStyle: "default",
|
||||
channel: "stable",
|
||||
doneSetup: true,
|
||||
armcordCSP: true,
|
||||
minimizeToTray: true,
|
||||
automaticPatches: false,
|
||||
mods: "cumcord",
|
||||
blurType: "acrylic",
|
||||
}
|
||||
storage.set(
|
||||
"settings",
|
||||
{
|
||||
...defaults,
|
||||
doneSetup: true,
|
||||
},
|
||||
function (error) {
|
||||
if (error) throw error;
|
||||
}
|
||||
);
|
||||
}
|
||||
export async function sleep(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
export async function checkIfConfigIsNew() {
|
||||
if (await getConfigUnsafe("automaticPatches") == undefined) {
|
||||
firstRun = true;
|
||||
}
|
||||
}
|
||||
|
||||
export function saveSettings(
|
||||
windowStyle: string,
|
||||
channelSetting: string,
|
||||
armcordCSPSetting: boolean,
|
||||
minimizeToTray: boolean,
|
||||
automaticPatches: boolean,
|
||||
modsSetting: string,
|
||||
blurType: string
|
||||
settings: Settings
|
||||
) {
|
||||
console.log("Setting up ArmCord settings.");
|
||||
storage.set(
|
||||
"settings",
|
||||
{
|
||||
windowStyle: windowStyle,
|
||||
channel: channelSetting,
|
||||
doneSetup: true,
|
||||
armcordCSP: armcordCSPSetting,
|
||||
minimizeToTray: minimizeToTray,
|
||||
automaticPatches: automaticPatches,
|
||||
mods: modsSetting,
|
||||
blurType: blurType
|
||||
...settings,
|
||||
doneSetup: true
|
||||
},
|
||||
function (error) {
|
||||
if (error) throw error;
|
||||
|
|
Loading…
Reference in a new issue