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 { |       } else { | ||||||
|         console.log("Starting ArmCord Setup..."); |         console.log("Starting ArmCord Setup..."); | ||||||
|         document.getElementById("express").addEventListener("click", function () { |         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")); |           fade(document.getElementById("setup")); | ||||||
|                 setTimeout(function () { |                 setTimeout(function () { | ||||||
|                   window.armcordinternal.restart() |                   window.armcordinternal.restart() | ||||||
|  | @ -91,15 +99,30 @@ | ||||||
|                   .getElementById("next") |                   .getElementById("next") | ||||||
|                   .addEventListener("click", function () { |                   .addEventListener("click", function () { | ||||||
|                     var mod = document.getElementById("mod").value; |                     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")); |                     fade(document.getElementById("setup")); | ||||||
|                     setTimeout(function () { |                     setTimeout(function () { | ||||||
|                       window.armcordinternal.restart(); |                       window.armcordinternal.restart(); | ||||||
|                     }, 5000); |                     }, 5000); | ||||||
|                   }); |                   }); | ||||||
|               } else { |               } else { | ||||||
|                 //saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray:boolean, modsSetting: string) |                 window.armcordinternal.saveSettings({ | ||||||
|                 window.armcordinternal.saveSettings("default", branch, true,true,false, "none", "acrylic"); |                   windowStyle: "default", | ||||||
|  |                   channel: branch, | ||||||
|  |                   armcordCSP: true, | ||||||
|  |                   minimizeToTray: true, | ||||||
|  |                   automaticPatches: false, | ||||||
|  |                   mods: "none", | ||||||
|  |                   blurType: "acrylic" | ||||||
|  |                 }) | ||||||
|                 fade(document.getElementById("setup")); |                 fade(document.getElementById("setup")); | ||||||
|                 setTimeout(function () { |                 setTimeout(function () { | ||||||
|                   window.armcordinternal.restart() |                   window.armcordinternal.restart() | ||||||
|  |  | ||||||
|  | @ -45,9 +45,8 @@ export function registerIpc() { | ||||||
|     app.relaunch(); |     app.relaunch(); | ||||||
|     app.exit(); |     app.exit(); | ||||||
|   }); |   }); | ||||||
|   ipcMain.on("saveSettings", (event, ...args) => { |   ipcMain.on("saveSettings", (event, args) => { | ||||||
|     //@ts-ignore
 |     saveSettings(args); | ||||||
|     saveSettings(...args); |  | ||||||
|   }); |   }); | ||||||
|   ipcMain.on("minimizeToTray", (event) => { |   ipcMain.on("minimizeToTray", (event) => { | ||||||
|     console.log(settings.minimizeToTray); |     console.log(settings.minimizeToTray); | ||||||
|  |  | ||||||
|  | @ -8,14 +8,20 @@ const desktopCapturer = { | ||||||
| }; | }; | ||||||
| const CANCEL_ID = 'desktop-capturer-selection__cancel'; | const CANCEL_ID = 'desktop-capturer-selection__cancel'; | ||||||
| 
 | 
 | ||||||
|  | interface IPCSources { | ||||||
|  |   id: string; | ||||||
|  |   name: string; | ||||||
|  |   thumbnail: HTMLCanvasElement; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export async function getDisplayMediaSelector() { | export async function getDisplayMediaSelector() { | ||||||
|   const sources = await desktopCapturer.getSources({ |   const sources: IPCSources[] = await desktopCapturer.getSources({ | ||||||
|     types: ['screen', 'window'], |     types: ['screen', 'window'], | ||||||
|   }); |   }); | ||||||
|   return `<div class="desktop-capturer-selection__scroller">
 |   return `<div class="desktop-capturer-selection__scroller">
 | ||||||
|   <ul class="desktop-capturer-selection__list"> |   <ul class="desktop-capturer-selection__list"> | ||||||
|     ${sources |     ${sources | ||||||
|       .map( //@ts-ignore i know it works
 |       .map( | ||||||
|         ({ id, name, thumbnail }) => ` |         ({ id, name, thumbnail }) => ` | ||||||
|       <li class="desktop-capturer-selection__item"> |       <li class="desktop-capturer-selection__item"> | ||||||
|         <button class="desktop-capturer-selection__btn" data-id="${id}" title="${name}"> |         <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); |   addScript(screenShareJS); | ||||||
|   addStyle(screenShareCSS); |   addStyle(screenShareCSS); | ||||||
|   console.log("Capturer injected.") |   console.log("Capturer injected.") | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { BrowserWindow, shell, ipcMain } from "electron"; | import { BrowserWindow, shell, ipcMain } from "electron"; | ||||||
| import * as storage from "electron-json-storage";  | import * as storage from "electron-json-storage";  | ||||||
| import {getConfigUnsafe, saveSettings} from "../utils"; | import {getConfigUnsafe, saveSettings, Settings} from "../utils"; | ||||||
| import path from "path"; | import path from "path"; | ||||||
| var settings:any; | var settings:any; | ||||||
| var isAlreadyCreated:boolean = false; | var isAlreadyCreated:boolean = false; | ||||||
|  | @ -25,9 +25,9 @@ export function createSettingsWindow() { | ||||||
|       preload: path.join(__dirname, "preload.js"), |       preload: path.join(__dirname, "preload.js"), | ||||||
|     }, |     }, | ||||||
|   }); |   }); | ||||||
|   ipcMain.on("saveSettings", (event, ...args) => { |   ipcMain.on("saveSettings", (event, args: Settings) => { | ||||||
|     //@ts-ignore
 |     console.log(args); | ||||||
|     saveSettings(...args); |     saveSettings(args); | ||||||
|   }); |   }); | ||||||
|   ipcMain.handle("getSetting", (event, toGet: string) => { |   ipcMain.handle("getSetting", (event, toGet: string) => { | ||||||
|     return getConfigUnsafe(toGet); |     return getConfigUnsafe(toGet); | ||||||
|  |  | ||||||
							
								
								
									
										58
									
								
								src/utils.ts
									
										
									
									
									
								
							
							
						
						
									
										58
									
								
								src/utils.ts
									
										
									
									
									
								
							|  | @ -16,54 +16,58 @@ export function addScript(scriptString: string) { | ||||||
|   script.textContent = scriptString; |   script.textContent = scriptString; | ||||||
|   document.body.append(script); |   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() { | export function setup() { | ||||||
|   console.log("Setting up temporary ArmCord settings."); |   console.log("Setting up temporary ArmCord settings."); | ||||||
|   storage.set( |   const defaults: Settings = { | ||||||
|     "settings", |  | ||||||
|     { |  | ||||||
|     windowStyle: "default", |     windowStyle: "default", | ||||||
|     channel: "stable", |     channel: "stable", | ||||||
|       doneSetup: true, |  | ||||||
|     armcordCSP: true, |     armcordCSP: true, | ||||||
|     minimizeToTray: true, |     minimizeToTray: true, | ||||||
|     automaticPatches: false, |     automaticPatches: false, | ||||||
|     mods: "cumcord", |     mods: "cumcord", | ||||||
|     blurType: "acrylic", |     blurType: "acrylic", | ||||||
|  |   } | ||||||
|  |   storage.set( | ||||||
|  |     "settings", | ||||||
|  |     { | ||||||
|  |       ...defaults, | ||||||
|  |       doneSetup: true, | ||||||
|     }, |     }, | ||||||
|     function (error) { |     function (error) { | ||||||
|       if (error) throw 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( | export function saveSettings( | ||||||
|   windowStyle: string, |   settings: Settings | ||||||
|   channelSetting: string, |  | ||||||
|   armcordCSPSetting: boolean, |  | ||||||
|   minimizeToTray: boolean, |  | ||||||
|   automaticPatches: boolean, |  | ||||||
|   modsSetting: string, |  | ||||||
|   blurType: string |  | ||||||
| ) { | ) { | ||||||
|   console.log("Setting up ArmCord settings."); |   console.log("Setting up ArmCord settings."); | ||||||
|   storage.set( |   storage.set( | ||||||
|     "settings", |     "settings", | ||||||
|     { |     { | ||||||
|       windowStyle: windowStyle, |       ...settings, | ||||||
|       channel: channelSetting, |       doneSetup: true | ||||||
|       doneSetup: true, |  | ||||||
|       armcordCSP: armcordCSPSetting, |  | ||||||
|       minimizeToTray: minimizeToTray, |  | ||||||
|       automaticPatches: automaticPatches, |  | ||||||
|       mods: modsSetting, |  | ||||||
|       blurType: blurType |  | ||||||
|     }, |     }, | ||||||
|     function (error) { |     function (error) { | ||||||
|       if (error) throw error; |       if (error) throw error; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue