2021-05-16 14:29:37 +00:00
const fs = require ( "fs" ) ;
2021-05-16 14:31:20 +00:00
const { app , session } = require ( "electron" ) ;
2021-06-30 12:42:36 +00:00
const electron = require ( "electron" ) ;
const userDataPath = ( electron . app || electron . remote . app ) . getPath ( "userData" ) ;
const pluginFolder = userDataPath + "/plugins/" ;
if ( ! fs . existsSync ( pluginFolder ) ) {
fs . mkdirSync ( pluginFolder ) ;
console . log ( "Created plugin folder" )
try {
console . log ( "Attempting to download GooseMod Extension" )
const https = require ( "https" ) ;
function download ( url , dest , cb ) {
const file = fs . createWriteStream ( dest ) ;
const request = https
. get ( url , function ( response ) {
response . pipe ( file ) ;
file . on ( "finish" , function ( ) {
file . close ( cb ) ; // close() is async, call cb after close completes.
} ) ;
} )
. on ( "error" , function ( err ) {
// Handle errors
fs . unlink ( dest ) ; // Delete the file async. (But we don't check the result)
if ( cb ) cb ( err . message ) ;
} ) ;
}
// Download latest archive from GitHub to temp folder
const dest = userDataPath + "/Cache/GooseMod.zip" ;
const url =
"https://codeload.github.com/GooseMod/Extension/zip/refs/heads/main" ;
download ( url , dest , function ( ) {
console . log ( "Downloaded, attempting to install." ) ;
const unzip = require ( "unzipper" )
fs . createReadStream ( dest ) . pipe ( unzip . Extract ( { path : pluginFolder } ) ) ;
2021-06-30 13:40:19 +00:00
electron . dialog . showMessageBox ( {
title : "ArmCord" ,
type : "warning" ,
2021-07-14 16:45:36 +00:00
message : "ArmCord has installed GooseMod onto your client." ,
2021-06-30 13:40:19 +00:00
detail :
2021-07-15 13:45:56 +00:00
"If you wish to use it restart your ArmCord completely using tray icon. It should appear in next session. GooseMod is reccomended to every user of ArmCord due to various improvements and bugfixes it ships with. You won't be able to load themes or see any of ArmCord specific CSS patches including fixed font logo at the top." ,
2021-06-30 13:40:19 +00:00
} ) ;
2021-06-30 12:42:36 +00:00
} ) ;
}
catch ( e ) {
console . error ( ` GooseMod failed to download. Error: ${ e } ` )
}
}
2021-05-16 14:29:37 +00:00
app . whenReady ( ) . then ( ( ) => {
fs . readdirSync ( pluginFolder ) . forEach ( ( file ) => {
try {
const manifest = fs . readFileSync (
2021-06-30 12:42:36 +00:00
` ${ userDataPath } /plugins/ ${ file } /manifest.json ` ,
2021-05-16 14:29:37 +00:00
"utf8"
) ;
var pluginFile = JSON . parse ( manifest ) ;
2021-06-30 12:42:36 +00:00
session . defaultSession . loadExtension ( ` ${ userDataPath } /plugins/ ${ file } ` ) ;
2021-05-16 14:29:37 +00:00
console . log (
` %cLoaded ${ pluginFile . name } made by ${ pluginFile . author } ` ,
"color:red"
) ;
} catch ( err ) {
console . error ( err ) ;
}
} ) ;
} ) ;